Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

LuApplicationTest.php 2.6KB

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