|
@@ -0,0 +1,72 @@
|
|
1
|
+<?php
|
|
2
|
+use Luticate\Utils\Controller\LuticateApplication;
|
|
3
|
+use Luticate\Utils\Dbo\LuDboDeserializeException;
|
|
4
|
+use Luticate\Utils\Dbo\LuBoolDboArray;
|
|
5
|
+
|
|
6
|
+/**
|
|
7
|
+ * Created by PhpStorm.
|
|
8
|
+ * User: robin
|
|
9
|
+ * Date: 5/29/16
|
|
10
|
+ * Time: 2:57 PM
|
|
11
|
+ */
|
|
12
|
+
|
|
13
|
+class LuApplicationTest extends \PHPUnit_Framework_TestCase
|
|
14
|
+{
|
|
15
|
+ public function testGetDatabases1()
|
|
16
|
+ {
|
|
17
|
+ $db1 = ["name" => "mydb", "other_info" => 42];
|
|
18
|
+ $dbs = [$db1];
|
|
19
|
+ $this->assertSame($db1, LuticateApplication::getDatabase($db1["name"], $dbs));
|
|
20
|
+ }
|
|
21
|
+
|
|
22
|
+ public function testGetDatabases2()
|
|
23
|
+ {
|
|
24
|
+ $db1 = ["name" => "mydb", "other_info" => 42];
|
|
25
|
+ $dbs = [$db1];
|
|
26
|
+ $this->assertNull(LuticateApplication::getDatabase("db", $dbs));
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ public function testGetDatabases3()
|
|
30
|
+ {
|
|
31
|
+ $db1 = ["name" => "mydb", "other_info" => 42];
|
|
32
|
+ $db2 = ["name" => "myotherdb", "other_info" => 42];
|
|
33
|
+ $dbs = [$db1, $db2];
|
|
34
|
+ $this->assertSame($db2, LuticateApplication::getDatabase($db2["name"], $dbs));
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ public function testGetDatabases4()
|
|
38
|
+ {
|
|
39
|
+ $db1 = ["name" => "mydb", "other_info" => 42];
|
|
40
|
+ $db2 = ["name" => "myotherdb", "other_info" => 42];
|
|
41
|
+ $dbs = [$db1, $db2];
|
|
42
|
+ $this->assertNull(LuticateApplication::getDatabase("anotherdb", $dbs));
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ public function testResolveDatabases1()
|
|
46
|
+ {
|
|
47
|
+ $db1 = ["name" => "mydb", "other_info" => 42];
|
|
48
|
+ $dbs = [$db1, "mydb"];
|
|
49
|
+ $this->assertSame([$db1, $db1], LuticateApplication::resolveDatabases($dbs));
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ public function testResolveDatabases2()
|
|
53
|
+ {
|
|
54
|
+ $db1 = ["name" => "mydb", "other_info" => 42];
|
|
55
|
+ $dbs = [$db1, "mydb2"];
|
|
56
|
+ $this->assertSame([$db1], LuticateApplication::resolveDatabases($dbs));
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ public function testResolveDatabases3()
|
|
60
|
+ {
|
|
61
|
+ $db1 = ["name" => "mydb", "other_info" => 42];
|
|
62
|
+ $dbs = ["mydb2", $db1];
|
|
63
|
+ $this->assertSame([$db1], LuticateApplication::resolveDatabases($dbs));
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ public function testResolveDatabases4()
|
|
67
|
+ {
|
|
68
|
+ $db1 = ["name" => "mydb", "other_info" => 42];
|
|
69
|
+ $dbs = ["mydb", $db1];
|
|
70
|
+ $this->assertSame([$db1, $db1], LuticateApplication::resolveDatabases($dbs));
|
|
71
|
+ }
|
|
72
|
+}
|