InterNations\Component\HttpMock\Tests\PHPUnit\HttpMockMultiPHPUnitIntegrationTest::testLimitDurationOfAResponse PHP Method

testLimitDurationOfAResponse() public method

    public function testLimitDurationOfAResponse()
    {
        $this->http['firstNamedServer']->mock->once()->when()->methodIs('POST')->then()->body('POST METHOD')->end();
        $this->http['firstNamedServer']->setUp();
        $firstResponse = $this->http['firstNamedServer']->client->post('/')->send();
        $this->assertSame(200, $firstResponse->getStatusCode());
        $secondResponse = $this->http['firstNamedServer']->client->post('/')->send();
        $this->assertSame(410, $secondResponse->getStatusCode());
        $this->assertSame('Expectation no longer applicable', $secondResponse->getBody(true));
        $this->http['firstNamedServer']->mock->exactly(2)->when()->methodIs('POST')->then()->body('POST METHOD')->end();
        $this->http['firstNamedServer']->setUp();
        $firstResponse = $this->http['firstNamedServer']->client->post('/')->send();
        $this->assertSame(200, $firstResponse->getStatusCode());
        $secondResponse = $this->http['firstNamedServer']->client->post('/')->send();
        $this->assertSame(200, $secondResponse->getStatusCode());
        $thirdResponse = $this->http['firstNamedServer']->client->post('/')->send();
        $this->assertSame(410, $thirdResponse->getStatusCode());
        $this->assertSame('Expectation no longer applicable', $thirdResponse->getBody(true));
        $this->http['firstNamedServer']->mock->any()->when()->methodIs('POST')->then()->body('POST METHOD')->end();
        $this->http['firstNamedServer']->setUp();
        $firstResponse = $this->http['firstNamedServer']->client->post('/')->send();
        $this->assertSame(200, $firstResponse->getStatusCode());
        $secondResponse = $this->http['firstNamedServer']->client->post('/')->send();
        $this->assertSame(200, $secondResponse->getStatusCode());
        $thirdResponse = $this->http['firstNamedServer']->client->post('/')->send();
        $this->assertSame(200, $thirdResponse->getStatusCode());
    }