diff --git a/CHANGELOG.md b/CHANGELOG.md index 929b236..dcfc0aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## [3.3.0] - 2020-11-06 ### Added * Explicitly added compatibility with PHP 8 +* Added support for Chronos 2.0 ### Changed -* *Nothing* +* Updated to `infection` v0.20 ### Deprecated * *Nothing* diff --git a/composer.json b/composer.json index 0f61a30..cad9444 100644 --- a/composer.json +++ b/composer.json @@ -15,11 +15,11 @@ "php": "^7.4 || ^8.0", "ext-fileinfo": "*", "akrabat/ip-address-middleware": "^1.0", - "cakephp/chronos": "^1.2", + "cakephp/chronos": "^2.0 || ^1.2", "doctrine/orm": "^2.7", "endroid/qr-code": "^3.6", "fig/http-message-util": "^1.1", - "guzzlehttp/guzzle": "^7.0 || ^6.5.1", + "guzzlehttp/guzzle": "^7.0", "laminas/laminas-config": "^3.3", "laminas/laminas-diactoros": "^2.1.3", "laminas/laminas-inputfilter": "^2.10", @@ -38,7 +38,7 @@ "symfony/translation-contracts": "^2.1" }, "require-dev": { - "infection/infection": "^0.19.2", + "infection/infection": "^0.20.1", "laminas/laminas-stratigility": "^3.2", "mezzio/mezzio-problem-details": "^1.0", "phpspec/prophecy-phpunit": "^2.0", diff --git a/src/Validation/SluggerFilter.php b/src/Validation/SluggerFilter.php index 47e0b38..39e1715 100644 --- a/src/Validation/SluggerFilter.php +++ b/src/Validation/SluggerFilter.php @@ -28,6 +28,6 @@ public function __construct(?Slugger\SluggerInterface $slugger = null) */ public function filter($value) { - return is_string($value) ? (string) $this->slugger->slug($value) : $value; + return is_string($value) ? $this->slugger->slug($value)->toString() : $value; } } diff --git a/test/Util/IpAddressTest.php b/test/Util/IpAddressTest.php index cdc9196..d5109f7 100644 --- a/test/Util/IpAddressTest.php +++ b/test/Util/IpAddressTest.php @@ -10,6 +10,7 @@ use Shlinkio\Shlink\Common\Util\IpAddress; use function sprintf; +use function trim; class IpAddressTest extends TestCase { @@ -48,11 +49,11 @@ public function validAddressesAreProperlyParsed( ): void { $address = IpAddress::fromString($validAddress); - $this->assertEquals($firstOctet, $this->getPropFromIpAddress($address, 'firstOctet')); - $this->assertEquals($secondOctet, $this->getPropFromIpAddress($address, 'secondOctet')); - $this->assertEquals($thirdOctet, $this->getPropFromIpAddress($address, 'thirdOctet')); - $this->assertEquals($fourthOctet, $this->getPropFromIpAddress($address, 'fourthOctet')); - $this->assertEquals($validAddress, (string) $address); + self::assertEquals($firstOctet, $this->getPropFromIpAddress($address, 'firstOctet')); + self::assertEquals($secondOctet, $this->getPropFromIpAddress($address, 'secondOctet')); + self::assertEquals($thirdOctet, $this->getPropFromIpAddress($address, 'thirdOctet')); + self::assertEquals($fourthOctet, $this->getPropFromIpAddress($address, 'fourthOctet')); + self::assertEquals(trim($validAddress), (string) $address); } /** @@ -67,10 +68,10 @@ public function addressesRemoveLastOctetWhenAnonymized( ): void { $anonymizedAddress = IpAddress::fromString($validAddress)->getAnonymizedCopy(); - $this->assertEquals($firstOctet, $this->getPropFromIpAddress($anonymizedAddress, 'firstOctet')); - $this->assertEquals($secondOctet, $this->getPropFromIpAddress($anonymizedAddress, 'secondOctet')); - $this->assertEquals($thirdOctet, $this->getPropFromIpAddress($anonymizedAddress, 'thirdOctet')); - $this->assertEquals(0, $this->getPropFromIpAddress($anonymizedAddress, 'fourthOctet')); + self::assertEquals($firstOctet, $this->getPropFromIpAddress($anonymizedAddress, 'firstOctet')); + self::assertEquals($secondOctet, $this->getPropFromIpAddress($anonymizedAddress, 'secondOctet')); + self::assertEquals($thirdOctet, $this->getPropFromIpAddress($anonymizedAddress, 'thirdOctet')); + self::assertEquals(0, $this->getPropFromIpAddress($anonymizedAddress, 'fourthOctet')); } public function provideValidAddresses(): iterable @@ -81,6 +82,7 @@ public function provideValidAddresses(): iterable yield ['192.168.1.254', '192', '168', '1', '254']; yield ['8.8.8.8', '8', '8', '8', '8']; yield ['8.8.4.4', '8', '8', '4', '4']; + yield [' 8.8.4.4 ', '8', '8', '4', '4']; } /** diff --git a/test/Validation/HostAndPortValidatorTest.php b/test/Validation/HostAndPortValidatorTest.php index ed1f696..bc9732d 100644 --- a/test/Validation/HostAndPortValidatorTest.php +++ b/test/Validation/HostAndPortValidatorTest.php @@ -23,8 +23,8 @@ public function failsToValidateWhenProvidedDataIsInvalid(string $value, string $ { $validator = new HostAndPortValidator(); - $this->assertFalse($validator->isValid($value)); - $this->assertContains($expectedError, array_values($validator->getMessages())); + self::assertFalse($validator->isValid($value)); + self::assertContains($expectedError, array_values($validator->getMessages())); } public function provideInvalidValues(): iterable @@ -49,7 +49,7 @@ public function provideInvalidValues(): iterable public function succeedsWhenProvidingValidValues(string $value): void { $validator = new HostAndPortValidator(); - $this->assertTrue($validator->isValid($value)); + self::assertTrue($validator->isValid($value)); } public function provideValidValues(): iterable @@ -58,6 +58,8 @@ public function provideValidValues(): iterable yield ['localhost:3000']; yield ['example.com']; yield ['example.com:8080']; + yield ['example.com:1']; + yield ['example.com:65535']; } /** diff --git a/test/Validation/SluggerFilterTest.php b/test/Validation/SluggerFilterTest.php index 4d30e66..a557fbe 100644 --- a/test/Validation/SluggerFilterTest.php +++ b/test/Validation/SluggerFilterTest.php @@ -35,7 +35,7 @@ public function providedValueIsFilteredAsExpected(?string $providedValue, ?strin $result = $this->filter->filter($providedValue); - $this->assertEquals($expectedValue, $result); + self::assertEquals($expectedValue, $result); $slugify->shouldHaveBeenCalledTimes($expectedValue !== null ? 1 : 0); } @@ -53,7 +53,7 @@ public function provideValuesToFilter(): iterable public function internalSluggerKeepsCasing(string $providedValue, string $expectedValue): void { $filter = new SluggerFilter(); - $this->assertEquals($expectedValue, $filter->filter($providedValue)); + self::assertEquals($expectedValue, $filter->filter($providedValue)); } public function provideValuesToFilterWithCasing(): iterable