Skip to content

Commit d001755

Browse files
committed
some final tweaks
1 parent 055c80c commit d001755

13 files changed

+50
-50
lines changed

src/CountryAssertions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
trait CountryAssertions
1010
{
11-
public static function assertCountry(string $key, $actual): void
11+
public static function assertCountry($actual, string $key): void
1212
{
1313
switch ($key) {
1414
case ISO3166::KEY_NAME:

src/EmailAssertions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public static function assertValidStrict($actual): void
2020
PHPUnit::assertTrue((new EmailValidator())->isValid($actual, new RFCValidation()));
2121
}
2222

23-
public static function assertSameDomain(string $expected, $actual): void
23+
public static function assertDomain(string $expected, $actual): void
2424
{
2525
PHPUnit::assertIsString($actual);
2626
[, $domain] = explode('@', $actual, 2);
2727
PHPUnit::assertSame($expected, $domain);
2828
}
2929

30-
public static function assertSameLocalPart(string $expected, $actual): void
30+
public static function assertLocalPart(string $expected, $actual): void
3131
{
3232
PHPUnit::assertIsString($actual);
3333
[$localPart] = explode('@', $actual, 2);

src/GeoAssertions.php renamed to src/GeographicAssertions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use PHPUnit\Framework\Assert as PHPUnit;
66

7-
trait GeoAssertions
7+
trait GeographicAssertions
88
{
99
public static function assertLatitude($actual): void
1010
{

src/NullableTypeAssertions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function assertIsNullableBool($actual): void
7171
* @param string $type
7272
* @param mixed|null $actual
7373
*/
74-
private static function assertIsNullableType(bool $condition, string $type, $actual): void
74+
protected static function assertIsNullableType(bool $condition, string $type, $actual): void
7575
{
7676
PHPUnit::assertTrue(
7777
$condition,

src/PhoneNumberAssertions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static function assertE164($actual): void
1313
{
1414
PHPUnit::assertIsString($actual);
1515
PHPUnit::assertMatchesRegularExpression('/^\+[1-9]\d{1,14}$/', $actual);
16-
StringAssertions::assertLengthLessThanOrEqual(16, $actual); // plus-sign and max. 15 digits incl. CC-prefix
16+
StringLengthAssertions::assertLessThanOrEqual(16, $actual); // plus-sign and max. 15 digits incl. CC-prefix
1717
}
1818

1919
public static function assertValid($actual): void
@@ -25,7 +25,7 @@ public static function assertValid($actual): void
2525
);
2626
}
2727

28-
public static function assertValidForRegion(string $regionCode, $actual): void
28+
public static function assertValidForRegion($actual, string $regionCode): void
2929
{
3030
PHPUnit::assertTrue(
3131
PhoneNumberUtil::getInstance()->isValidNumberForRegion(

src/StringAssertions.php renamed to src/StringLengthAssertions.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@
44

55
use PHPUnit\Framework\Assert as PHPUnit;
66

7-
trait StringAssertions
7+
trait StringLengthAssertions
88
{
9-
public static function assertLength(int $length, $actual): void
9+
public static function assertSame(int $length, $actual): void
1010
{
1111
PHPUnit::assertIsString($actual);
1212
PHPUnit::assertSame($length, mb_strlen($actual));
1313
}
1414

15-
public static function assertNotLength(int $length, $actual): void
15+
public static function assertNotSame(int $length, $actual): void
1616
{
1717
PHPUnit::assertIsString($actual);
1818
PHPUnit::assertNotSame($length, mb_strlen($actual));
1919
}
2020

21-
public static function assertLengthLessThan(int $length, $actual): void
21+
public static function assertLessThan(int $length, $actual): void
2222
{
2323
PHPUnit::assertIsString($actual);
2424
PHPUnit::assertLessThan($length, mb_strlen($actual));
2525
}
2626

27-
public static function assertLengthLessThanOrEqual(int $length, $actual): void
27+
public static function assertLessThanOrEqual(int $length, $actual): void
2828
{
2929
PHPUnit::assertIsString($actual);
3030
PHPUnit::assertLessThanOrEqual($length, mb_strlen($actual));
3131
}
3232

33-
public static function assertLengthGreaterThan(int $length, $actual): void
33+
public static function assertGreaterThan(int $length, $actual): void
3434
{
3535
PHPUnit::assertIsString($actual);
3636
PHPUnit::assertGreaterThan($length, mb_strlen($actual));
3737
}
3838

39-
public static function assertLengtGreaterThanOrEqual(int $length, $actual): void
39+
public static function assertGreaterThanOrEqual(int $length, $actual): void
4040
{
4141
PHPUnit::assertIsString($actual);
4242
PHPUnit::assertGreaterThanOrEqual($length, mb_strlen($actual));

src/UrlAssertions.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ public static function assertValidLoose($actual): void
1212
PHPUnit::assertNotFalse(filter_var($actual, FILTER_VALIDATE_URL));
1313
}
1414

15-
public static function assertSameScheme(string $expected, $actual): void
15+
public static function assertScheme(string $expected, $actual): void
1616
{
17-
self::assertSameComponent($expected, $actual, PHP_URL_SCHEME);
17+
self::assertComponent($expected, $actual, PHP_URL_SCHEME);
1818
}
1919

20-
public static function assertSameHost(string $expected, $actual): void
20+
public static function assertHost(string $expected, $actual): void
2121
{
22-
self::assertSameComponent($expected, $actual, PHP_URL_HOST);
22+
self::assertComponent($expected, $actual, PHP_URL_HOST);
2323
}
2424

25-
public static function assertSamePath(string $expected, $actual): void
25+
public static function assertPath(string $expected, $actual): void
2626
{
27-
self::assertSameComponent($expected, $actual, PHP_URL_PATH);
27+
self::assertComponent($expected, $actual, PHP_URL_PATH);
2828
}
2929

30-
public static function assertSameComponent($expected, $actual, $component): void
30+
public static function assertComponent($expected, $actual, int $component): void
3131
{
3232
self::assertValidLoose($actual);
3333
PHPUnit::assertSame($expected, parse_url($actual, $component));

tests/CountryAssertionsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ final class CountryAssertionsTest extends TestCase
1313
*/
1414
public static function it_can_validate_country(string $name, string $alpha2, string $alpha3, string $numeric): void
1515
{
16-
CountryAssertions::assertCountry(ISO3166::KEY_NAME, $name);
17-
CountryAssertions::assertCountry(ISO3166::KEY_ALPHA2, $alpha2);
18-
CountryAssertions::assertCountry(ISO3166::KEY_ALPHA3, $alpha3);
19-
CountryAssertions::assertCountry(ISO3166::KEY_NUMERIC, $numeric);
16+
CountryAssertions::assertCountry($name, ISO3166::KEY_NAME);
17+
CountryAssertions::assertCountry($alpha2, ISO3166::KEY_ALPHA2);
18+
CountryAssertions::assertCountry($alpha3, ISO3166::KEY_ALPHA3);
19+
CountryAssertions::assertCountry($numeric, ISO3166::KEY_NUMERIC);
2020
}
2121

2222
/**

tests/EmailAssertionsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ public static function it_can_validate_strict(): void
2828
* @test
2929
* @dataProvider hundredTimes
3030
*/
31-
public static function it_can_validate_same_domain(): void
31+
public static function it_can_validate_domain(): void
3232
{
33-
EmailAssertions::assertSameDomain('email.com', self::randomString().'@email.com');
33+
EmailAssertions::assertDomain('email.com', self::randomString().'@email.com');
3434
}
3535

3636
/**
3737
* @test
3838
* @dataProvider hundredTimes
3939
*/
40-
public static function it_can_validate_same_local_part(): void
40+
public static function it_can_validate_local_part(): void
4141
{
4242
$localPart = self::randomString();
4343

44-
EmailAssertions::assertSameLocalPart($localPart, $localPart.'@email.com');
44+
EmailAssertions::assertLocalPart($localPart, $localPart.'@email.com');
4545
}
4646
}

tests/GeoAssertionsTest.php renamed to tests/GeographicAssertionsTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
namespace Astrotomic\PhpunitAssertions\Tests;
44

5-
use Astrotomic\PhpunitAssertions\GeoAssertions;
5+
use Astrotomic\PhpunitAssertions\GeographicAssertions;
66

7-
final class GeoAssertionsTest extends TestCase
7+
final class GeographicAssertionsTest extends TestCase
88
{
99
/**
1010
* @test
1111
* @dataProvider hundredTimes
1212
*/
1313
public static function it_can_validate_latitude(): void
1414
{
15-
GeoAssertions::assertLatitude(static::randomFloat(-90, 90));
15+
GeographicAssertions::assertLatitude(static::randomFloat(-90, 90));
1616
}
1717

1818
/**
@@ -21,7 +21,7 @@ public static function it_can_validate_latitude(): void
2121
*/
2222
public static function it_can_validate_longitude(): void
2323
{
24-
GeoAssertions::assertLongitude(static::randomFloat(-180, 180));
24+
GeographicAssertions::assertLongitude(static::randomFloat(-180, 180));
2525
}
2626

2727
/**
@@ -35,7 +35,7 @@ public static function it_can_validate_array_of_coordinates(): void
3535
'lng' => static::randomFloat(-180, 180),
3636
];
3737

38-
GeoAssertions::assertCoordinates($coords);
38+
GeographicAssertions::assertCoordinates($coords);
3939
}
4040

4141
/**
@@ -52,6 +52,6 @@ public static function it_can_validate_array_of_coordinates_with_custom_keys():
5252
$lng => static::randomFloat(-180, 180),
5353
];
5454

55-
GeoAssertions::assertCoordinates($coords, $lat, $lng);
55+
GeographicAssertions::assertCoordinates($coords, $lat, $lng);
5656
}
5757
}

0 commit comments

Comments
 (0)