/** * クライアントの準備 * @return void */ protected function boot() { $this->container->set('config', $this->config); $this->container->set('api', $this->container->get(QiitaAPIInterface::class)); Model::setFactory($this->container); Model::setApi($this->container->get('api')); }
protected function readyApiMock() { $this->apiMock = \Mockery::mock(QiitaAPIInterface::class); $this->container->set('api', $this->apiMock); $this->container->set(QiitaAPIInterface::class, $this->apiMock); Model::setApi($this->apiMock); }
/** * Configure the engine and start it. * * Compute and register some information such as computed global configuration, * input, output etc to the DI container for easier access later to * lower level components. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * * @return void */ public function configAndStart(InputInterface $input, OutputInterface $output) { $startUpMsg = "\n" . "Starting the test run. Version ( " . Application::APP_VERSION . " )\n" . "Type character h for help when prompted for an input value.\n"; $output->writeln($startUpMsg); $config = $this->configFactory->config($input, $output); $this->container->set('Box\\TestScribe\\Config\\GlobalComputedConfig', $config); App::Init($this->appInstance); $this->engine->start(); }
protected function createContainer() { $container = new Container(); $container->set('array_iterator', new \ArrayIterator(range(1, 5))); $container->set('error', function () { throw new \RuntimeException(); }); return new PHPDIContainerAdapter($container); }
/** * Приготовить ответ из вывода handler. * * @param null|string|Response $output * @return Response */ protected function makeResponse($output) { /** @var Response $response */ $response = $this->container->get(Response::class); if ($output instanceof Response) { $response = $output; } elseif (is_string($output)) { $response->setContent($output); } $this->container->set(Response::class, $response); return $response; }
protected function registerMocks() { $parser = new PhpDocReader(); $class = new ReflectionClass($this); $registeredNames = array(); //Find every member that begins with "mock" or "spy" foreach ($class->getProperties() as $property) { if (strpos($property->name, 'mock') === 0 || strpos($property->name, 'spy') === 0) { if ($property->name == "mockObjects") { //This is inherited from PHPUnit_Framework_TestCase and we can't mock it continue; } //Use the type as the DI name $name = $parser->getPropertyType($property); //TODO: Check for duplicates //$this->DIContainer->getDefinitionManager()->getDefinition() $property->setAccessible(true); $this->DIContainer->set($name, $property->getValue($this)); } } }
public function build($env = null) : Application { $this->env = $env; $router = new FastRouteRouter(); $finalHandler = new FinalHandler(); $emitter = new EmitterStack(); if ($this->useSAPIEmitter) { $emitter->push(new SapiEmitter()); } else { $emitter->push(new PHPUnitEmitter()); } foreach ($this->initScripts as $initScriptClassName) { $script = new $initScriptClassName(); $script($this); } $app = new Application($router, $this->container, $finalHandler, $emitter); foreach ($this->initAppScripts as $initAppScriptClassName) { $script = new $initAppScriptClassName(); $script($app); } $this->container->set(Application::class, $app); return $app; }
/** * {@inheritdoc} */ public function set($name, $value) { parent::set($name, $value); return $this; }
public function setDemoStatus(Config $config) { $this->container->set(DemoStatus::class, $config->getDemo()); }
/** * Configure the application dispatcher. */ private function configureDispatcher() { $dispatcher = new Dispatcher($this->container); $this->setDispatcher($dispatcher); $this->container->set('dispatcher', $dispatcher); }
/** * @param $name * @param $value */ public function set($name, $value) { $this->phpDiContainer->set($name, $value); }