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