/**
  * @return Cache
  */
 private function callFactory()
 {
     $callable = $this->factory;
     $doctrineCache = $callable($this->container->reveal());
     static::assertInstanceOf(Cache::class, $doctrineCache);
     return $doctrineCache;
 }
 public function testFactoryWithTemplate()
 {
     $factory = new HelloActionFactory();
     $this->container->get(TemplateRendererInterface::class)->willRetur($this->prophesize(TemplateRendererInterface::class));
     $helloPage = $factory($this->container->reveal());
     $this->assertTrue($helloPage instanceof Response);
 }
 public function testFormInstance()
 {
     $formName = 'foobar';
     $this->container->get($formName)->willReturn($this->prophesize(FormInterface::class));
     $factory = new ZendFormFactory();
     $formInstance = $factory($this->container->reveal(), $formName);
     static::assertInstanceOf(FormInterface::class, $formInstance);
 }
 public function testFactoryWithTemplate()
 {
     $factory = new HomePageFactory();
     $this->container->has(TemplateInterface::class)->willReturn(true);
     $this->container->get(TemplateInterface::class)->willReturn($this->prophesize(TemplateInterface::class));
     $this->assertTrue($factory instanceof HomePageFactory);
     $homePage = $factory($this->container->reveal());
     $this->assertTrue($homePage instanceof HomePageAction);
 }
 public function testFactory()
 {
     $factory = new RedirectHandlerActionFactory();
     $this->container->get('config')->willReturn(['expressive-redirect-handler' => ['allow_not_routed_url' => false, 'default_url' => '/']]);
     $router = $this->prophesize(RouterInterface::class);
     $this->container->get(RouterInterface::class)->willReturn($router);
     $this->assertTrue($factory instanceof RedirectHandlerActionFactory);
     $homePage = $factory($this->container->reveal());
     $this->assertTrue($homePage instanceof RedirectHandlerAction);
 }
 public function testWillInjectTemplateNamesFromConfigurationWhenPresent()
 {
     $config = ['zend-expressive' => ['error_handler' => ['template_404' => 'error::404', 'template_error' => 'error::500']]];
     $this->container->has(TemplateRendererInterface::class)->willReturn(false);
     $this->container->has('config')->willReturn(true);
     $this->container->get('config')->willReturn($config);
     $factory = $this->factory;
     $result = $factory($this->container->reveal());
     $this->assertInstanceOf(WhoopsErrorHandler::class, $result);
     $this->assertAttributeEquals('error::404', 'template404', $result);
     $this->assertAttributeEquals('error::500', 'templateError', $result);
 }
 /**
  * @param string $dsn
  * @param string $persistent_id
  * @param bool $rpc
  * @return ZeroMQMessageProducer
  */
 private function make($dsn = null, $persistent_id = null, $rpc = null)
 {
     $config = compact('dsn', 'persistent_id', 'rpc');
     $this->container->get('config')->willReturn(['prooph' => ['zeromq_producer' => $config]])->shouldBeCalled();
     $factory = new ZeroMQMessageProducerFactory();
     return $factory($this->container->reveal());
 }
 public function testInvalidResourceException()
 {
     $request = $this->request->withUri(new Uri('http://localhost/api/ping/666'))->withMethod('GET')->withAttribute('resource', 'SomeBogusResource')->withAttribute('resourceId', 1);
     $apiMiddleware = new ApiMiddleware($this->container->reveal());
     /** @var \Zend\Diactoros\Response\JsonResponse $response */
     $response = $apiMiddleware($request, new Response());
     $data = json_decode((string) $response->getBody(), true);
     $this->assertInstanceOf('Zend\\Diactoros\\Response\\JsonResponse', $response);
     $this->assertEquals(400, $response->getStatusCode());
     $this->assertArrayHasKey('errors', $data);
 }
 public function testInvoke()
 {
     $instance = $this->factory->__invoke($this->container->reveal(), '');
     $this->assertInstanceOf(TwigRenderer::class, $instance);
 }