Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema validation does not work with %xx sequences in path to phpunit.xsd #4572

Closed
veugenio opened this issue Dec 31, 2020 · 0 comments · Fixed by multitheftauto/mtasa-php-sdk#88
Assignees
Labels
feature/test-runner CLI test runner type/bug Something is broken

Comments

@veugenio
Copy link

veugenio commented Dec 31, 2020

Q A
PHPUnit version 9.5.0
PHP version 7.4.13
Installation Method Composer

Summary

PHPUnit returns "Warning - The configuration file did not pass validation!" when running inside a directory containing a %xx sequence as name.

Apparently this is related to this bug https://bugs.php.net/bug.php?id=55374 and if you change this code, it works as expected:
vendor/phpunit/phpunit/src/Util/Xml/Validator.php:26

// $document->schemaValidate($xsdFilename);
$document->schemaValidateSource(file_get_contents($xsdFilename));

Composer info:

doctrine/instantiator              1.4.0   A small, lightweight utility to instantiate objects in PHP without...
myclabs/deep-copy                  1.10.2  Create deep copies (clones) of your objects
nikic/php-parser                   v4.10.4 A PHP parser written in PHP
phar-io/manifest                   2.0.1   Component for reading phar.io manifest information from a PHP Arch...
phar-io/version                    3.0.4   Library for handling version information and constraints
phpdocumentor/reflection-common    2.2.0   Common reflection classes used by phpdocumentor to reflect the cod...
phpdocumentor/reflection-docblock  5.2.2   With this component, a library can provide support for annotations...
phpdocumentor/type-resolver        1.4.0   A PSR-5 based resolver of Class names, Types and Structural Elemen...
phpspec/prophecy                   1.12.2  Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          9.2.5   Library that provides collection, processing, and rendering functi...
phpunit/php-file-iterator          3.0.5   FilterIterator implementation that filters files based on a list o...
phpunit/php-invoker                3.1.1   Invoke callables with a timeout
phpunit/php-text-template          2.0.4   Simple template engine.
phpunit/php-timer                  5.0.3   Utility class for timing
phpunit/phpunit                    9.5.0   The PHP Unit Testing framework.
sebastian/cli-parser               1.0.1   Library for parsing CLI options
sebastian/code-unit                1.0.8   Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.3   Looks up which function or method a line of code belongs to
sebastian/comparator               4.0.6   Provides the functionality to compare PHP values for equality
sebastian/complexity               2.0.2   Library for calculating the complexity of PHP code units
sebastian/diff                     4.0.4   Diff implementation
sebastian/environment              5.1.3   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 4.0.3   Provides the functionality to export PHP variables for visualization
sebastian/global-state             5.0.2   Snapshotting of global state
sebastian/lines-of-code            1.0.3   Library for counting the lines of code in PHP source code
sebastian/object-enumerator        4.0.4   Traverses array structures and object graphs to enumerate all refe...
sebastian/object-reflector         2.0.4   Allows reflection of object attributes, including inherited and no...
sebastian/recursion-context        4.0.4   Provides functionality to recursively process PHP variables
sebastian/resource-operations      3.0.3   Provides a list of PHP built-in functions that operate on resources
sebastian/type                     2.3.1   Collection of value objects that represent the types of the PHP ty...
sebastian/version                  3.0.2   Library that helps with managing the version number of Git-hosted ...
symfony/polyfill-ctype             v1.20.0 Symfony polyfill for ctype functions
theseer/tokenizer                  1.2.0   A small library for converting tokenized PHP source code into XML ...
webmozart/assert                   1.9.1   Assertions to validate method input/output with nice error messages.

Current behavior

When running vendor/bin/phpunit we have this:

PHP Warning:  DOMDocument::schemaValidate(): Invalid Schema in /var/www/a%25/vendor/phpunit/phpunit/src/Util/Xml/Validator.php on line 26

  Warning - The configuration file did not pass validation!
  The following problems have been detected:

  Line 0:
  - failed to load external entity "/var/www/a%25/vendor/phpunit/phpunit/phpunit.xsd"
  - Failed to locate the main schema resource at '/var/www/a%25/vendor/phpunit/phpunit/phpunit.xsd'.

  Test results may not be as expected.

How to reproduce

  • Create a directory called a%25 (or another name with the same pattern);
  • Init a new composer project inside this directory that requires PHPUnit;
  • Create a basic phpunit.xml;
  • Run vendor/bin/phpunit;

Expected behavior

Run without warnings:

PHPUnit 9.5.0 by Sebastian Bergmann and contributors.

No tests executed!
@veugenio veugenio added the type/bug Something is broken label Dec 31, 2020
@sebastianbergmann sebastianbergmann self-assigned this Jan 1, 2021
@sebastianbergmann sebastianbergmann added the feature/test-runner CLI test runner label Jan 1, 2021
@sebastianbergmann sebastianbergmann changed the title DOMDocument::schemaValidate(): Invalid Schema DOMDocument::schemaValidateSource() should be used instead of DOMDocument::schemaValidate() Jan 1, 2021
@sebastianbergmann sebastianbergmann changed the title DOMDocument::schemaValidateSource() should be used instead of DOMDocument::schemaValidate() Schema validation does not work with %xx sequences in path to phpunit.xsd Jan 1, 2021
This was referenced Mar 12, 2021
This was referenced Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-runner CLI test runner type/bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants