Skip to content

Commit

Permalink
Enabled php_unit_test_case_self_method_calls fixer (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored Dec 12, 2020
1 parent afa2aab commit 0576f83
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 109 deletions.
1 change: 1 addition & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enabled:
- php_unit_no_expectation_annotation
- php_unit_ordered_covers
- php_unit_set_up_tear_down_visibility
- php_unit_test_case_self_method_calls
- phpdoc_indent
- phpdoc_inline_tag_normalizer
- phpdoc_no_package
Expand Down
8 changes: 4 additions & 4 deletions test/Faker/Calculator/IbanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function checksumProvider()
*/
public function testChecksum($iban, $checksum)
{
$this->assertEquals($checksum, Iban::checksum($iban), $iban);
self::assertEquals($checksum, Iban::checksum($iban), $iban);
}

public function validatorProvider()
Expand Down Expand Up @@ -235,7 +235,7 @@ public function validatorProvider()
*/
public function testIsValid($iban, $isValid)
{
$this->assertEquals($isValid, Iban::isValid($iban), $iban);
self::assertEquals($isValid, Iban::isValid($iban), $iban);
}

public function alphaToNumberProvider()
Expand Down Expand Up @@ -275,7 +275,7 @@ public function alphaToNumberProvider()
*/
public function testAlphaToNumber($letter, $number)
{
$this->assertEquals($number, Iban::alphaToNumber($letter), $letter);
self::assertEquals($number, Iban::alphaToNumber($letter), $letter);
}

public function mod97Provider()
Expand All @@ -300,6 +300,6 @@ public function mod97Provider()
*/
public function testMod97($number, $result)
{
$this->assertEquals($result, Iban::mod97($number), $number);
self::assertEquals($result, Iban::mod97($number), $number);
}
}
2 changes: 1 addition & 1 deletion test/Faker/Provider/BarcodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testEan8()
{
$code = $this->faker->ean8();
self::assertMatchesRegularExpression('/^\d{8}$/i', $code);
$this->assertTrue(Ean::isValid($code));
self::assertTrue(Ean::isValid($code));
}

public function testEan13()
Expand Down
12 changes: 6 additions & 6 deletions test/Faker/Provider/BiasedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function testUnbiased()
$assumed = (1 / self::MAX * $number) - (1 / self::MAX * ($number - 1));
// calculate the fraction of the whole area
$assumed /= 1;
$this->assertGreaterThan(self::NUMBERS * $assumed * .95, $amount, 'Value was more than 5 percent under the expected value');
$this->assertLessThan(self::NUMBERS * $assumed * 1.05, $amount, 'Value was more than 5 percent over the expected value');
self::assertGreaterThan(self::NUMBERS * $assumed * .95, $amount, 'Value was more than 5 percent under the expected value');
self::assertLessThan(self::NUMBERS * $assumed * 1.05, $amount, 'Value was more than 5 percent over the expected value');
}
}

Expand All @@ -48,8 +48,8 @@ public function testLinearHigh()
$assumed = 0.5 * (1 / self::MAX * $number) ** 2 - 0.5 * (1 / self::MAX * ($number - 1)) ** 2;
// calculate the fraction of the whole area
$assumed /= 1 ** 2 * .5;
$this->assertGreaterThan(self::NUMBERS * $assumed * .9, $amount, 'Value was more than 10 percent under the expected value');
$this->assertLessThan(self::NUMBERS * $assumed * 1.1, $amount, 'Value was more than 10 percent over the expected value');
self::assertGreaterThan(self::NUMBERS * $assumed * .9, $amount, 'Value was more than 10 percent under the expected value');
self::assertLessThan(self::NUMBERS * $assumed * 1.1, $amount, 'Value was more than 10 percent over the expected value');
}
}

Expand All @@ -64,8 +64,8 @@ public function testLinearLow()
$assumed += 1 / self::MAX;
// calculate the fraction of the whole area
$assumed /= 1 ** 2 * .5;
$this->assertGreaterThan(self::NUMBERS * $assumed * .9, $amount, 'Value was more than 10 percent under the expected value');
$this->assertLessThan(self::NUMBERS * $assumed * 1.1, $amount, 'Value was more than 10 percent over the expected value');
self::assertGreaterThan(self::NUMBERS * $assumed * .9, $amount, 'Value was more than 10 percent under the expected value');
self::assertLessThan(self::NUMBERS * $assumed * 1.1, $amount, 'Value was more than 10 percent over the expected value');
}
}

Expand Down
138 changes: 69 additions & 69 deletions test/Faker/Provider/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function testPreferDefaultTimezoneOverSystemTimezone()
* timezone over the system timezone.
*/
$date = DateTimeProvider::dateTime();
$this->assertNotSame($systemTimezone, $date->getTimezone()->getName());
$this->assertSame($this->defaultTz, $date->getTimezone()->getName());
self::assertNotSame($systemTimezone, $date->getTimezone()->getName());
self::assertSame($this->defaultTz, $date->getTimezone()->getName());

/**
* Restore the system timezone.
Expand All @@ -59,8 +59,8 @@ public function testUseSystemTimezoneWhenDefaultTimezoneIsNotSet()
* and not the system timezone.
*/
$date = DateTimeProvider::dateTime();
$this->assertSame($systemTimezone, $date->getTimezone()->getName());
$this->assertNotSame($this->defaultTz, $date->getTimezone()->getName());
self::assertSame($systemTimezone, $date->getTimezone()->getName());
self::assertNotSame($this->defaultTz, $date->getTimezone()->getName());

/**
* Restore the system timezone.
Expand All @@ -71,115 +71,115 @@ public function testUseSystemTimezoneWhenDefaultTimezoneIsNotSet()
public function testUnixTime()
{
$timestamp = DateTimeProvider::unixTime();
$this->assertIsInt($timestamp);
$this->assertGreaterThanOrEqual(0, $timestamp);
$this->assertLessThanOrEqual(time(), $timestamp);
self::assertIsInt($timestamp);
self::assertGreaterThanOrEqual(0, $timestamp);
self::assertLessThanOrEqual(time(), $timestamp);
}

public function testDateTime()
{
$date = DateTimeProvider::dateTime();
$this->assertInstanceOf('\DateTime', $date);
$this->assertGreaterThanOrEqual(new \DateTime('@0'), $date);
$this->assertLessThanOrEqual(new \DateTime(), $date);
$this->assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
self::assertInstanceOf('\DateTime', $date);
self::assertGreaterThanOrEqual(new \DateTime('@0'), $date);
self::assertLessThanOrEqual(new \DateTime(), $date);
self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}

public function testDateTimeWithTimezone()
{
$date = DateTimeProvider::dateTime('now', 'America/New_York');
$this->assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
self::assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
}

public function testDateTimeAD()
{
$date = DateTimeProvider::dateTimeAD();
$this->assertInstanceOf('\DateTime', $date);
$this->assertGreaterThanOrEqual(new \DateTime('0000-01-01 00:00:00'), $date);
$this->assertLessThanOrEqual(new \DateTime(), $date);
$this->assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
self::assertInstanceOf('\DateTime', $date);
self::assertGreaterThanOrEqual(new \DateTime('0000-01-01 00:00:00'), $date);
self::assertLessThanOrEqual(new \DateTime(), $date);
self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}

public function testDateTimeThisCentury()
{
$date = DateTimeProvider::dateTimeThisCentury();
$this->assertInstanceOf('\DateTime', $date);
$this->assertGreaterThanOrEqual(new \DateTime('-100 year'), $date);
$this->assertLessThanOrEqual(new \DateTime(), $date);
$this->assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
self::assertInstanceOf('\DateTime', $date);
self::assertGreaterThanOrEqual(new \DateTime('-100 year'), $date);
self::assertLessThanOrEqual(new \DateTime(), $date);
self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}

public function testDateTimeThisDecade()
{
$date = DateTimeProvider::dateTimeThisDecade();
$this->assertInstanceOf('\DateTime', $date);
$this->assertGreaterThanOrEqual(new \DateTime('-10 year'), $date);
$this->assertLessThanOrEqual(new \DateTime(), $date);
$this->assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
self::assertInstanceOf('\DateTime', $date);
self::assertGreaterThanOrEqual(new \DateTime('-10 year'), $date);
self::assertLessThanOrEqual(new \DateTime(), $date);
self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}

public function testDateTimeThisYear()
{
$date = DateTimeProvider::dateTimeThisYear();
$this->assertInstanceOf('\DateTime', $date);
$this->assertGreaterThanOrEqual(new \DateTime('first day of january this year'), $date);
$this->assertLessThanOrEqual(new \DateTime(), $date);
$this->assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
self::assertInstanceOf('\DateTime', $date);
self::assertGreaterThanOrEqual(new \DateTime('first day of january this year'), $date);
self::assertLessThanOrEqual(new \DateTime(), $date);
self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}

public function testDateTimeThisMonth()
{
$date = DateTimeProvider::dateTimeThisMonth();
$this->assertInstanceOf('\DateTime', $date);
$this->assertGreaterThanOrEqual(new \DateTime('-1 month'), $date);
$this->assertLessThanOrEqual(new \DateTime(), $date);
$this->assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
self::assertInstanceOf('\DateTime', $date);
self::assertGreaterThanOrEqual(new \DateTime('-1 month'), $date);
self::assertLessThanOrEqual(new \DateTime(), $date);
self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}

public function testDateTimeThisCenturyWithTimezone()
{
$date = DateTimeProvider::dateTimeThisCentury('now', 'America/New_York');
$this->assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
self::assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
}

public function testDateTimeThisDecadeWithTimezone()
{
$date = DateTimeProvider::dateTimeThisDecade('now', 'America/New_York');
$this->assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
self::assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
}

public function testDateTimeThisYearWithTimezone()
{
$date = DateTimeProvider::dateTimeThisYear('now', 'America/New_York');
$this->assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
self::assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
}

public function testDateTimeThisMonthWithTimezone()
{
$date = DateTimeProvider::dateTimeThisMonth('now', 'America/New_York');
$this->assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
self::assertEquals($date->getTimezone(), new \DateTimeZone('America/New_York'));
}

public function testIso8601()
{
$date = DateTimeProvider::iso8601();
$this->assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-Z](\d{4})?$/', $date);
$this->assertGreaterThanOrEqual(new \DateTime('@0'), new \DateTime($date));
$this->assertLessThanOrEqual(new \DateTime(), new \DateTime($date));
self::assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-Z](\d{4})?$/', $date);
self::assertGreaterThanOrEqual(new \DateTime('@0'), new \DateTime($date));
self::assertLessThanOrEqual(new \DateTime(), new \DateTime($date));
}

public function testDate()
{
$date = DateTimeProvider::date();
$this->assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}$/', $date);
$this->assertGreaterThanOrEqual(new \DateTime('@0'), new \DateTime($date));
$this->assertLessThanOrEqual(new \DateTime(), new \DateTime($date));
self::assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}$/', $date);
self::assertGreaterThanOrEqual(new \DateTime('@0'), new \DateTime($date));
self::assertLessThanOrEqual(new \DateTime(), new \DateTime($date));
}

public function testTime()
{
$date = DateTimeProvider::time();
$this->assertMatchesRegularExpression('/^\d{2}:\d{2}:\d{2}$/', $date);
self::assertMatchesRegularExpression('/^\d{2}:\d{2}:\d{2}$/', $date);
}

/**
Expand All @@ -188,10 +188,10 @@ public function testTime()
public function testDateTimeBetween($start, $end)
{
$date = DateTimeProvider::dateTimeBetween($start, $end);
$this->assertInstanceOf('\DateTime', $date);
$this->assertGreaterThanOrEqual(new \DateTime($start), $date);
$this->assertLessThanOrEqual(new \DateTime($end), $date);
$this->assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
self::assertInstanceOf('\DateTime', $date);
self::assertGreaterThanOrEqual(new \DateTime($start), $date);
self::assertLessThanOrEqual(new \DateTime($end), $date);
self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}

public function providerDateTimeBetween()
Expand All @@ -210,16 +210,16 @@ public function providerDateTimeBetween()
public function testDateTimeInInterval($start, $interval, $isInFuture)
{
$date = DateTimeProvider::dateTimeInInterval($start, $interval);
$this->assertInstanceOf('\DateTime', $date);
self::assertInstanceOf('\DateTime', $date);

$_interval = \DateInterval::createFromDateString($interval);
$_start = new \DateTime($start);
if ($isInFuture) {
$this->assertGreaterThanOrEqual($_start, $date);
$this->assertLessThanOrEqual($_start->add($_interval), $date);
self::assertGreaterThanOrEqual($_start, $date);
self::assertLessThanOrEqual($_start->add($_interval), $date);
} else {
$this->assertLessThanOrEqual($_start, $date);
$this->assertGreaterThanOrEqual($_start->add($_interval), $date);
self::assertLessThanOrEqual($_start, $date);
self::assertGreaterThanOrEqual($_start->add($_interval), $date);
}
}

Expand Down Expand Up @@ -258,23 +258,23 @@ public function testFixedSeedWithMaximumTimestamp()

//regenerate Random Date with same seed and same maximum end timestamp
mt_srand(1);
$this->assertEquals($unixTime, DateTimeProvider::unixTime($max));
$this->assertEquals($datetimeAD, DateTimeProvider::dateTimeAD($max));
$this->assertEquals($dateTime1, DateTimeProvider::dateTime($max));
$this->assertEquals($dateTimeBetween, DateTimeProvider::dateTimeBetween('2014-03-01 06:00:00', $max));
$this->assertEquals($date, DateTimeProvider::date('Y-m-d', $max));
$this->assertEquals($time, DateTimeProvider::time('H:i:s', $max));
$this->assertEquals($iso8601, DateTimeProvider::iso8601($max));
$this->assertEquals($dateTimeThisCentury, DateTimeProvider::dateTimeThisCentury($max));
$this->assertEquals($dateTimeThisDecade, DateTimeProvider::dateTimeThisDecade($max));
$this->assertEquals($dateTimeThisMonth, DateTimeProvider::dateTimeThisMonth($max));
$this->assertEquals($amPm, DateTimeProvider::amPm($max));
$this->assertEquals($dayOfMonth, DateTimeProvider::dayOfMonth($max));
$this->assertEquals($dayOfWeek, DateTimeProvider::dayOfWeek($max));
$this->assertEquals($month, DateTimeProvider::month($max));
$this->assertEquals($monthName, DateTimeProvider::monthName($max));
$this->assertEquals($year, DateTimeProvider::year($max));
$this->assertEquals($dateTimeThisYear, DateTimeProvider::dateTimeThisYear($max));
self::assertEquals($unixTime, DateTimeProvider::unixTime($max));
self::assertEquals($datetimeAD, DateTimeProvider::dateTimeAD($max));
self::assertEquals($dateTime1, DateTimeProvider::dateTime($max));
self::assertEquals($dateTimeBetween, DateTimeProvider::dateTimeBetween('2014-03-01 06:00:00', $max));
self::assertEquals($date, DateTimeProvider::date('Y-m-d', $max));
self::assertEquals($time, DateTimeProvider::time('H:i:s', $max));
self::assertEquals($iso8601, DateTimeProvider::iso8601($max));
self::assertEquals($dateTimeThisCentury, DateTimeProvider::dateTimeThisCentury($max));
self::assertEquals($dateTimeThisDecade, DateTimeProvider::dateTimeThisDecade($max));
self::assertEquals($dateTimeThisMonth, DateTimeProvider::dateTimeThisMonth($max));
self::assertEquals($amPm, DateTimeProvider::amPm($max));
self::assertEquals($dayOfMonth, DateTimeProvider::dayOfMonth($max));
self::assertEquals($dayOfWeek, DateTimeProvider::dayOfWeek($max));
self::assertEquals($month, DateTimeProvider::month($max));
self::assertEquals($monthName, DateTimeProvider::monthName($max));
self::assertEquals($year, DateTimeProvider::year($max));
self::assertEquals($dateTimeThisYear, DateTimeProvider::dateTimeThisYear($max));
mt_srand();
}
}
2 changes: 1 addition & 1 deletion test/Faker/Provider/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testDownloadWithDefaults()
curl_close($curlPing);

if ($httpCode < 200 | $httpCode > 300) {
$this->markTestSkipped('Placeholder.com is offline, skipping image download');
self::markTestSkipped('Placeholder.com is offline, skipping image download');
}

$file = Image::image(sys_get_temp_dir());
Expand Down
6 changes: 3 additions & 3 deletions test/Faker/Provider/InternetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ public function testSlugWithoutVariableNbWordsProducesValidSlug()
{
$pattern = '/^[a-z0-9-]+$/';
$slug = $this->faker->slug(6, false);
$this->assertSame(preg_match($pattern, $slug), 1);
self::assertSame(preg_match($pattern, $slug), 1);
}

public function testSlugWithoutVariableNbWordsProducesCorrectNumberOfNbWords()
{
$slug = $this->faker->slug(3, false);
$this->assertCount(3, explode('-', $slug));
self::assertCount(3, explode('-', $slug));
}

public function testSlugWithoutNbWordsIsEmpty()
{
$slug = $this->faker->slug(0);
$this->assertSame('', $slug);
self::assertSame('', $slug);
}

public function testUrlIsValid()
Expand Down
Loading

0 comments on commit 0576f83

Please sign in to comment.