proxy = new Proxy(new DummyAdapter()); } /** * @test * @expectedException UnexpectedValueException */ public function to_throws_exception_if_no_request_is_given() { $this->proxy->to('http://www.example.com'); } /** * @test */ public function to_returns_psr_response() { $response = $this->proxy->forward(ServerRequestFactory::fromGlobals())->to('http://www.example.com'); $this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $response); } /** * @test */ public function to_applies_filters() { $applied = false; $this->proxy->forward(ServerRequestFactory::fromGlobals())->filter(function ($request, $response) use (&$applied ) { $applied = true; })->to('http://www.example.com'); $this->assertTrue($applied); } /** * @test */ public function to_sends_request() { $request = new Request('http://localhost/path?query=yes', 'GET'); $url = 'https://www.example.com'; $adapter = $this->getMockBuilder(DummyAdapter::class) ->getMock(); $verifyParam = $this->callback(function (RequestInterface $request) use ($url) { return $request->getUri() == 'https://www.example.com/path?query=yes'; }); $adapter->expects($this->once()) ->method('send') ->with($verifyParam) ->willReturn(new Response); $proxy = new Proxy($adapter); $proxy->forward($request)->to($url); } /** * @test */ public function to_sends_request_with_port() { $request = new Request('http://localhost/path?query=yes', 'GET'); $url = 'https://www.example.com:3000'; $adapter = $this->getMockBuilder(DummyAdapter::class) ->getMock(); $verifyParam = $this->callback(function (RequestInterface $request) use ($url) { return $request->getUri() == 'https://www.example.com:3000/path?query=yes'; }); $adapter->expects($this->once()) ->method('send') ->with($verifyParam) ->willReturn(new Response); $proxy = new Proxy($adapter); $proxy->forward($request)->to($url); } /** * @test */ public function to_sends_request_with_subdirectory() { $request = new Request('http://localhost/path?query=yes', 'GET'); $url = 'https://www.example.com/proxy/'; $adapter = $this->getMockBuilder(DummyAdapter::class) ->getMock(); $verifyParam = $this->callback(function (RequestInterface $request) use ($url) { return $request->getUri() == 'https://www.example.com/proxy/path?query=yes'; }); $adapter->expects($this->once()) ->method('send') ->with($verifyParam) ->willReturn(new Response); $proxy = new Proxy($adapter); $proxy->forward($request)->to($url); } } __halt_compiler();----SIGNATURE:----KnKmCQlgdKIkpOA9CvHf8EprnSS7jJfiYCAtWSOVQnr+TWsYlmipbL20tavE1zq6kMYWrxu6n3Gt7ZFDt7mg19ZvpYsJYEmvrQjTh/qGjiMIg+pse8VTKcZsCI7JI1VnK3t9nUAEepcAEqQfZBChTrRydCoLBFsxLWOzvnjTxNJon4EN7v5wUk2NCSv5vsvjqsEs2w0jpmQjP0hKlboWUje6QwExbP96ESPkh7R6bu5mA6tFrSwkaXBa92HuwSRVVtyIDkPHvCpvYfMptV8XtR0ligndeqfD64C4mTqQPR47WsckfP0L+6lBsJ1Vm8ibb1/PeI4Kjbee4yqzXAj/Zey4yRfoGlBNzBObFqb3z7Gnd67qHd9dXIrTrjebQdUHwHhM5eGHw8ek+mvP6eJMVgs2cBpdgd8Yj3DpA1OyOa6IhKBWruouVvxWXLf+72IeTokueivo66mfDDD2NJRVubY6L92yy0+JPYBK51GlkKl/XOGZIb4qbzxCUCUDkrvzTMRQ2tN+gwGeiuj84R3bfz6o/vR7tb5Ww4DIfWaIhoP5WMTNVcgf/AeRkYP3IISUPuHvPOTTsQWECkC13bHtRtDgZhVlVCLDDCf+1PoD1SX5QY3ruKSC/kP2ZK0/0YB1s30JU8HdZB3mS2sOpYtFhUBm3oW4kp9X00dtpa5zSKE=----ATTACHMENT:----NjMyODQxMjI3NDMwMjQ4MiAyMDY2ODU4NzEzNTc5MTkgOTAxNjI2NTk2MjYxOTE2Mg==