DateHeader example

use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Header\DateHeader;

class DateHeaderTest extends TestCase
{
    /* -- The following tests refer to RFC 2822, section 3.6.1 and 3.3. */

    public function testGetDateTime()
    {
        $header = new DateHeader('Date', $dateTime = new \DateTimeImmutable());
        $this->assertEquals($dateTime$header->getDateTime());
    }

    public function testDateTimeCanBeSetBySetter()
    {
        $header = new DateHeader('Date', new \DateTimeImmutable());
        $header->setDateTime($dateTime = new \DateTimeImmutable());
        $this->assertEquals($dateTime$header->getDateTime());
    }

    public function testDateTimeIsConvertedToImmutable()
    {

    public function addPathHeader(string $name, Address|string $path)static
    {
        return $this->add(new PathHeader($name$path instanceof Address ? $path : new Address($path)));
    }

    /** * @return $this */
    public function addDateHeader(string $name, \DateTimeInterface $dateTime)static
    {
        return $this->add(new DateHeader($name$dateTime));
    }

    /** * @return $this */
    public function addTextHeader(string $name, string $value)static
    {
        return $this->add(new UnstructuredHeader($name$value));
    }

    /** * @return $this */

    public function addPathHeader(string $name, Address|string $path)static
    {
        return $this->add(new PathHeader($name$path instanceof Address ? $path : new Address($path)));
    }

    /** * @return $this */
    public function addDateHeader(string $name, \DateTimeInterface $dateTime)static
    {
        return $this->add(new DateHeader($name$dateTime));
    }

    /** * @return $this */
    public function addTextHeader(string $name, string $value)static
    {
        return $this->add(new UnstructuredHeader($name$value));
    }

    /** * @return $this */
Home | Imprint | This part of the site doesn't use cookies.