mirror of
https://github.com/Neur0toxine/pock.git
synced 2025-04-20 01:10:57 +00:00
Compare commits
No commits in common. "master" and "v0.12.0" have entirely different histories.
11 changed files with 40 additions and 135 deletions
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
@ -14,7 +14,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
|
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code into the workspace
|
- name: Check out code into the workspace
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||

|

|
||||||
[](https://codecov.io/gh/Neur0toxine/pock)
|
[](https://codecov.io/gh/Neur0toxine/pock)
|
||||||
[](https://packagist.org/packages/neur0toxine/pock)
|
[](https://packagist.org/packages/neur0toxine/pock)
|
||||||
[](https://packagist.org/packages/neur0toxine/pock)
|
[](https://packagist.org/packages/neur0toxine/pock)
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
"php": ">=7.2.0",
|
"php": ">=7.2.0",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"psr/http-client": "^1.0",
|
"psr/http-client": "^1.0",
|
||||||
"psr/http-message": "^1.0 || ^2.0",
|
"psr/http-message": "^1.0",
|
||||||
"php-http/httplug": "^1.0 || ^2.0",
|
"php-http/httplug": "^1.0 || ^2.0",
|
||||||
"nyholm/psr7": "^1.4",
|
"nyholm/psr7": "^1.4",
|
||||||
"riverline/multipart-parser": "^2.0"
|
"riverline/multipart-parser": "^2.0"
|
||||||
|
@ -76,8 +76,7 @@
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||||
"php-http/discovery": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,11 @@ parameters:
|
||||||
count: 1
|
count: 1
|
||||||
path: src/Client.php
|
path: src/Client.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Method Pock\\\\Comparator\\\\ComparatorLocator\\:\\:get\\(\\) should return Pock\\\\Comparator\\\\ComparatorInterface but returns object\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Comparator/ComparatorLocator.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Static property Pock\\\\Comparator\\\\ComparatorLocator\\:\\:\\$comparators \\(array\\<Pock\\\\Comparator\\\\ComparatorInterface\\>\\) does not accept array\\<object\\>\\.$#"
|
message: "#^Static property Pock\\\\Comparator\\\\ComparatorLocator\\:\\:\\$comparators \\(array\\<Pock\\\\Comparator\\\\ComparatorInterface\\>\\) does not accept array\\<object\\>\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
@ -15,6 +20,21 @@ parameters:
|
||||||
count: 3
|
count: 3
|
||||||
path: src/Comparator/ComparatorLocator.php
|
path: src/Comparator/ComparatorLocator.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$object_or_class of function method_exists expects object\\|string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Creator/AbstractJmsSerializerCreator.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$encoders of class Symfony\\\\Component\\\\Serializer\\\\Serializer constructor expects array\\<Symfony\\\\Component\\\\Serializer\\\\Encoder\\\\DecoderInterface\\|Symfony\\\\Component\\\\Serializer\\\\Encoder\\\\EncoderInterface\\>, array\\<int, object\\> given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Creator/AbstractSymfonySerializerCreator.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Method Pock\\\\Factory\\\\CallbackReplyFactory\\:\\:createReply\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Factory/CallbackReplyFactory.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Unsafe access to private property Pock\\\\Factory\\\\JsonSerializerFactory\\:\\:\\$mainSerializer through static\\:\\:\\.$#"
|
message: "#^Unsafe access to private property Pock\\\\Factory\\\\JsonSerializerFactory\\:\\:\\$mainSerializer through static\\:\\:\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
|
@ -26,9 +46,9 @@ parameters:
|
||||||
path: src/Factory/XmlSerializerFactory.php
|
path: src/Factory/XmlSerializerFactory.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#4 \\$flags of function preg_match expects TFlags of 0\\|256\\|512\\|768, int given\\.$#"
|
message: "#^Method Pock\\\\Matchers\\\\CallbackRequestMatcher\\:\\:matches\\(\\) should return bool but returns mixed\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
path: src/Matchers/AbstractRegExpMatcher.php
|
path: src/Matchers/CallbackRequestMatcher.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Unsafe call to private method Pock\\\\Matchers\\\\ExactHeadersMatcher\\:\\:headerValuesEqual\\(\\) through static\\:\\:\\.$#"
|
message: "#^Unsafe call to private method Pock\\\\Matchers\\\\ExactHeadersMatcher\\:\\:headerValuesEqual\\(\\) through static\\:\\:\\.$#"
|
||||||
|
@ -46,9 +66,9 @@ parameters:
|
||||||
path: src/Matchers/JsonBodyMatcher.php
|
path: src/Matchers/JsonBodyMatcher.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method Pock\\\\Matchers\\\\QueryMatcher\\:\\:parseQuery\\(\\) should return array\\<string, mixed\\> but returns array\\<int\\|string, array\\|string\\>\\.$#"
|
message: "#^Method Pock\\\\Matchers\\\\MultipartFormDataMatcher\\:\\:matches\\(\\) should return bool but returns mixed\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
path: src/Matchers/QueryMatcher.php
|
path: src/Matchers/MultipartFormDataMatcher.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method Pock\\\\Matchers\\\\XmlBodyMatcher\\:\\:sortXmlTags\\(\\) should return string but returns string\\|null\\.$#"
|
message: "#^Method Pock\\\\Matchers\\\\XmlBodyMatcher\\:\\:sortXmlTags\\(\\) should return string but returns string\\|null\\.$#"
|
||||||
|
@ -109,3 +129,4 @@ parameters:
|
||||||
message: "#^Parameter \\#3 \\$depth of function json_encode expects int\\<1, max\\>, int given\\.$#"
|
message: "#^Parameter \\#3 \\$depth of function json_encode expects int\\<1, max\\>, int given\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
path: src/PockResponseBuilder.php
|
path: src/PockResponseBuilder.php
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,8 @@ class RecursiveArrayComparator implements ComparatorInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($first as $key => $value) {
|
foreach ($first as $key => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value) && !self::recursiveCompareArrays($value, $second[$key])) {
|
||||||
if (!is_array($second[$key]) || !self::recursiveCompareArrays($value, $second[$key])) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value !== $second[$key]) {
|
if ($value !== $second[$key]) {
|
||||||
|
|
|
@ -47,12 +47,11 @@ class RecursiveLtrArrayComparator extends RecursiveArrayComparator
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($needle as $key => $value) {
|
foreach ($needle as $key => $value) {
|
||||||
if (is_array($value)) {
|
if (
|
||||||
if (!is_array($haystack[$key]) || !self::recursiveCompareArrays($value, $haystack[$key])) {
|
is_array($value) &&
|
||||||
return false;
|
(!is_array($haystack[$key]) || !self::recursiveCompareArrays($value, $haystack[$key]))
|
||||||
}
|
) {
|
||||||
|
return false;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value !== $haystack[$key]) {
|
if ($value !== $haystack[$key]) {
|
||||||
|
|
|
@ -30,12 +30,12 @@ abstract class AbstractJmsSerializerCreator implements SerializerCreatorInterfac
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
class_exists(self::BUILDER_CLASS) &&
|
class_exists(self::BUILDER_CLASS) &&
|
||||||
method_exists(self::BUILDER_CLASS, 'create') // @phpstan-ignore-line
|
method_exists(self::BUILDER_CLASS, 'create')
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
$builder = call_user_func([self::BUILDER_CLASS, 'create']); // @phpstan-ignore-line
|
$builder = call_user_func([self::BUILDER_CLASS, 'create']);
|
||||||
|
|
||||||
if (null !== $builder && method_exists($builder, 'build')) { // @phpstan-ignore-line
|
if (null !== $builder && method_exists($builder, 'build')) {
|
||||||
return new JmsSerializerAdapter($builder->build(), static::getFormat()); // @phpstan-ignore-line
|
return new JmsSerializerAdapter($builder->build(), static::getFormat()); // @phpstan-ignore-line
|
||||||
}
|
}
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ abstract class AbstractSymfonySerializerCreator implements SerializerCreatorInte
|
||||||
$encoder = static::getEncoderClass();
|
$encoder = static::getEncoderClass();
|
||||||
|
|
||||||
return new SymfonySerializerAdapter(
|
return new SymfonySerializerAdapter(
|
||||||
new $serializer([new $normalizer()], [new $encoder()]), // @phpstan-ignore-line
|
new $serializer([new $normalizer()], [new $encoder()]),
|
||||||
static::getFormat()
|
static::getFormat()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,5 @@ class BodyMatcher implements RequestMatcherInterface
|
||||||
if (is_resource($contents)) {
|
if (is_resource($contents)) {
|
||||||
return static::readAllResource($contents);
|
return static::readAllResource($contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHP version 7.3
|
|
||||||
*
|
|
||||||
* @category RecursiveArrayComparatorTest
|
|
||||||
* @package Pock\Tests\Comparator
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Pock\Tests\Comparator;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Pock\Comparator\ComparatorLocator;
|
|
||||||
use Pock\Comparator\RecursiveArrayComparator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class RecursiveArrayComparatorTest
|
|
||||||
*
|
|
||||||
* @category RecursiveArrayComparatorTest
|
|
||||||
* @package Pock\Tests\Comparator
|
|
||||||
*/
|
|
||||||
class RecursiveArrayComparatorTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testMatches(): void
|
|
||||||
{
|
|
||||||
$needle = [
|
|
||||||
'filter' => [
|
|
||||||
'createdAtFrom' => '2020-01-01 00:00:00',
|
|
||||||
'createdAtTo' => '2021-08-01 00:00:00',
|
|
||||||
],
|
|
||||||
'test' => ''
|
|
||||||
];
|
|
||||||
$haystack = [
|
|
||||||
'filter' => [
|
|
||||||
'createdAtFrom' => '2020-01-01 00:00:00',
|
|
||||||
'createdAtTo' => '2021-08-01 00:00:00',
|
|
||||||
],
|
|
||||||
'test' => ''
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertTrue(ComparatorLocator::get(RecursiveArrayComparator::class)->compare($needle, $haystack));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNotMatches(): void
|
|
||||||
{
|
|
||||||
$needle = [
|
|
||||||
'filter' => [
|
|
||||||
'createdAtFrom' => '2020-01-01 00:00:00',
|
|
||||||
'createdAtTo' => '2021-08-01 00:00:00',
|
|
||||||
],
|
|
||||||
'test2' => [1]
|
|
||||||
];
|
|
||||||
$haystack = [
|
|
||||||
'filter' => [
|
|
||||||
'createdAtFrom' => '2020-01-01 00:00:00',
|
|
||||||
'createdAtTo' => '2021-08-01 00:00:00',
|
|
||||||
],
|
|
||||||
'test2' => 1
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertFalse(ComparatorLocator::get(RecursiveArrayComparator::class)->compare($needle, $haystack));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNotMatchesKeyPositions(): void
|
|
||||||
{
|
|
||||||
$needle = [
|
|
||||||
'source' => json_decode('{"medium":"tiktok","source":"Test Ad","campaign":"Test Campaign"}', true)
|
|
||||||
];
|
|
||||||
$haystack = [
|
|
||||||
'source' => json_decode('{"source":"Test Ad","medium":"tiktok","campaign":"Test Campaign"}', true)
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertTrue(ComparatorLocator::get(RecursiveArrayComparator::class)->compare($needle, $haystack));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -39,37 +39,4 @@ class RecursiveArrayLtrComparatorTest extends TestCase
|
||||||
|
|
||||||
self::assertTrue(ComparatorLocator::get(RecursiveLtrArrayComparator::class)->compare($needle, $haystack));
|
self::assertTrue(ComparatorLocator::get(RecursiveLtrArrayComparator::class)->compare($needle, $haystack));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNotMatches(): void
|
|
||||||
{
|
|
||||||
$needle = [
|
|
||||||
'filter' => [
|
|
||||||
'createdAtFrom' => '2020-01-01 00:00:00',
|
|
||||||
'createdAtTo' => '2021-08-01 00:00:00',
|
|
||||||
],
|
|
||||||
'test2' => [1]
|
|
||||||
];
|
|
||||||
$haystack = [
|
|
||||||
'filter' => [
|
|
||||||
'createdAtFrom' => '2020-01-01 00:00:00',
|
|
||||||
'createdAtTo' => '2021-08-01 00:00:00',
|
|
||||||
],
|
|
||||||
'test2' => 1,
|
|
||||||
'test' => ''
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertFalse(ComparatorLocator::get(RecursiveLtrArrayComparator::class)->compare($needle, $haystack));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNotMatchesKeyPositions(): void
|
|
||||||
{
|
|
||||||
$needle = [
|
|
||||||
'source' => json_decode('{"medium":"tiktok","source":"Test Ad","campaign":"Test Campaign"}', true)
|
|
||||||
];
|
|
||||||
$haystack = [
|
|
||||||
'source' => json_decode('{"source":"Test Ad","medium":"tiktok","campaign":"Test Campaign"}', true)
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertTrue(ComparatorLocator::get(RecursiveLtrArrayComparator::class)->compare($needle, $haystack));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue