Skip to content

Commit

Permalink
Merge pull request #226 from fightbulc/fix/return-type-will-change
Browse files Browse the repository at this point in the history
Fix: Add tests to assert compatibility with PHP 8.1
  • Loading branch information
localheinz authored Feb 27, 2024
2 parents 4eb24b7 + 0d0af2e commit 19da913
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/Unit/MomentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,56 @@

class MomentTest extends TestCase
{
public function testCreateFromFormatReturnsMomentWhenFormatAndTimeArePresent()
{
$format = 'Y-m-d H:i:s';
$time = '2018-01-01 12:00:00';

$moment = Moment::createFromFormat(
$format,
$time
);

self::assertInstanceOf(Moment::class, $moment);

self::assertSame($time, $moment->format($format));
}

public function testCanSetDate()
{
$moment = new Moment('2014-01-01T10:10:00+0100');

$moment->setDate(
2015,
12,
31
);

self::assertSame('2015-12-31T10:10:00+0100', $moment->format());
}

public function testCanSetTimeWhenHourMinuteAndSecondArePresent()
{
$moment = new Moment('2014-01-01T10:10:00+0100');

$moment->setTime(
12,
30,
12
);

self::assertSame('2014-01-01T12:30:12+0100', $moment->format());
}

public function testCanSetTimezone()
{
$moment = new Moment('2014-01-01T10:10:00+0100');

$moment->setTimezone('UTC');

self::assertSame('2014-01-01T09:10:00+0000', $moment->format());
}

public function testMoment()
{
$data = '1923-12-31 12:30:00';
Expand Down

0 comments on commit 19da913

Please sign in to comment.