lchrusciel / ApiTestCase

Handy PHPUnit test case for testing JSON APIs in your Symfony applications.
MIT License
410 stars 35 forks source link

coduo/php-matcher 3.0 and "@string@.isDateTime()" #115

Closed emodric closed 6 years ago

emodric commented 6 years ago

With ATC 3.0 final, using coduo/php-matcher 3.0 and @string@.isDateTime() pattern match results in an error, while everything works as expected with ATC 3.0 and PHP Matcher 2.4.

TypeError: Argument 1 passed to Coduo\PHPMatcher\Parser::unexpectedSyntaxError() must be of the type array, null given, called in vendor/coduo/php-matcher/src/Parser.php on line 62

vendor/coduo/php-matcher/src/Parser.php:248
vendor/coduo/php-matcher/src/Parser.php:62
vendor/coduo/php-matcher/src/Parser.php:50
vendor/coduo/php-matcher/src/Parser.php:29
vendor/coduo/php-matcher/src/Matcher/StringMatcher.php:43
vendor/coduo/php-matcher/src/Matcher/ChainMatcher.php:32
vendor/coduo/php-matcher/src/Matcher/ChainMatcher.php:33
vendor/coduo/php-matcher/src/Matcher/ArrayMatcher.php:165
vendor/coduo/php-matcher/src/Matcher/ArrayMatcher.php:88
vendor/coduo/php-matcher/src/Matcher/ArrayMatcher.php:46
vendor/coduo/php-matcher/src/Matcher/ChainMatcher.php:33
vendor/coduo/php-matcher/src/Matcher/JsonMatcher.php:35
vendor/coduo/php-matcher/src/Matcher/ChainMatcher.php:33
vendor/coduo/php-matcher/src/Matcher.php:20
vendor/lakion/api-test-case/src/ApiTestCase.php:206
vendor/lakion/api-test-case/src/JsonApiTestCase.php:80
vendor/lakion/api-test-case/src/JsonApiTestCase.php:59

I'm not sure if this is an issue with PHP Matcher lib or ATC not supporting PHP Matcher 3.0 correctly.

emodric commented 6 years ago

This test script using PHP Matcher 3.0 works fine, so it looks like this is an issue with ATC 3.0 and PHP Matcher 3.0.

<?php

require 'vendor/autoload.php';

use Coduo\PHPMatcher\Factory\SimpleFactory;

$factory = new SimpleFactory();
$matcher = $factory->createMatcher();

$match = $matcher->match('{"key": "2018-03-15T00:00:00Z"}', '{"key": "@string@.isDateTime()"}');
// $match === true

Ping @pamil

emodric commented 6 years ago

Okay, seems like an issue in PHP Matcher 3.0 after all: https://github.com/coduo/php-matcher/issues/124

lchrusciel commented 6 years ago

Best kind of bug ever! Thank Edi anyway for reporting ;)