Browse Source

tests

develop
Robin Thoni 8 years ago
parent
commit
aecced19b7
2 changed files with 57 additions and 1 deletions
  1. 55
    0
      tests/LuUsersTest.php
  2. 2
    1
      tests/bootstrap.php

+ 55
- 0
tests/LuUsersTest.php View File

@@ -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
+}

+ 2
- 1
tests/bootstrap.php View File

@@ -7,8 +7,9 @@
7 7
  */
8 8
 
9 9
 use Luticate\Utils\Controller\LuticateApplication;
10
+use Luticate\Utils\DataAccess\LuDataAccess;
10 11
 
11 12
 $json = file_get_contents(__DIR__ . '/../config.json');
12 13
 $config = json_decode($json, true);
13 14
 $app = new LuticateApplication($config);
14
-$app->addDatabaseProvider(\Luticate\Utils\DataAccess\LuDataAccess::class);
15
+$app->addDatabaseProvider(LuDataAccess::class);

Loading…
Cancel
Save