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 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(); }
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()); }
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()); }
/** * @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; }
/** * @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()); }; }
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); } }
/** * @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); }; } }
public function thenAnInstanceOf_ShouldBeTheSingletonOf($userClass, $baseClass) { $this->instance = $this->myFactory->getInstance($baseClass); $this->spec->assertInstanceOf($userClass, $this->instance); }
/** * @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]); }
/** * @param Request $request * @return Target */ public function create(Request $request) { return $this->factory->getInstance($this->targetClass, array_merge(array('request' => $request), $this->arguments)); }
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)); }
/** * @return Renderer */ protected function createDefaultRenderer() { return $this->factory->getInstance(Renderer::RENDERER); }
public function __construct(Factory $factory) { $this->domin = $factory->getInstance(WebApplication::class); }
public static function quickResponse($respondingClass, Factory $factory = null) { $targetFactory = RespondingTarget::factory(self::$factory, self::$factory->getInstance($respondingClass)); self::quickRoute(new NoneRouter($targetFactory)); }
function after(Factory $factory) { assert($factory->getInstance(\DateTime::class) == new \DateTime('yesterday')); }
public function __construct(Factory $factory, callable $internalInjector = null) { $this->injector = $internalInjector ?: function ($class) use($factory) { return $factory->getInstance($class); }; }
/** * @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); }
public function whenIGet_FromTheFactoryAgain($className) { $this->instance2 = $this->factory->getInstance($className); }