mirror of
https://github.com/Neur0toxine/pock.git
synced 2024-12-01 01:16:07 +03:00
ugly hack for tests
This commit is contained in:
parent
b99fb4f255
commit
e7a17599ad
1
.github/workflows/tests.yml
vendored
1
.github/workflows/tests.yml
vendored
@ -23,7 +23,6 @@ jobs:
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
coverage: pcov
|
||||
extensions: uopz
|
||||
- name: Composer cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
|
@ -44,6 +44,9 @@ class XmlBodyMatcher extends BodyMatcher
|
||||
</xsl:stylesheet>
|
||||
EOT;
|
||||
|
||||
/** @var bool */
|
||||
public static $forceTextComparison = false;
|
||||
|
||||
/** @var XSLTProcessor|null */
|
||||
private static $sorter;
|
||||
|
||||
@ -59,14 +62,14 @@ EOT;
|
||||
*/
|
||||
public function __construct($referenceXml)
|
||||
{
|
||||
if (!extension_loaded('xsl') || !extension_loaded('dom')) {
|
||||
if (!static::hasExtension('xsl') || !static::hasExtension('dom')) {
|
||||
$this->useFallback = true;
|
||||
}
|
||||
|
||||
if (!extension_loaded('xsl')) {
|
||||
if (!static::hasExtension('xsl')) {
|
||||
$this->useFallback = true;
|
||||
|
||||
if (extension_loaded('dom') && $referenceXml instanceof DOMDocument) {
|
||||
if (static::hasExtension('dom') && $referenceXml instanceof DOMDocument) {
|
||||
$referenceXml = static::getDOMString($referenceXml);
|
||||
}
|
||||
|
||||
@ -190,4 +193,18 @@ EOT;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $extension
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function hasExtension(string $extension): bool
|
||||
{
|
||||
if (static::$forceTextComparison && 'xsl' === $extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return extension_loaded($extension);
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,10 @@
|
||||
namespace Pock\Tests;
|
||||
|
||||
use DOMDocument;
|
||||
use phpmock\Mock;
|
||||
use phpmock\MockBuilder;
|
||||
use phpmock\MockRegistry;
|
||||
use Pock\Enum\RequestMethod;
|
||||
use Pock\Enum\RequestScheme;
|
||||
use Pock\Exception\UnsupportedRequestException;
|
||||
use Pock\Matchers\XmlBodyMatcher;
|
||||
use Pock\PockBuilder;
|
||||
use Pock\PockResponseBuilder;
|
||||
use Pock\TestUtils\PockTestCase;
|
||||
@ -35,9 +33,9 @@ use RuntimeException;
|
||||
*/
|
||||
class PockBuilderTest extends PockTestCase
|
||||
{
|
||||
protected function tearDown(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
uopz_unset_return('extension_loaded');
|
||||
XmlBodyMatcher::$forceTextComparison = false;
|
||||
}
|
||||
|
||||
public function testNoHit(): void
|
||||
@ -463,17 +461,7 @@ EOF;
|
||||
$document = new DOMDocument();
|
||||
$document->loadXML($simpleObject);
|
||||
|
||||
uopz_set_return(
|
||||
'extension_loaded',
|
||||
function (string $extension) {
|
||||
if ('xsl' === $extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
true
|
||||
);
|
||||
XmlBodyMatcher::$forceTextComparison = true;
|
||||
|
||||
$builder = new PockBuilder();
|
||||
$builder->matchMethod(RequestMethod::GET)
|
||||
|
Loading…
Reference in New Issue
Block a user