-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
207 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
|
||
<arg value="p"/> | ||
<arg value="s"/> | ||
<arg name="colors"/> | ||
<arg name="parallel" value="4"/> | ||
<arg name="cache" value="./.phpcs.cache"/> | ||
|
||
<file>bin/</file> | ||
<file>src/</file> | ||
<file>tests/</file> | ||
|
||
<rule ref="./vendor/doctrine/coding-standard/lib/Doctrine/ruleset.xml"> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix"/> | ||
<exclude name="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed"/> | ||
</rule> | ||
|
||
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"> | ||
<properties> | ||
<property name="spacing" value="1" /> | ||
<property name="spacingBeforeFirst" value="0" /> | ||
</properties> | ||
</rule> | ||
|
||
<rule ref="Generic.Files.LineLength"> | ||
<properties> | ||
<property name="lineLimit" value="160"/> | ||
</properties> | ||
</rule> | ||
|
||
<rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"> | ||
<severity>5</severity> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html --> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="./tests/bootstrap.php" | ||
beStrictAboutChangesToGlobalState="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutResourceUsageDuringSmallTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
beStrictAboutCoversAnnotation="false" | ||
forceCoversAnnotation="true" | ||
enforceTimeLimit="true" | ||
cacheResultFile="./var/cache/phpunit.unit.result.cache" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
timeoutForSmallTests="2" | ||
colors="true" | ||
verbose="true" | ||
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer" | ||
> | ||
<php> | ||
<server name="KERNEL_CLASS" value="App\Kernel" /> | ||
<server name="APP_ENV" value="test" /> | ||
</php> | ||
|
||
|
||
<testsuites> | ||
<testsuite name="Project Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Collection; | ||
|
||
use App\Collection\PackageCollection; | ||
use Composer\Package\PackageInterface; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \App\Collection\PackageCollection | ||
*/ | ||
final class PackageCollectionTest extends TestCase | ||
{ | ||
public function testLastStable(): void | ||
{ | ||
$packageDev = $this->createMock(PackageInterface::class); | ||
$packageDev->method('isDev')->willReturn(true); | ||
|
||
$packageStable = $this->createMock(PackageInterface::class); | ||
$packageStable->method('isDev')->willReturn(false); | ||
|
||
$collection = PackageCollection::create( | ||
$packageDev, | ||
$packageStable | ||
); | ||
|
||
self::assertSame($packageStable, $collection->getLastStablePackage()); | ||
} | ||
|
||
public function testLastStableNotFound(): void | ||
{ | ||
$packageDev = $this->createMock(PackageInterface::class); | ||
$packageDev->method('isDev')->willReturn(true); | ||
|
||
$packageStable = $this->createMock(PackageInterface::class); | ||
$packageStable->method('isDev')->willReturn(true); | ||
$collection = PackageCollection::create( | ||
$packageDev, | ||
$packageStable | ||
); | ||
|
||
self::assertNull($collection->getLastStablePackage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Collection; | ||
|
||
use App\Collection\VersionCollection; | ||
use App\Entity\Version; | ||
use Carbon\Carbon; | ||
use Composer\Package\PackageInterface; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \App\Collection\VersionCollection | ||
*/ | ||
final class VersionCollectionTest extends TestCase | ||
{ | ||
public function testSortByReleaseDate(): void | ||
{ | ||
$packageA = $this->createMock(PackageInterface::class); | ||
$packageA->method('isDev')->willReturn(false); | ||
$packageA->method('getReleaseDate')->willReturn(Carbon::parse('2020-05-05 12:00:00')); | ||
|
||
$packageB = $this->createMock(PackageInterface::class); | ||
$packageB->method('isDev')->willReturn(false); | ||
$packageB->method('getReleaseDate')->willReturn(Carbon::parse('2020-05-10 12:00:00')); | ||
|
||
$packageC = $this->createMock(PackageInterface::class); | ||
$packageC->method('isDev')->willReturn(true); | ||
$packageC->method('getReleaseDate')->willReturn(Carbon::parse('2020-05-15 12:00:00')); | ||
|
||
$versionA = $this->createMock(Version::class); | ||
$versionA->method('getPackageInformation')->willReturn($packageA); | ||
|
||
$versionB = $this->createMock(Version::class); | ||
$versionB->method('getPackageInformation')->willReturn($packageB); | ||
|
||
$versionC = $this->createMock(Version::class); | ||
$versionC->method('getPackageInformation')->willReturn($packageC); | ||
|
||
$collection = VersionCollection::create( | ||
$versionA, | ||
$versionB, | ||
$versionC, | ||
); | ||
|
||
self::assertSame([ | ||
$versionB, | ||
$versionA, | ||
$versionC, | ||
], $collection->sortByReleaseDate()->toArray()); | ||
} | ||
|
||
public function testToMapCollection(): void | ||
{ | ||
$packageA = $this->createMock(PackageInterface::class); | ||
$packageA->method('isDev')->willReturn(false); | ||
$packageA->method('getReleaseDate')->willReturn(Carbon::parse('2020-05-05 12:00:00')); | ||
|
||
$packageB = $this->createMock(PackageInterface::class); | ||
$packageB->method('isDev')->willReturn(false); | ||
$packageB->method('getReleaseDate')->willReturn(Carbon::parse('2020-05-10 12:00:00')); | ||
|
||
$packageC = $this->createMock(PackageInterface::class); | ||
$packageC->method('isDev')->willReturn(true); | ||
$packageC->method('getReleaseDate')->willReturn(Carbon::parse('2020-05-15 12:00:00')); | ||
|
||
$versionA = $this->createMock(Version::class); | ||
$versionA->method('getPackageInformation')->willReturn($packageA); | ||
|
||
$versionB = $this->createMock(Version::class); | ||
$versionB->method('getPackageInformation')->willReturn($packageB); | ||
|
||
$versionC = $this->createMock(Version::class); | ||
$versionC->method('getPackageInformation')->willReturn($packageC); | ||
|
||
$collection = VersionCollection::create( | ||
$versionA, | ||
$versionB, | ||
$versionC, | ||
); | ||
|
||
self::assertSame([ | ||
$packageA, | ||
$packageB, | ||
$packageC, | ||
], $collection->toPackageCollection()->toArray()); | ||
} | ||
} |