public function __construct($storageDir, Factory $factory) { $this->factory = $factory; $this->authors = new PersistentAuthorRepository($storageDir); $this->posts = new PersistentPostRepository($storageDir); $this->postService = $factory->setSingleton(new Posts($this->authors, $this->posts)); $this->authorService = $factory->setSingleton(new Authors($this->authors)); }
protected function before() { $this->factory = new Factory(); $this->factory->setSingleton($this->action->registry); $this->access = $this->factory->setSingleton(new AccessControl()); $this->app = $this->factory->getInstance(WebApplication::class); $this->app->prepare(); }
public function givenTheBoxContainer_In_WithBody($boxName, $folder, $body) { $namespace = $this->spec->getName(false) . ($folder ? '\\' . str_replace('/', '\\', $folder) : ''); $className = ucfirst($boxName) . WebRouter::SUFFIX; $code = "namespace {$namespace}; class {$className} extends \\spec\\watoki\\boxes\\fixtures\\TestBox {\n function getMockDirectory() {\n return '{$folder}';\n }\n {$body}\n }"; eval($code); $fileName = ($folder ? $folder . '/' : '') . $className . '.php'; $this->store->create(new File($code), $fileName); $fullClassName = $namespace . '\\' . $className; $this->boxes[$boxName] = new $fullClassName($this->factory); $this->factory->setSingleton($this->boxes[$boxName], $fullClassName); }
function __construct(Factory $factory, $workingDirectory, array $config) { $factory->setSingleton($this); $this->workingDirectory = $workingDirectory; $this->config = $config; $this->factory = $factory; }
/** * @param Console $console * @param array $arguments Arguments as produced by the Parser * @throws \Exception If the class does not implement a "doExecute" method * @return void */ public function execute(Console $console, array $arguments) { $injector = new Injector($this->factory); $methodName = $this->getExecutionMethodName(); try { $method = new \ReflectionMethod($this, $methodName); } catch (\ReflectionException $e) { throw new \Exception("Command [" . get_class($this) . "] must implement the method [{$methodName}]."); } $this->factory->setSingleton($console, Console::$CLASS); $resolved = $this->resolveFlags($method, $arguments); $filtered = $this->filter($method, $resolved); $arguments = $injector->injectMethodArguments($method, $filtered, $this->parameterInjectionFilter); $this->checkArguments($method, $resolved); $method->invokeArgs($this, $arguments); }
private function whenIExecuteTheCommand() { $this->listener = new ArrayListener(); $factory = new Factory(); $factory->setSingleton($this->listener); $command = new ScrutCommand(new ConfigurationReader($this->files->fullPath(), $factory)); $command->execute(['-c' . json_encode(['listen' => [ArrayListener::class]])]); }
/** * @param Factory $factory <- */ public function __construct(Factory $factory) { $this->factory = $factory; $factory->setSingleton($this, get_class($this)); $this->register((new GenericActionRepresenter(RootAction::class, $factory))->setHandler(function () { return new RootEntity(); })->setName('Home')); $this->register((new GenericEntityRepresenter(RootEntity::class))->setName('Qrator')); $printDateTime = function (\DateTimeInterface $d) { return $d->format('Y-m-d H:i:s'); }; $this->register((new GenericEntityRepresenter(\DateTime::class))->setStringifier($printDateTime)); $this->register((new GenericEntityRepresenter(\DateTimeImmutable::class))->setStringifier($printDateTime)); }
function before(Factory $factory) { $factory->setSingleton(new \DateTime('yesterday')); }
function __construct(Factory $factory, TestRunConfiguration $config, TestName $parent) { $factory->setSingleton($this, get_class($config)); $this->config = $config; $this->parent = $parent; }
/** * @param Factory $factory <- * @param ActionRegistry $actions <- * @param FieldRegistry $fields <- * @param RendererRegistry $renderers <- * @param LinkRegistry $links <- * @param IdentifiersProvider $identifiers <- * @param TypeFactory $types <- * @param MobileDetector $detect <- * @param WebCommentParser $parser <- * @param AccessControl $access <- */ public function __construct(Factory $factory, ActionRegistry $actions, FieldRegistry $fields, RendererRegistry $renderers, LinkRegistry $links, IdentifiersProvider $identifiers, TypeFactory $types, MobileDetector $detect, WebCommentParser $parser, AccessControl $access) { $factory->setSingleton($this); $this->factory = $factory; $this->actions = $actions; $this->renderers = $renderers; $this->links = $links; $this->types = $types; $this->fields = $fields; $this->identifiers = $identifiers; $this->detector = $detect; $this->parser = $parser; $this->access = $access; $this->menu = new Menu($actions); $this->groups = new ActionGroups($actions); }
private function executeCommand(Assert $assert, $arguments = [], $shouldReturn = 0) { $factory = new Factory(); $factory->setSingleton(new RunTestByName_Configuration($this->files->fullPath(), $this->test, $this->listener), TestRunConfiguration::class); $command = new ScrutCommand(new ConfigurationReader($this->files->fullPath(), $factory)); $returned = $command->execute($arguments); $assert($returned, $shouldReturn); }
/** * @param Assert $assert <- * @param Factory $factory <- */ function __construct(Assert $assert, Factory $factory) { parent::__construct($assert); $factory->setSingleton($this); }
function withRegisteredListener() { $this->factory->setSingleton($this->listener, TimeConsoleListener::class); $this->whenIExecuteTheCommandWithTheArguments(['-lTime']); $this->thenTheListenerShouldHaveReceivedSomething(); }
public function whenISetAnInstanceOf_AsASingletonFor($singleton, $class) { $this->factory->setSingleton(new $singleton(), $class); }