Skip to content

Commit

Permalink
Added support for Chronos 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Nov 6, 2020
1 parent aae5dc4 commit 4ca88b2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/SluggerFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
20 changes: 11 additions & 9 deletions test/Util/IpAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Shlinkio\Shlink\Common\Util\IpAddress;

use function sprintf;
use function trim;

class IpAddressTest extends TestCase
{
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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
Expand All @@ -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'];
}

/**
Expand Down
8 changes: 5 additions & 3 deletions test/Validation/HostAndPortValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/Validation/SluggerFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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
Expand Down

0 comments on commit 4ca88b2

Please sign in to comment.