assertResponseNotHasHeader example

public function testAssertResponseHasHeader()
    {
        $this->getResponseTester(new Response())->assertResponseHasHeader('Date');
        $this->expectException(AssertionFailedError::class);
        $this->expectExceptionMessage('Failed asserting that the Response has header "X-Date".');
        $this->getResponseTester(new Response())->assertResponseHasHeader('X-Date');
    }

    public function testAssertResponseNotHasHeader()
    {
        $this->getResponseTester(new Response())->assertResponseNotHasHeader('X-Date');
        $this->expectException(AssertionFailedError::class);
        $this->expectExceptionMessage('Failed asserting that the Response does not have header "Date".');
        $this->getResponseTester(new Response())->assertResponseNotHasHeader('Date');
    }

    public function testAssertResponseHeaderSame()
    {
        $this->getResponseTester(new Response())->assertResponseHeaderSame('Cache-Control', 'no-cache, private');
        $this->expectException(AssertionFailedError::class);
        $this->expectExceptionMessage('Failed asserting that the Response has header "Cache-Control" with value "public".');
        $this->getResponseTester(new Response())->assertResponseHeaderSame('Cache-Control', 'public');
    }
Home | Imprint | This part of the site doesn't use cookies.