/** * Runs before each test * * @return void */ protected function setUp() { parent::setUp(); $this->originalDiContainer = Application::getInstance()->getDiContainer(); $diContainer = new SystemContainer(); $this->storage = new StorageMock(true, false, array()); $diContainer->setMiddlewareStorage($this->storage); Application::getInstance()->setDiContainer($diContainer); Config::getInstance()->set(array('system.project.name' => 'test')); }
public function testMiddlewareStorage() { $sc = new SystemContainer(); try { $sc->getMiddlewareStorage(); $this->fail('Getting a middleware storage without setting one first should result in a DiExceptiom'); } catch (\YapepBase\Exception\DiException $e) { $this->assertEquals(\YapepBase\Exception\DiException::ERR_INSTANCE_NOT_SET, $e->getCode()); } $storage = new StorageMock(true, true); $sc->setMiddlewareStorage($storage); $this->assertSame($storage, $sc->getMiddlewareStorage(), 'The retrieved middleware storage is not the one that has been set.'); }