コード例 #1
0
ファイル: Admin.php プロジェクト: rtens/domin-sample
 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));
 }
コード例 #2
0
ファイル: ListActionsSpec.php プロジェクト: rtens/domin
 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();
 }
コード例 #3
0
ファイル: BoxFixture.php プロジェクト: watoki/boxes
 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);
 }
コード例 #4
0
ファイル: TestRunConfiguration.php プロジェクト: rtens/scrut
 function __construct(Factory $factory, $workingDirectory, array $config)
 {
     $factory->setSingleton($this);
     $this->workingDirectory = $workingDirectory;
     $this->config = $config;
     $this->factory = $factory;
 }
コード例 #5
0
ファイル: DefaultCommand.php プロジェクト: watoki/cli
 /**
  * @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);
 }
コード例 #6
0
 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]])]);
 }
コード例 #7
0
ファイル: RepresenterRegistry.php プロジェクト: watoki/qrator
 /**
  * @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));
 }
コード例 #8
0
ファイル: RunPlainTestSuites.php プロジェクト: rtens/scrut
 function before(Factory $factory)
 {
     $factory->setSingleton(new \DateTime('yesterday'));
 }
コード例 #9
0
ファイル: LinkedConfiguration.php プロジェクト: rtens/scrut
 function __construct(Factory $factory, TestRunConfiguration $config, TestName $parent)
 {
     $factory->setSingleton($this, get_class($config));
     $this->config = $config;
     $this->parent = $parent;
 }
コード例 #10
0
ファイル: WebApplication.php プロジェクト: rtens/domin
 /**
  * @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);
 }
コード例 #11
0
ファイル: RunTestByName.php プロジェクト: rtens/scrut
 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);
 }
コード例 #12
0
ファイル: FilesFixture.php プロジェクト: rtens/scrut
 /**
  * @param Assert $assert <-
  * @param Factory $factory <-
  */
 function __construct(Assert $assert, Factory $factory)
 {
     parent::__construct($assert);
     $factory->setSingleton($this);
 }
コード例 #13
0
ファイル: SetListeners.php プロジェクト: rtens/scrut
 function withRegisteredListener()
 {
     $this->factory->setSingleton($this->listener, TimeConsoleListener::class);
     $this->whenIExecuteTheCommandWithTheArguments(['-lTime']);
     $this->thenTheListenerShouldHaveReceivedSomething();
 }
コード例 #14
0
ファイル: FactoryFixture.php プロジェクト: watoki/factory
 public function whenISetAnInstanceOf_AsASingletonFor($singleton, $class)
 {
     $this->factory->setSingleton(new $singleton(), $class);
 }