public function testCanRequestKeyInSlowStorage()
 {
     $uri = $this->createMock('Psr\\Http\\Message\\UriInterface');
     $uri->method('getPath')->willReturn('/foo/baz');
     $uri->method('getQuery')->willReturn('');
     $request = $this->createMock('Psr\\Http\\Message\\RequestInterface');
     $request->method('getMethod')->willReturn('GET');
     $request->method('getUri')->willReturn($uri);
     $this->assertEquals('Hello World!', $this->chain->handle($request));
 }
Exemplo n.º 2
0
 /**
  * This approach by using a template method pattern ensures you that
  * each subclass will not forget to call the successor
  *
  * @param RequestInterface $request
  *
  * @return string|null
  */
 public final function handle(RequestInterface $request)
 {
     $processed = $this->processing($request);
     if ($processed === null) {
         // the request has not been processed by this handler => see the next
         if ($this->successor !== null) {
             $processed = $this->successor->handle($request);
         }
     }
     return $processed;
 }
 /**
  * @param array $data
  * @param Handler|null $successor
  */
 public function __construct(array $data, Handler $successor = null)
 {
     parent::__construct($successor);
     $this->data = $data;
 }