/** * @When I try to get the service :serviceId out of the container */ public function iTryToGetTheServiceOutOfTheContainer($serviceId) { try { $this->container->get($serviceId); } catch (\Exception $exception) { $this->lastExceptionFromContainer = $exception; } }
public function testCanGetFrontControllerFromDi() { // ARRANGE $container = DiContainer::getInstance(); // ACT $frontController = $container->get('restinpeace.frontcontroller'); // ASSERT $this->assertInstanceOf('\\RestInPeace\\FrontController', $frontController); }
/** * @expectedException \DirtyNeedle\Exception\CyclicDependencyInDiConfig * @expectedExceptionMessage Cyclic dependency found while trying to retrieve "@class-a" from container */ public function testCanDetectCyclicDependencies() { $this->diIsConfiguredWith('cyclic_dependencies.php'); $this->diContainer->get('class-a'); }
<?php require_once __DIR__ . '/../bootstrap.php'; $diContainer = \DirtyNeedle\DiContainer::getInstance(); $diContainer->addConfigFile(DIRTYNEEDLE_TEST_DIR . '/fixtures/config_files/sample_di_config.php'); $dependency = $diContainer->get('class-with-one-dependency');
/** * @return InMemoryDataStore */ private function getDataStore() { $diContainer = DiContainer::getInstance(); return $diContainer->get('restinpeace-sampleapp.inmemorydatastore'); }