Skip to content

Commit

Permalink
fix(datetime): checks for time equality
Browse files Browse the repository at this point in the history
  • Loading branch information
pitchart committed Feb 12, 2021
1 parent 0b02981 commit 915b63b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Checks/DateTimeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Pitchart\Phlunit\Checks\Mixin\WithMessage;
use Pitchart\Phlunit\Constraint\DateTime\IsSameDayAs;
use Pitchart\Phlunit\Constraint\DateTime\IsSameIgnoringMillis;
use Pitchart\Phlunit\Constraint\DateTime\IsSameTimeAs;

class DateTimeCheck implements FluentCheck
{
Expand Down Expand Up @@ -80,7 +81,7 @@ public function isSameDayAs(\DateTimeInterface $expected): self

public function isSameTimeAs(\DateTimeInterface $expected): self
{
Assert::assertThat($this->value, new IsSameDayAs($expected), $this->message);
Assert::assertThat($this->value, new IsSameTimeAs($expected), $this->message);
$this->resetMessage();
return $this;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/DateTimeCheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function test_checks_datetime_formats()
->isSameDayAs(new \DateTime())
->isSameIgnoringMillis(new \DateTime())
;
Check::that(\DateTime::createFromFormat('Y-m-d H:i:s','1983-04-28 00:30:45'))
->isSameTimeAs(\DateTime::createFromFormat('Y-m-d H:i:s','2021-04-28 00:30:45'));
}

public function test_checks_datetime_parts()
Expand Down

0 comments on commit 915b63b

Please sign in to comment.