Neos\Flow\Tests\Unit\Http\HeadersTest::setGetAndGetAllConvertDatesFromDateObjectsToStringAndViceVersa PHP Method

setGetAndGetAllConvertDatesFromDateObjectsToStringAndViceVersa() public method

This checks if set() and get() convert DateTime to an RFC 2822 compliant date / time string and vice versa. Note that the date / time passed to set() is normalized to GMT internally, so that get() will return the same point in time, but not in the same timezone, if it was not GMT previously.
    public function setGetAndGetAllConvertDatesFromDateObjectsToStringAndViceVersa()
    {
        $now = \DateTime::createFromFormat(DATE_RFC2822, 'Tue, 22 May 2012 12:00:00 +0200');
        $nowInGmt = clone $now;
        $nowInGmt->setTimezone(new \DateTimeZone('GMT'));
        $headers = new Headers();
        $headers->set('Last-Modified', $now);
        $this->assertEquals($nowInGmt->format(DATE_RFC2822), $headers->get('Last-Modified')->format(DATE_RFC2822));
        $headers->set('X-Test-Run-At', $now);
        $this->assertEquals($nowInGmt->format(DATE_RFC2822), $headers->get('X-Test-Run-At')->format(DATE_RFC2822));
    }