Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call PHPUnit methods through self:: instead of $this-> #82

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ abstract class AbstractTestCase extends TestCase
*/
protected function assertIs(string $className, string $expectedString, object $object): void
{
$this->assertInstanceOf($className, $object);
$this->assertSame($expectedString, (string) $object);
self::assertInstanceOf($className, $object);
self::assertSame($expectedString, (string) $object);
}

/**
Expand Down Expand Up @@ -115,7 +115,7 @@ protected function assertLocalDateTimeIs(int $y, int $m, int $d, int $h, int $i,
*/
protected function assertLocalDateTimeEquals(LocalDateTime $expected, LocalDateTime $actual): void
{
$this->assertTrue($actual->isEqualTo($expected), "$actual != $expected");
self::assertTrue($actual->isEqualTo($expected), "$actual != $expected");
}

protected function assertYearIs(int $yearValue, Year $year): void
Expand Down Expand Up @@ -225,8 +225,8 @@ protected function assertPeriodIs(int $years, int $months, int $days, Period $pe
*/
protected function assertLocalDateRangeIs(int $y1, int $m1, int $d1, int $y2, int $m2, int $d2, LocalDateRange $range): void
{
$this->assertLocalDateIs($y1, $m1, $d1, $range->getStart());
$this->assertLocalDateIs($y2, $m2, $d2, $range->getEnd());
self::assertLocalDateIs($y1, $m1, $d1, $range->getStart());
self::assertLocalDateIs($y2, $m2, $d2, $range->getEnd());
}

/**
Expand All @@ -238,8 +238,8 @@ protected function assertLocalDateRangeIs(int $y1, int $m1, int $d1, int $y2, in
*/
protected function assertYearMonthRangeIs(int $y1, int $m1, int $y2, int $m2, YearMonthRange $range): void
{
$this->assertYearMonthIs($y1, $m1, $range->getStart());
$this->assertYearMonthIs($y2, $m2, $range->getEnd());
self::assertYearMonthIs($y1, $m1, $range->getStart());
self::assertYearMonthIs($y2, $m2, $range->getEnd());
}

/**
Expand All @@ -248,7 +248,7 @@ protected function assertYearMonthRangeIs(int $y1, int $m1, int $y2, int $m2, Ye
*/
protected function assertTimeZoneEquals(TimeZone $expected, TimeZone $actual): void
{
$this->assertTrue($actual->isEqualTo($expected), "$actual != $expected");
self::assertTrue($actual->isEqualTo($expected), "$actual != $expected");
}

/**
Expand All @@ -271,7 +271,7 @@ private function compare(array $expected, array $actual): void
$message = $this->export($actual) . ' !== ' . $this->export($expected);

foreach ($expected as $key => $value) {
$this->assertSame($value, $actual[$key], $message);
self::assertSame($value, $actual[$key], $message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Clock/FixedClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ class FixedClockTest extends AbstractTestCase
public function testFixedClock(): void
{
$clock = new FixedClock(Instant::of(123456789, 987654321));
$this->assertInstantIs(123456789, 987654321, $clock->getTime());
self::assertInstantIs(123456789, 987654321, $clock->getTime());
}
}
2 changes: 1 addition & 1 deletion tests/Clock/OffsetClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testOffsetClock(int $second, int $nano, string $duration, int $e
$baseClock = new FixedClock(Instant::of($second, $nano));
$clock = new OffsetClock($baseClock, Duration::parse($duration));

$this->assertInstantIs($expectedSecond, $expectedNano, $clock->getTime());
self::assertInstantIs($expectedSecond, $expectedNano, $clock->getTime());
}

public function providerOffsetClock(): array
Expand Down
4 changes: 2 additions & 2 deletions tests/Clock/ScaleClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function testScaleClock(int $second, int $nano, string $duration, int $sc

$actualTime = $scaleClock->getTime();

$this->assertInstanceOf(Instant::class, $actualTime);
$this->assertSame($expectedInstant, $actualTime->toDecimal());
self::assertInstanceOf(Instant::class, $actualTime);
self::assertSame($expectedInstant, $actualTime->toDecimal());
}

public function providerScaleClock(): array
Expand Down
2 changes: 1 addition & 1 deletion tests/Clock/SystemClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testSystemClock(): void
{
$clock = new SystemClock();

$this->assertInstantIs(14079491701, 555276000, $clock->getTime());
self::assertInstantIs(14079491701, 555276000, $clock->getTime());
}
}
}
40 changes: 20 additions & 20 deletions tests/DayOfWeekTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DayOfWeekTest extends AbstractTestCase
*/
public function testConstants(int $expectedValue, int $dayOfWeekConstant): void
{
$this->assertSame($expectedValue, $dayOfWeekConstant);
self::assertSame($expectedValue, $dayOfWeekConstant);
}

public function providerConstants(): array
Expand All @@ -45,7 +45,7 @@ public function providerConstants(): array

public function testOf(): void
{
$this->assertDayOfWeekIs(5, DayOfWeek::of(5));
self::assertDayOfWeekIs(5, DayOfWeek::of(5));
}

/**
Expand Down Expand Up @@ -76,7 +76,7 @@ public function providerOfInvalidDayOfWeekThrowsException(): array
public function testNow(int $epochSecond, string $timeZone, int $expectedDayOfWeek): void
{
$clock = new FixedClock(Instant::of($epochSecond));
$this->assertDayOfWeekIs($expectedDayOfWeek, DayOfWeek::now(TimeZone::parse($timeZone), $clock));
self::assertDayOfWeekIs($expectedDayOfWeek, DayOfWeek::now(TimeZone::parse($timeZone), $clock));
}

public function providerNow(): array
Expand All @@ -97,52 +97,52 @@ public function testAll(): void
$dayOfWeek = DayOfWeek::of($day);

foreach (DayOfWeek::all($dayOfWeek) as $dow) {
$this->assertTrue($dow->isEqualTo($dayOfWeek));
self::assertTrue($dow->isEqualTo($dayOfWeek));
$dayOfWeek = $dayOfWeek->plus(1);
}
}
}

public function testMonday(): void
{
$this->assertDayOfWeekIs(DayOfWeek::MONDAY, DayOfWeek::monday());
self::assertDayOfWeekIs(DayOfWeek::MONDAY, DayOfWeek::monday());
}

public function testTuesday(): void
{
$this->assertDayOfWeekIs(DayOfWeek::TUESDAY, DayOfWeek::tuesday());
self::assertDayOfWeekIs(DayOfWeek::TUESDAY, DayOfWeek::tuesday());
}

public function testWednesday(): void
{
$this->assertDayOfWeekIs(DayOfWeek::WEDNESDAY, DayOfWeek::wednesday());
self::assertDayOfWeekIs(DayOfWeek::WEDNESDAY, DayOfWeek::wednesday());
}

public function testThursday(): void
{
$this->assertDayOfWeekIs(DayOfWeek::THURSDAY, DayOfWeek::thursday());
self::assertDayOfWeekIs(DayOfWeek::THURSDAY, DayOfWeek::thursday());
}

public function testFriday(): void
{
$this->assertDayOfWeekIs(DayOfWeek::FRIDAY, DayOfWeek::friday());
self::assertDayOfWeekIs(DayOfWeek::FRIDAY, DayOfWeek::friday());
}

public function testSaturday(): void
{
$this->assertDayOfWeekIs(DayOfWeek::SATURDAY, DayOfWeek::saturday());
self::assertDayOfWeekIs(DayOfWeek::SATURDAY, DayOfWeek::saturday());
}

public function testSunday(): void
{
$this->assertDayOfWeekIs(DayOfWeek::SUNDAY, DayOfWeek::sunday());
self::assertDayOfWeekIs(DayOfWeek::SUNDAY, DayOfWeek::sunday());
}

public function testIs(): void
{
for ($i = DayOfWeek::MONDAY; $i <= DayOfWeek::SUNDAY; $i++) {
for ($j = DayOfWeek::MONDAY; $j <= DayOfWeek::SUNDAY; $j++) {
$this->assertSame($i === $j, DayOfWeek::of($i)->is($j));
self::assertSame($i === $j, DayOfWeek::of($i)->is($j));
}
}
}
Expand All @@ -151,7 +151,7 @@ public function testIsEqualTo(): void
{
for ($i = DayOfWeek::MONDAY; $i <= DayOfWeek::SUNDAY; $i++) {
for ($j = DayOfWeek::MONDAY; $j <= DayOfWeek::SUNDAY; $j++) {
$this->assertSame($i === $j, DayOfWeek::of($i)->isEqualTo(DayOfWeek::of($j)));
self::assertSame($i === $j, DayOfWeek::of($i)->isEqualTo(DayOfWeek::of($j)));
}
}
}
Expand All @@ -161,7 +161,7 @@ public function testIsEqualTo(): void
*/
public function testIsWeekday(DayOfWeek $dayOfWeek, bool $isWeekday): void
{
$this->assertSame($isWeekday, $dayOfWeek->isWeekday());
self::assertSame($isWeekday, $dayOfWeek->isWeekday());
}

public function providerIsWeekday(): array
Expand All @@ -182,7 +182,7 @@ public function providerIsWeekday(): array
*/
public function testIsWeekend(DayOfWeek $dayOfWeek, bool $isWeekend): void
{
$this->assertSame($isWeekend, $dayOfWeek->isWeekend());
self::assertSame($isWeekend, $dayOfWeek->isWeekend());
}

public function providerIsWeekend(): array
Expand All @@ -207,7 +207,7 @@ public function providerIsWeekend(): array
*/
public function testPlus(int $dayOfWeek, int $plusDays, int $expectedDayOfWeek): void
{
$this->assertDayOfWeekIs($expectedDayOfWeek, DayOfWeek::of($dayOfWeek)->plus($plusDays));
self::assertDayOfWeekIs($expectedDayOfWeek, DayOfWeek::of($dayOfWeek)->plus($plusDays));
}

/**
Expand All @@ -219,7 +219,7 @@ public function testPlus(int $dayOfWeek, int $plusDays, int $expectedDayOfWeek):
*/
public function testMinus(int $dayOfWeek, int $plusDays, int $expectedDayOfWeek): void
{
$this->assertDayOfWeekIs($expectedDayOfWeek, DayOfWeek::of($dayOfWeek)->minus(-$plusDays));
self::assertDayOfWeekIs($expectedDayOfWeek, DayOfWeek::of($dayOfWeek)->minus(-$plusDays));
}

public function providerPlus(): Generator
Expand Down Expand Up @@ -253,7 +253,7 @@ public function testGetDayOfWeekFromLocalDate(string $localDate, int $dayOfWeek)
$localDate = LocalDate::parse($localDate);
$dayOfWeek = DayOfWeek::of($dayOfWeek);

$this->assertTrue($localDate->getDayOfWeek()->isEqualTo($dayOfWeek));
self::assertTrue($localDate->getDayOfWeek()->isEqualTo($dayOfWeek));
}

