ContextTest.php 692 B

1234567891011121314151617181920212223242526
  1. <?php
  2. class ContextTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function testContext()
  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. $this->assertEquals("127.0.0.10", $context->ip);
  14. $this->assertEquals($context, \Tools\Context::getContext());
  15. try {
  16. $i = $context->undefinedAttribute;
  17. $this->fail("Expected exception");
  18. }
  19. catch (\Exception $e)
  20. { }
  21. }
  22. }