/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->config = new ConfigForMocking(APP_ROOT_DIRECTORY . 'config/', new NullCache()); $this->object = new Router(); $this->object->setConfig($this->config); $this->config->setUnmockedClassesAllowed(true); }
/** * Creates a new MockDb object, this is used to mock database tables. * * @param \Emmetog\Config\ConfigForMocking $config The ConfigForMocking object. * @param \Emmetog\Config\Config $real_config A real config object, used to get * the structure of the real table (optional). If not specified then * the same config dir and cache as the ConfigForMocking object are * used to create a new (real) config object. */ public function __construct(ConfigForMocking $config, Config $real_config = null) { $this->config = $config; if (!$real_config) { $real_config = new Config($config->getConfigDirectory(), $config->getCache()); } $this->mockDbModelReal = new MockDbModel($real_config); $this->mockDbModelTest = new MockDbModel($this->config); }
/** * Test the getClass() method when unmocked classes are allowed. * * We expect to be able to get the class without any exceptions thrown. */ public function testGetClassWhenUnmockedClassesAreAllowed() { $this->object->setUnmockedClassesAllowed(true); $testClass = $this->object->getClass('stdClass'); $this->assertInstanceOf('stdClass', $testClass); }