Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
vendor
/.idea
/vendor
/.phpunit.cache/
/.phpunit.result.cache
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"symfony/yaml": "^6.2|^7.0|^8.0"
},
"require-dev": {
"brianium/paratest": "^6.0",
"brianium/paratest": "^7.3",
"jangregor/phpstan-prophecy": "2.2.0",
"larapack/dd": "^1.1",
"phpmd/phpmd": "^2.9",
"phpspec/prophecy-phpunit": "^2.0",
"phpspec/prophecy-phpunit": "^2.5",
"phpstan/phpstan": "2.2.1",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^9.3",
"phpunit/phpunit": "^10.5|^11.0|^12.0|^13.0",
"rregeer/phpunit-coverage-check": "^0.3.1",
"slevomat/coding-standard": "^8.15",
"squizlabs/php_codesniffer": "^3.5",
Expand Down
10 changes: 7 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true" bootstrap="vendor/autoload.php">
<coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache">
<source>
<include>
<directory>src</directory>
</include>
<exclude>
<directory>src/Dictionary/*</directory>
<directory>src/Exception/*</directory>
</exclude>
</coverage>
</source>
<testsuites>
<testsuite name="test">
<directory>test/Unit</directory>
Expand Down
108 changes: 75 additions & 33 deletions test/ApiDataProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ trait ApiDataProviders
/**
* @return iterable<mixed>
*/
public function provideGetEndpointsTestCases(): iterable
public static function provideGetEndpointsTestCases(): iterable
{
foreach ($this->getGetEndpoints() as $endpoint => $value) {
foreach (static::getGetEndpoints() as $endpoint => $value) {
[$data, $parameters] = $value;

yield [$data, $endpoint, $parameters];
Expand All @@ -22,11 +22,11 @@ public function provideGetEndpointsTestCases(): iterable
/**
* @return iterable<mixed>
*/
public function provideGetEndpointsUnsuccessfulTestCases(): iterable
public static function provideGetEndpointsUnsuccessfulTestCases(): iterable
{
foreach ($this->getGetEndpoints() as $endpoint => $value) {
foreach (static::getGetEndpoints() as $endpoint => $value) {
$parameters = next($value);
foreach ($this->provideUnsuccessfulResponses() as $testCase) {
foreach (static::provideUnsuccessfulResponses() as $testCase) {
yield [current($testCase), $endpoint, $parameters];
}
}
Expand All @@ -35,9 +35,16 @@ public function provideGetEndpointsUnsuccessfulTestCases(): iterable
/**
* @return iterable<mixed>
*/
public function providePostEndpointsTestCases(): iterable
public static function providePostEndpointsTestCases(): iterable
{
foreach ($this->getPostEndpoints() as $endpoint => $value) {
$endpoints = static::getPostEndpoints();
if (empty($endpoints)) {
yield [null, null, null];

return;
}

foreach ($endpoints as $endpoint => $value) {
[$model, $data] = $value;

yield [$model, $data, $endpoint];
Expand All @@ -47,9 +54,9 @@ public function providePostEndpointsTestCases(): iterable
/**
* @return iterable<mixed>
*/
public function providePutEndpointsTestCases(): iterable
public static function providePutEndpointsTestCases(): iterable
{
foreach ($this->getPutEndpoints() as $endpoint => $value) {
foreach (static::getPutEndpoints() as $endpoint => $value) {
[$model, $data, $response] = $value;

yield [$model, $data, $response, $endpoint];
Expand All @@ -59,11 +66,18 @@ public function providePutEndpointsTestCases(): iterable
/**
* @return iterable<mixed>
*/
public function providePostEndpointsUnsuccessfulTestCases(): iterable
public static function providePostEndpointsUnsuccessfulTestCases(): iterable
{
foreach ($this->getPostEndpoints() as $endpoint => $value) {
$endpoints = static::getPostEndpoints();
if (empty($endpoints)) {
yield [null, null, null];

return;
}

foreach ($endpoints as $endpoint => $value) {
$model = current($value);
foreach ($this->provideUnsuccessfulResponses() as $testCase) {
foreach (static::provideUnsuccessfulResponses() as $testCase) {
yield [current($testCase), $endpoint, [$model]];
}
}
Expand All @@ -72,11 +86,18 @@ public function providePostEndpointsUnsuccessfulTestCases(): iterable
/**
* @return iterable<mixed>
*/
public function providePutEndpointsUnsuccessfulTestCases(): iterable
public static function providePutEndpointsUnsuccessfulTestCases(): iterable
{
foreach ($this->getPutEndpoints() as $endpoint => $value) {
$endpoints = static::getPutEndpoints();
if (empty($endpoints)) {
yield [null, null, null];

return;
}

foreach ($endpoints as $endpoint => $value) {
[$model, $data] = $value;
foreach ($this->provideUnsuccessfulResponses() as $testCase) {
foreach (static::provideUnsuccessfulResponses() as $testCase) {
yield [current($testCase), $endpoint, [$model, $data]];
}
}
Expand All @@ -85,9 +106,16 @@ public function providePutEndpointsUnsuccessfulTestCases(): iterable
/**
* @return iterable<mixed>
*/
public function provideApiClientPutEndpointsTestCases(): iterable
public static function provideApiClientPutEndpointsTestCases(): iterable
{
foreach ($this->getPutEndpoints() as $endpoint => $value) {
$endpoints = static::getPutEndpoints();
if (empty($endpoints)) {
yield [null, null, null];

return;
}

foreach ($endpoints as $endpoint => $value) {
[$data, $response] = $value;

yield [$data, $response, $endpoint];
Expand All @@ -97,10 +125,10 @@ public function provideApiClientPutEndpointsTestCases(): iterable
/**
* @return iterable<mixed>
*/
public function provideDeleteEndpointsUnsuccessfulTestCases(): iterable
public static function provideDeleteEndpointsUnsuccessfulTestCases(): iterable
{
foreach ($this->getDeleteEndpoints() as $endpoint => $id) {
foreach ($this->provideUnsuccessfulResponses() as $testCase) {
foreach (static::getDeleteEndpoints() as $endpoint => $id) {
foreach (static::provideUnsuccessfulResponses() as $testCase) {
yield [current($testCase), $endpoint, [$id]];
}
}
Expand All @@ -109,30 +137,44 @@ public function provideDeleteEndpointsUnsuccessfulTestCases(): iterable
/**
* @return iterable<mixed>
*/
public function provideDeleteEndpointsTestCases(): iterable
public static function provideDeleteEndpointsTestCases(): iterable
{
foreach ($this->getDeleteEndpoints() as $endpoint => $id) {
foreach (static::getDeleteEndpoints() as $endpoint => $id) {
yield [$id, $endpoint];
}
}

/**
* @return iterable<mixed>
*/
public function provideDownloadEndpointsTestCases(): iterable
public static function provideDownloadEndpointsTestCases(): iterable
{
foreach ($this->getDownloadsEndpoints() as $endpoint => $model) {
$endpoints = static::getDownloadsEndpoints();
if (empty($endpoints)) {
yield [null, null];

return;
}

foreach ($endpoints as $endpoint => $model) {
yield [$model, $endpoint];
}
}

/**
* @return iterable<mixed>
*/
public function provideDownloadUnsuccessfulTestCases(): iterable
public static function provideDownloadUnsuccessfulTestCases(): iterable
{
foreach ($this->getDownloadsEndpoints() as $endpoint => $model) {
foreach ($this->provideUnsuccessfulResponses() as $testCase) {
$endpoints = static::getDownloadsEndpoints();
if (empty($endpoints)) {
yield [null, null, null];

return;
}

foreach ($endpoints as $endpoint => $model) {
foreach (static::provideUnsuccessfulResponses() as $testCase) {
yield [current($testCase), $endpoint, [$model]];
}
}
Expand All @@ -141,30 +183,30 @@ public function provideDownloadUnsuccessfulTestCases(): iterable
/**
* @return array<mixed>
*/
abstract protected function getGetEndpoints(): array;
abstract protected static function getGetEndpoints(): array;

/**
* @return array<mixed>
*/
abstract protected function getPostEndpoints(): array;
abstract protected static function getPostEndpoints(): array;

/**
* @return array<mixed>
*/
abstract protected function getPutEndpoints(): array;
abstract protected static function getPutEndpoints(): array;

/**
* @return array<mixed>
*/
abstract protected function getDeleteEndpoints(): array;
abstract protected static function getDeleteEndpoints(): array;

/**
* @return array<mixed>
*/
abstract protected function getDownloadsEndpoints(): array;
abstract protected static function getDownloadsEndpoints(): array;

/**
* @return iterable<mixed>
*/
abstract protected function provideUnsuccessfulResponses(): iterable;
abstract protected static function provideUnsuccessfulResponses(): iterable;
}
Loading
Loading