コード例 #1
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();
 }
コード例 #2
0
ファイル: WebFixture.php プロジェクト: jonfm/domin
 public function whenIGet_From($path, $resourceClass)
 {
     $request = $this->request->withTarget(Path::fromString($path))->withMethod('get');
     $stub = new TestDelivererStub($request);
     $router = new NoneRouter(RespondingTarget::factory($this->factory, $this->factory->getInstance($resourceClass)));
     $delivery = new WebDelivery($router, $stub, $stub);
     $stub->onDeliver(function (WebResponse $response) {
         if ($response instanceof ErrorResponse) {
             throw $response->getException();
         }
         $this->model = $response->getBody();
     });
     $delivery->run();
 }
コード例 #3
0
 protected function before()
 {
     $this->cookies = Mockster::of(CookieStore::class);
     $factory = new Factory();
     $this->app = $factory->getInstance(WebApplication::class);
     $this->resource = new ExecuteResource(new Factory(), $this->app, Mockster::mock($this->cookies));
     $this->app->renderers->add(new PrimitiveRenderer());
     $this->app->fields->add(new StringField());
 }
コード例 #4
0
 protected function before()
 {
     $factory = new Factory();
     $this->app = $factory->getInstance(WebApplication::class);
     $this->app->prepare();
     $this->app->fields->add(new ActionField($this->app->fields, $this->app->actions));
     $this->app->renderers->add(new PrimitiveRenderer());
     $this->app->fields->add(new StringField());
 }
コード例 #5
0
ファイル: Mockster.php プロジェクト: rtens/mockster
 /**
  * @param array $constructorArguments
  * @return object The Unit Under Test - an instance of the class, methods are not stubbed and the parent
  * constructor is called, mocks of dependencies are injected
  */
 public function __uut($constructorArguments = [])
 {
     $this->stubs->stubbedByDefault(false);
     $instance = $this->prepMock($this->factory->getInstance($this->class, $constructorArguments));
     $this->uuts[] = $instance;
     foreach ($this->propertyMocksters as $property => $mockster) {
         $this->properties[$property]->set($instance, $mockster->__mock());
     }
     return $instance;
 }
コード例 #6
0
ファイル: ObjectTarget.php プロジェクト: watoki/deli
 /**
  * @param Request $request
  * @param object $object
  * @param Factory $factory <-
  */
 function __construct(Request $request, $object, Factory $factory)
 {
     parent::__construct($request);
     $this->object = $object;
     $this->factory = $factory;
     $this->filters = $factory->getInstance(FilterRegistry::class);
     $this->parameterInjectionFilter = function (\ReflectionParameter $parameter) {
         $pattern = '/@param.+\\$' . $parameter->getName() . '.+' . DefaultProvider::INJECTION_TOKEN . '/';
         return preg_match($pattern, $parameter->getDeclaringFunction()->getDocComment());
     };
 }
コード例 #7
0
ファイル: StaticRouter.php プロジェクト: watoki/deli
 private function createTargetFromClass($fullClassName, Request $request, Path $context)
 {
     $object = $this->factory->getInstance($fullClassName);
     $nextRequest = $request->withContext($request->getContext()->appendedAll($context->getElements()));
     $nextRequest = $nextRequest->withTarget(new Path(array_slice($request->getTarget()->getElements(), count($context->getElements()))));
     if ($object instanceof Responding) {
         return new RespondingTarget($nextRequest, $object);
     } else {
         return new ObjectTarget($nextRequest, $object, $this->factory);
     }
 }
コード例 #8
0
 /**
  * @param callable|object|string $handler
  * @return callable
  */
 protected function makeCallable($handler)
 {
     if (is_callable($handler)) {
         return $handler;
     } else {
         $classReflection = new \ReflectionClass($this->getClass());
         $methodName = lcfirst($classReflection->getShortName());
         return function ($action) use($handler, $methodName) {
             $handler = is_object($handler) ? $handler : $this->factory->getInstance($handler);
             if (!method_exists($handler, $methodName) && !method_exists($handler, '__call')) {
                 $class = get_class($handler);
                 throw new \InvalidArgumentException("Method [{$class}::{$methodName}] does not exist.");
             }
             return call_user_func(array($handler, $methodName), $action);
         };
     }
 }
コード例 #9
0
ファイル: LoaderFixture.php プロジェクト: watoki/cfg
 public function thenAnInstanceOf_ShouldBeTheSingletonOf($userClass, $baseClass)
 {
     $this->instance = $this->myFactory->getInstance($baseClass);
     $this->spec->assertInstanceOf($userClass, $this->instance);
 }
コード例 #10
0
ファイル: ConfigurationReader.php プロジェクト: rtens/scrut
 /**
  * @param null|string $file
  * @param array $mergeWith
  * @return TestRunConfiguration
  */
 public function read($file = null, array $mergeWith = [])
 {
     $config = array_replace_recursive(self::$defaultConfiguration, $this->readFromFile($file), $mergeWith);
     return $this->factory->getInstance(TestRunConfiguration::class, [$this->factory, $this->cwd, $config]);
 }
コード例 #11
0
ファイル: TargetFactory.php プロジェクト: watoki/deli
 /**
  * @param Request $request
  * @return Target
  */
 public function create(Request $request)
 {
     return $this->factory->getInstance($this->targetClass, array_merge(array('request' => $request), $this->arguments));
 }
コード例 #12
0
ファイル: CliApplication.php プロジェクト: rtens/domin
 public static function run(Factory $factory, Console $console = null)
 {
     global $argv;
     /** @var self $app */
     $app = $factory->getInstance(self::class);
     return $app->doRun($console ?: new Console($argv));
 }
コード例 #13
0
ファイル: Resource.php プロジェクト: watoki/curir
 /**
  * @return Renderer
  */
 protected function createDefaultRenderer()
 {
     return $this->factory->getInstance(Renderer::RENDERER);
 }
コード例 #14
0
 public function __construct(Factory $factory)
 {
     $this->domin = $factory->getInstance(WebApplication::class);
 }
コード例 #15
0
ファイル: IntroductionTest.php プロジェクト: watoki/curir
 public static function quickResponse($respondingClass, Factory $factory = null)
 {
     $targetFactory = RespondingTarget::factory(self::$factory, self::$factory->getInstance($respondingClass));
     self::quickRoute(new NoneRouter($targetFactory));
 }
コード例 #16
0
ファイル: RunPlainTestSuites.php プロジェクト: rtens/scrut
 function after(Factory $factory)
 {
     assert($factory->getInstance(\DateTime::class) == new \DateTime('yesterday'));
 }
コード例 #17
0
ファイル: Injector.php プロジェクト: watoki/factory
 public function __construct(Factory $factory, callable $internalInjector = null)
 {
     $this->injector = $internalInjector ?: function ($class) use($factory) {
         return $factory->getInstance($class);
     };
 }
コード例 #18
0
ファイル: WebRouter.php プロジェクト: watoki/curir
 /**
  * @param Factory $factory <-
  * @param string $directory
  * @param string $namespace
  * @param string $suffix
  */
 function __construct(Factory $factory, $directory, $namespace, $suffix = self::SUFFIX)
 {
     $store = $factory->getInstance(FlatFileStore::class, array('basePath' => $directory));
     parent::__construct($factory, $store, $namespace, $suffix);
 }
コード例 #19
0
ファイル: FactoryFixture.php プロジェクト: watoki/factory
 public function whenIGet_FromTheFactoryAgain($className)
 {
     $this->instance2 = $this->factory->getInstance($className);
 }