ZendTest\Stratigility\DispatchTest::testWillCatchPhp7Throwable PHP Метод

testWillCatchPhp7Throwable() публичный Метод

    public function testWillCatchPhp7Throwable()
    {
        $callableWithHint = function (stdClass $parameter) {
            // will not be executed
        };
        $middleware = function ($req, $res, $next) use($callableWithHint) {
            $callableWithHint('not an stdClass');
        };
        // Using PHPUnit mock here to allow asserting that the method is called.
        // Prophecy doesn't allow defining arbitrary methods on mocks it generates.
        $errorHandler = $this->getMockBuilder('stdClass')->setMethods(['__invoke'])->getMock();
        $errorHandler->expects(self::once())->method('__invoke')->with($this->request->reveal(), $this->response->reveal(), self::callback(function (TypeError $throwable) {
            self::assertStringStartsWith('Argument 1 passed to ZendTest\\Stratigility\\DispatchTest::ZendTest\\Stratigility\\{closure}()' . ' must be an instance of stdClass, string given', $throwable->getMessage());
            return true;
        }));
        $dispatch = new Dispatch();
        $dispatch(new Route('/foo', $middleware), null, $this->request->reveal(), $this->response->reveal(), $errorHandler);
    }
DispatchTest