public function providerGetDayOfWeekFromLocalDate(): array
Expand Down Expand Up @@ -283,7 +283,7 @@ public function providerGetDayOfWeekFromLocalDate(): array
*/
public function testJsonSerialize(int $dayOfWeek, string $expectedName): void
{
$this->assertSame(json_encode($expectedName), json_encode(DayOfWeek::of($dayOfWeek)));
self::assertSame(json_encode($expectedName), json_encode(DayOfWeek::of($dayOfWeek)));
}

/**
Expand All @@ -294,7 +294,7 @@ public function testJsonSerialize(int $dayOfWeek, string $expectedName): void
*/
public function testToString(int $dayOfWeek, string $expectedName): void
{
$this->assertSame($expectedName, (string) DayOfWeek::of($dayOfWeek));
self::assertSame($expectedName, (string) DayOfWeek::of($dayOfWeek));
}

public function providerToString(): array
Expand Down
14 changes: 7 additions & 7 deletions tests/DefaultClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ public function tearDown(): void
public function testFreeze(): void
{
DefaultClock::freeze(Instant::of(123456, 5000));
$this->assertInstantIs(123456, 5000, Instant::now());
self::assertInstantIs(123456, 5000, Instant::now());
}

public function testTravel(): void
{
$fixedClock = new FixedClock(Instant::of(1000, 0));
DefaultClock::set($fixedClock);
$this->assertInstantIs(1000, 0, Instant::now());
self::assertInstantIs(1000, 0, Instant::now());

DefaultClock::travel(Instant::of(-1000));
$this->assertInstantIs(-1000, 0, Instant::now());
self::assertInstantIs(-1000, 0, Instant::now());

$fixedClock->move(2);
$this->assertInstantIs(-998, 0, Instant::now());
self::assertInstantIs(-998, 0, Instant::now());
}

public function testScale(): void
{
$fixedClock = new FixedClock(Instant::of(1000, 0));
DefaultClock::set($fixedClock);
$this->assertInstantIs(1000, 0, Instant::now());
self::assertInstantIs(1000, 0, Instant::now());

DefaultClock::scale(60);
$this->assertInstantIs(1000, 0, Instant::now());
self::assertInstantIs(1000, 0, Instant::now());

$fixedClock->move(2);
$this->assertInstantIs(1120, 0, Instant::now());
self::assertInstantIs(1120, 0, Instant::now());
}
}
Loading