diff --git a/composer.json b/composer.json index d779b56..e7ec39e 100644 --- a/composer.json +++ b/composer.json @@ -73,5 +73,10 @@ "@lint", "@phpunit" ] + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/src/Matchers/FormDataMatcher.php b/src/Matchers/FormDataMatcher.php index ebddaa8..14cd2e6 100644 --- a/src/Matchers/FormDataMatcher.php +++ b/src/Matchers/FormDataMatcher.php @@ -10,7 +10,7 @@ namespace Pock\Matchers; use Pock\Comparator\ComparatorLocator; -use Pock\Comparator\RecursiveLtrArrayComparator; +use Pock\Comparator\RecursiveArrayComparator; use Pock\Traits\SeekableStreamDataExtractor; use Psr\Http\Message\RequestInterface; @@ -35,6 +35,6 @@ class FormDataMatcher extends QueryMatcher return false; } - return ComparatorLocator::get(RecursiveLtrArrayComparator::class)->compare($this->query, $query); + return ComparatorLocator::get(RecursiveArrayComparator::class)->compare($this->query, $query); } } diff --git a/tests/src/Matchers/FormDataMatcherTest.php b/tests/src/Matchers/FormDataMatcherTest.php index d20e486..ca7bfe9 100644 --- a/tests/src/Matchers/FormDataMatcherTest.php +++ b/tests/src/Matchers/FormDataMatcherTest.php @@ -44,11 +44,19 @@ class FormDataMatcherTest extends PockTestCase self::assertFalse($matcher->matches($request)); } - public function testMatches(): void + public function testNoMatchesExtraValues(): void { $matcher = new FormDataMatcher(['field2' => 'value2']); $request = self::getRequestWithBody('field1=value1&field2=value2'); + self::assertFalse($matcher->matches($request)); + } + + public function testMatches(): void + { + $matcher = new FormDataMatcher(['field1' => 'value1', 'field2' => 'value2']); + $request = self::getRequestWithBody('field1=value1&field2=value2'); + self::assertTrue($matcher->matches($request)); } } diff --git a/tests/src/PockBuilderTest.php b/tests/src/PockBuilderTest.php index fde2d04..1051749 100644 --- a/tests/src/PockBuilderTest.php +++ b/tests/src/PockBuilderTest.php @@ -681,7 +681,7 @@ EOF; $builder = new PockBuilder(); $builder->matchMethod(RequestMethod::GET) ->matchUri(self::TEST_URI) - ->matchFormData(['field2' => 'value2']) + ->matchFormData(['field1' => 'value1', 'field2' => 'value2']) ->reply(200); $response = $builder->getClient()->sendRequest(self::getRequestWithBody('field1=value1&field2=value2'));