mirror of
https://github.com/Neur0toxine/pock.git
synced 2024-12-01 01:16:07 +03:00
fix form-data matcher logic
This commit is contained in:
parent
5a92b28b5f
commit
f455ba52d5
@ -73,5 +73,10 @@
|
||||
"@lint",
|
||||
"@phpunit"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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'));
|
||||
|
Loading…
Reference in New Issue
Block a user