RouterTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. class RouterTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function testBaseLinker()
  5. {
  6. list($server, $mysqlConfig) = require("test/config.php");
  7. $dbh = new PDO($mysqlConfig[4][0], $mysqlConfig[1], $mysqlConfig[2]);
  8. $dbh->exec("DROP DATABASE ".$mysqlConfig[4][1]);
  9. $dbh->exec("CREATE DATABASE ".$mysqlConfig[4][1]);
  10. \Entity\ModelBase::init($mysqlConfig);
  11. $context = new \Tools\Context($server, false);
  12. \Entity\ModelBase::setup();
  13. $context->serve();
  14. $router = $context->router;
  15. $this->assertNotNull($router);
  16. $this->assertEquals("http://my.host.name/", $router->rootUrl);
  17. $this->assertEquals("http://my.host.name/content/modules/", $router->modulesUrl);
  18. $this->assertEquals("http://my.host.name/content/theme/", $router->themesUrl);
  19. try {
  20. $router->getFail;
  21. $this->fail("Expected exception");
  22. }
  23. catch (\Exception $e) {}
  24. }
  25. /**
  26. * @runInSeparateProcess
  27. **/
  28. public function testRedirect()
  29. {
  30. list($server, $mysqlConfig) = require("test/config.php");
  31. $dbh = new PDO($mysqlConfig[4][0], $mysqlConfig[1], $mysqlConfig[2]);
  32. $dbh->exec("DROP DATABASE ".$mysqlConfig[4][1]);
  33. $dbh->exec("CREATE DATABASE ".$mysqlConfig[4][1]);
  34. \Entity\ModelBase::init($mysqlConfig);
  35. $context = new \Tools\Context($server, false);
  36. \Entity\ModelBase::setup();
  37. \Entity\Config::setConfig(null, "siteUrl", "my.host2.name");
  38. $context = new \Tools\Context($server, false);
  39. $context->serve();
  40. $this->fail("Expected redirect then die");
  41. }
  42. public function testLinker()
  43. {
  44. /*
  45. list($server, $mysqlConfig) = require("test/config.php");
  46. $dbh = new PDO($mysqlConfig[4][0], $mysqlConfig[1], $mysqlConfig[2]);
  47. $dbh->exec("DROP DATABASE ".$mysqlConfig[4][1]);
  48. $dbh->exec("CREATE DATABASE ".$mysqlConfig[4][1]);
  49. \Entity\ModelBase::init($mysqlConfig);
  50. $context = new \Tools\Context($server, false);
  51. \Entity\ModelBase::setup();
  52. $context->serve();
  53. $router = $context->router;
  54. */
  55. }
  56. }