Skip to content

assertSame() with DateTime and null will always evaluate to false. #2105

@davidkmenta

Description

@davidkmenta

Support question

I'm little bit confused about this error I'm getting

Call to method PHPUnit\Framework\Assert::assertSame() with DateTime and null will always evaluate to false.

Unit test:

$this->topic->setFcmInsertedAt($fcmInsertedAt = new \DateTime());

$this->assertSame($fcmInsertedAt, $this->topic->getFcmInsertedAt());

Entity:

public function setFcmInsertedAt(?\DateTimeInterface $fcmInsertedAt): self
{
    $this->fcmInsertedAt = $fcmInsertedAt;

    return $this;
}

public function getFcmInsertedAt(): ?\DateTimeInterface
{
    return $this->fcmInsertedAt;
}

... and I'm not sure how to correctly fix this 😕

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions