{"action":"opened","issue":{"url":"https://api.github.com/repos/Codeception/Codeception/issues/5320","repository_url":"https://api.github.com/repos/Codeception/Codeception","labels_url":"https://api.github.com/repos/Codeception/Codeception/issues/5320/labels{/name}","comments_url":"https://api.github.com/repos/Codeception/Codeception/issues/5320/comments","events_url":"https://api.github.com/repos/Codeception/Codeception/issues/5320/events","html_url":"https://github.com/Codeception/Codeception/issues/5320","id":395242353,"node_id":"MDU6SXNzdWUzOTUyNDIzNTM=","number":5320,"title":"JsonType - Alternative filters after a string:regex are dropped","user":{"login":"Tenzian","id":13963952,"node_id":"MDQ6VXNlcjEzOTYzOTUy","avatar_url":"https://avatars1.githubusercontent.com/u/13963952?v=4","gravatar_id":"","url":"https://api.github.com/users/Tenzian","html_url":"https://github.com/Tenzian","followers_url":"https://api.github.com/users/Tenzian/followers","following_url":"https://api.github.com/users/Tenzian/following{/other_user}","gists_url":"https://api.github.com/users/Tenzian/gists{/gist_id}","starred_url":"https://api.github.com/users/Tenzian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tenzian/subscriptions","organizations_url":"https://api.github.com/users/Tenzian/orgs","repos_url":"https://api.github.com/users/Tenzian/repos","events_url":"https://api.github.com/users/Tenzian/events{/privacy}","received_events_url":"https://api.github.com/users/Tenzian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-01-02T13:05:39Z","updated_at":"2019-01-02T13:05:39Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"#### What are you trying to achieve?\r\n\r\nProvide alternative values for JSON Types by postfixing a type to `string:regex` i.e.\r\n\r\n- `string:regex(<pattern>)|null` \r\n\r\n#### What do you get instead?\r\n\r\nThis used to be fine, but fails to work since #5273 was merged.\r\n\r\nIt looks like the new filtering in https://github.com/ellisgl/Codeception/blob/be75ceb95f463f653cb111a60b12411dc7d161ba/src/Codeception/Util/JsonType.php#L133-L148 is causing postfixed options to be dropped.\r\n\r\n> Provide console output if related. Use `-vvv` mode for more details.\r\n\r\n```bash\r\n$ codecept run unit -vvv\r\nCodeception PHP Testing Framework v2.5.2\r\nPowered by PHPUnit 7.3.5 by Sebastian Bergmann and contributors.\r\nRunning with seed: \r\n\r\n\r\nUnit Tests (2) ------------------------------------------------------------------------------------------------------------------------------\r\nModules: CodeHelper, EmulateModuleHelper\r\n---------------------------------------------------------------------------------------------------------------------------------------------\r\n✔ JsonTypeTest: Regex filter with prefixed alternatives (0.00s)\r\n✖ JsonTypeTest: Regex filter with postfixed alternatives (0.00s)\r\n---------------------------------------------------------------------------------------------------------------------------------------------\r\n\r\n\r\nTime: 90 ms, Memory: 10.00MB\r\n\r\nThere was 1 failure:\r\n\r\n---------\r\n1) JsonTypeTest: Regex filter with postfixed alternatives\r\n Test  tests/unit/codeception/util/JsonTypeTest.php:testRegexFilterWithPostfixedAlternatives\r\nFailed asserting that '`test: NULL` is of type `string:regex(~^(\\d\\d@):\\d\\d$~)|null`' is true.\r\n/Users/tenz/Repositories/Codeception/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:112\r\n/Users/tenz/Repositories/Codeception/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:60\r\n/Users/tenz/Repositories/Codeception/vendor/phpunit/phpunit/src/Framework/Assert.php:1857\r\n/Users/tenz/Repositories/Codeception/vendor/phpunit/phpunit/src/Framework/Assert.php:1012\r\n/Users/tenz/Repositories/codeception-demo/tests/unit/codeception/util/JsonTypeTest.php:24\r\n/Users/tenz/Repositories/Codeception/vendor/phpunit/phpunit/src/Framework/TestCase.php:1150\r\n/Users/tenz/Repositories/Codeception/vendor/phpunit/phpunit/src/Framework/TestCase.php:844\r\n/Users/tenz/Repositories/Codeception/vendor/phpunit/phpunit/src/Framework/TestResult.php:665\r\n/Users/tenz/Repositories/Codeception/vendor/phpunit/phpunit/src/Framework/TestCase.php:798\r\n/Users/tenz/Repositories/Codeception/vendor/phpunit/phpunit/src/Framework/TestSuite.php:750\r\n/Users/tenz/Repositories/Codeception/vendor/codeception/phpunit-wrapper/src/Runner.php:117\r\n/Users/tenz/Repositories/Codeception/src/Codeception/SuiteManager.php:158\r\n/Users/tenz/Repositories/Codeception/src/Codeception/Codecept.php:192\r\n/Users/tenz/Repositories/Codeception/src/Codeception/Codecept.php:159\r\n/Users/tenz/Repositories/Codeception/src/Codeception/Command/Run.php:495\r\n/Users/tenz/Repositories/Codeception/src/Codeception/Command/Run.php:390\r\n/Users/tenz/Repositories/Codeception/vendor/symfony/console/Command/Command.php:255\r\n/Users/tenz/Repositories/Codeception/vendor/symfony/console/Application.php:886\r\n/Users/tenz/Repositories/Codeception/vendor/symfony/console/Application.php:262\r\n/Users/tenz/Repositories/Codeception/vendor/symfony/console/Application.php:145\r\n/Users/tenz/Repositories/Codeception/src/Codeception/Application.php:108\r\n/Users/tenz/Repositories/Codeception/codecept:43\r\n\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 5, Failures: 1.\r\n```\r\n> Provide test source code if related\r\n\r\n```php\r\n<?php\r\nnamespace Codeception\\Util;\r\n\r\nclass JsonTypeTest extends \\Codeception\\Test\\Unit\r\n{\r\n    // just showing additions to the existing unit test to save space\r\n\r\n    // working as expected\r\n    public function testRegexFilterWithPrefixedAlternatives()\r\n    {\r\n        $jsonType = new JsonType(['test' => null]);\r\n        $this->assertTrue($jsonType->matches(['test'    => 'null|string:regex(~^(\\d\\d@):\\d\\d$~)']));\r\n        $this->assertNotTrue($jsonType->matches(['test' => 'integer|string:regex(~^(\\d\\d@):\\d\\d$~)']));\r\n\r\n        $jsonType = new JsonType(['test' => 12345]);\r\n        $this->assertTrue($jsonType->matches(['test'    => 'integer|null|string:regex(~^(\\d\\d@):\\d\\d$~)']));\r\n    }\r\n\r\n    // not working as expected\r\n    public function testRegexFilterWithPostfixedAlternatives()\r\n    {\r\n        $jsonType = new JsonType(['test' => null]);\r\n        // currently produces a false positive\r\n        $this->assertNotTrue($jsonType->matches(['test' => 'string:regex(~^(\\d\\d@):\\d\\d$~)|integer']));\r\n        // currently produces a false negative\r\n        $this->assertTrue($jsonType->matches(['test'    => 'string:regex(~^(\\d\\d@):\\d\\d$~)|null']));\r\n\r\n        $jsonType = new JsonType(['test' => 12345]);\r\n        // currently produces a false negative\r\n        $this->assertTrue($jsonType->matches(['test'    => 'string:regex(~^(\\d\\d@):\\d\\d$~)|integer']));\r\n    }\r\n}\r\n```\r\n### Details\r\n\r\n* Codeception version: 2.5.2\r\n* PHP Version: \r\n```\r\nPHP 7.3.0 (cli) (built: Dec  7 2018 11:00:11) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies\r\n    with Zend OPcache v7.3.0, Copyright (c) 1999-2018, by Zend Technologies\r\n    with Xdebug v2.7.0beta1, Copyright (c) 2002-2018, by Derick Rethans\r\n```\r\n* Operating System: macOS 10.14.2\r\n* Installation type: Composer\r\n* List of installed packages (`composer show`)\r\n```\r\nbehat/gherkin                      v4.5.1 Gherkin DSL parser for PHP 5.3\r\ncodeception/phpunit-wrapper        7.3.2  PHPUnit classes used by Codeception\r\ncodeception/specify                0.4.6  BDD code blocks for PHPUnit and Codeception\r\ncodeception/stub                   2.0.4  Flexible Stub wrapper for PHPUnit's Mock Builder\r\ndoctrine/instantiator              1.1.0  A small, lightweight utility to instantiate objects in PHP without invoking their constructors\r\nfacebook/graph-sdk                 5.6.3  Facebook SDK for PHP\r\nfacebook/webdriver                 1.6.0  A PHP client for Selenium WebDriver\r\nflow/jsonpath                      0.4.0  JSONPath implementation for parsing, searching and flattening arrays\r\nguzzlehttp/guzzle                  6.3.3  Guzzle is a PHP HTTP client library\r\nguzzlehttp/promises                v1.3.1 Guzzle promises library\r\nguzzlehttp/psr7                    1.4.2  PSR-7 message implementation that also provides common utility methods\r\nmonolog/monolog                    1.23.0 Sends your logs to files, sockets, inboxes, databases and various web services\r\nmyclabs/deep-copy                  1.8.1  Create deep copies (clones) of your objects\r\npda/pheanstalk                     v3.2.1 PHP client for beanstalkd queue\r\nphar-io/manifest                   1.0.3  Component for reading phar.io manifest information from a PHP Archive (PHAR)\r\nphar-io/version                    2.0.1  Library for handling version information and constraints\r\nphp-amqplib/php-amqplib            v2.7.2 Formerly videlalvaro/php-amqplib.  This library is a pure PHP implementation of the AMQP pro...\r\nphpdocumentor/reflection-common    1.0.1  Common reflection classes used by phpdocumentor to reflect the code structure\r\nphpdocumentor/reflection-docblock  4.3.0  With this component, a library can provide support for annotations via DocBlocks or otherwis...\r\nphpdocumentor/type-resolver        0.4.0 \r\nphpspec/prophecy                   1.8.0  Highly opinionated mocking framework for PHP 5.3+\r\nphpunit/php-code-coverage          6.0.8  Library that provides collection, processing, and rendering functionality for PHP code cover...\r\nphpunit/php-file-iterator          2.0.2  FilterIterator implementation that filters files based on a list of suffixes.\r\nphpunit/php-text-template          1.2.1  Simple template engine.\r\nphpunit/php-timer                  2.0.0  Utility class for timing\r\nphpunit/php-token-stream           3.0.0  Wrapper around PHP's tokenizer extension.\r\nphpunit/phpunit                    7.3.5  The PHP Unit Testing framework.\r\npredis/predis                      v1.1.1 Flexible and feature-complete Redis client for PHP and HHVM\r\npsr/http-message                   1.0.1  Common interface for HTTP messages\r\npsr/log                            1.0.2  Common interface for logging libraries\r\nsebastian/code-unit-reverse-lookup 1.0.1  Looks up which function or method a line of code belongs to\r\nsebastian/comparator               3.0.2  Provides the functionality to compare PHP values for equality\r\nsebastian/diff                     3.0.1  Diff implementation\r\nsebastian/environment              3.1.0  Provides functionality to handle HHVM/PHP environments\r\nsebastian/exporter                 3.1.0  Provides the functionality to export PHP variables for visualization\r\nsebastian/global-state             2.0.0  Snapshotting of global state\r\nsebastian/object-enumerator        3.0.3  Traverses array structures and object graphs to enumerate all referenced objects\r\nsebastian/object-reflector         1.1.1  Allows reflection of object attributes, including inherited and non-public ones\r\nsebastian/recursion-context        3.0.0  Provides functionality to recursively process PHP variables\r\nsebastian/resource-operations      1.0.0  Provides a list of PHP built-in functions that operate on resources\r\nsebastian/version                  2.0.1  Library that helps with managing the version number of Git-hosted PHP projects\r\nsquizlabs/php_codesniffer          2.9.1  PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined ...\r\nsymfony/browser-kit                v4.1.6 Symfony BrowserKit Component\r\nsymfony/console                    v4.1.6 Symfony Console Component\r\nsymfony/css-selector               v4.1.6 Symfony CssSelector Component\r\nsymfony/dom-crawler                v4.1.6 Symfony DomCrawler Component\r\nsymfony/event-dispatcher           v4.1.6 Symfony EventDispatcher Component\r\nsymfony/finder                     v4.1.6 Symfony Finder Component\r\nsymfony/polyfill-ctype             v1.9.0 Symfony polyfill for ctype functions\r\nsymfony/polyfill-mbstring          v1.9.0 Symfony polyfill for the Mbstring extension\r\nsymfony/process                    v4.1.6 Symfony Process Component\r\nsymfony/yaml                       v4.1.6 Symfony Yaml Component\r\ntheseer/tokenizer                  1.1.0  A small library for converting tokenized PHP source code into XML and potentially other formats\r\nvlucas/phpdotenv                   v2.5.1 Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.\r\nwebmozart/assert                   1.3.0  Assertions to validate method input/output with nice error messages.\r\n```\r\n* Suite configuration:\r\n\r\n```yml\r\n# Codeception Test Suite Configuration\r\n\r\n# suite for unit (internal) tests.\r\nerror_level: \"E_ALL | E_STRICT\"\r\nclass_name: CodeGuy\r\nmodules:\r\n    enabled: [CodeHelper, EmulateModuleHelper]\r\n```\r\n"}}
{"actor":{"display_login":"Tenzian"}}