<?php

class ControllerTest extends PHPUnit_Framework_TestCase
{
	public function testContext()
	{
		list($server, $mysqlConfig) = require("test/config.php");
		$dbh = new PDO($mysqlConfig[4][0], $mysqlConfig[1], $mysqlConfig[2]);
		$dbh->exec("DROP DATABASE ".$mysqlConfig[4][1]);
		$dbh->exec("CREATE DATABASE ".$mysqlConfig[4][1]);
		\Entity\ModelBase::init($mysqlConfig);
		$context = new \Tools\Context($server, false);
		\Entity\ModelBase::setup();
		$moduleMan = new \Tools\ModuleManager($context);
		$this->assertTrue($context->router->overrideUrl("modulesPath", dirname(__FILE__)."/modules/"));
		$mod = $moduleMan->install("testController");
		$this->assertNotFalse($mod);
		$this->assertNotNull($mod);
		$this->assertInstanceOf("\MockIndexController", $context->serve());
	}
}

