You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuUsersTest.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. use Luticate\Auth\Controller\LuUsersController;
  3. use Luticate\Auth\Dbo\Users\LuUsersAddDbo;
  4. use Luticate\Utils\Controller\LuticateApplication;
  5. use Luticate\Utils\DataAccess\LuDataAccess;
  6. /**
  7. * Created by PhpStorm.
  8. * User: robin
  9. * Date: 9/18/16
  10. * Time: 1:02 AM
  11. */
  12. class Db extends LuDataAccess
  13. {
  14. protected static $_connection = "luticatedb";
  15. }
  16. class LuUsersTest extends \PHPUnit_Framework_TestCase
  17. {
  18. protected function getCtrl()
  19. {
  20. return new LuUsersController();
  21. }
  22. public static function setUpBeforeClass()
  23. {
  24. Db::getPdo()->query("DELETE FROM lu_users WHERE username LIKE '_test_%'");
  25. }
  26. public function testUserAdd1()
  27. {
  28. $ctrl = static::getCtrl();
  29. $newUser = new LuUsersAddDbo();
  30. $newUser->setUsername("_test_user1");
  31. $newUser->setPassword("test42");
  32. $newUser->setFirstname("Test");
  33. $newUser->setLastname("user1");
  34. $newUser->setEmail("test.user1@example.com");
  35. $newUser->setExternalAuth(null);
  36. $newUser->setProfileId(null);
  37. $user = $ctrl->add($newUser);
  38. $this->assertNotNull($user);
  39. $this->assertNotNull($user->getId());
  40. $this->assertSame($user->getUsername(), "_test_user1");
  41. $this->assertSame($user->getFirstname(), "Test");
  42. $this->assertSame($user->getLastname(), "user1");
  43. $this->assertSame($user->getEmail(), "test.user1@example.com");
  44. $this->assertNull($user->getExternalAuth());
  45. $this->assertNull($user->getProfileId());
  46. }
  47. }