vendor directory
This commit is contained in:
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
charset = utf-8
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
|
||||
[tests/_files/*_result_cache.txt]
|
||||
insert_final_newline = false
|
||||
@@ -0,0 +1,6 @@
|
||||
/.docker export-ignore
|
||||
/build export-ignore
|
||||
/tools export-ignore
|
||||
|
||||
*.php diff=php
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
||||
|
||||
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery
|
||||
* Personal attacks
|
||||
* Trolling or insulting/derogatory comments
|
||||
* Public or private harassment
|
||||
* Publishing other's private information, such as physical or electronic
|
||||
addresses, without explicit permission
|
||||
* Other unethical or unprofessional conduct
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer at sebastian@phpunit.de. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.3.0, available at [https://contributor-covenant.org/version/1/3/0/][version]
|
||||
|
||||
[homepage]: https://contributor-covenant.org
|
||||
[version]: https://contributor-covenant.org/version/1/3/0/
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
# Contributing to PHPUnit
|
||||
|
||||
## Contributor Code of Conduct
|
||||
|
||||
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
||||
|
||||
## Workflow
|
||||
|
||||
* Fork the project.
|
||||
* Make your bug fix or feature addition.
|
||||
* Add tests for it. This is important so we don't break it in a future version unintentionally.
|
||||
* Send a pull request. Bonus points for topic branches.
|
||||
|
||||
Please make sure that you have [set up your user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` look really stupid in the commit history of a project.
|
||||
|
||||
Pull requests for bug fixes must be made for the oldest branch that is [supported](https://phpunit.de/supported-versions.html). Pull requests for new features must be based on the `master` branch.
|
||||
|
||||
We are trying to keep backwards compatibility breaks in PHPUnit to an absolute minimum. Please take this into account when proposing changes.
|
||||
|
||||
Due to time constraints, we are not always able to respond as quickly as we would like. Please do not take delays personal and feel free to remind us if you feel that we forgot to respond.
|
||||
|
||||
## Coding Guidelines
|
||||
|
||||
This project comes with a configuration file and an executable for [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) (`.php_cs`) that you can use to (re)format your source code for compliance with this project's coding guidelines:
|
||||
|
||||
```bash
|
||||
$ ./tools/php-cs-fixer fix
|
||||
```
|
||||
|
||||
## Using PHPUnit from a Git checkout
|
||||
|
||||
The following commands can be used to perform the initial checkout of PHPUnit:
|
||||
|
||||
```bash
|
||||
$ git clone git://github.com/sebastianbergmann/phpunit.git
|
||||
|
||||
$ cd phpunit
|
||||
```
|
||||
|
||||
Retrieve PHPUnit's dependencies using [Composer](https://getcomposer.org/):
|
||||
|
||||
```bash
|
||||
$ ./tools/composer install
|
||||
```
|
||||
|
||||
The `phpunit` script can be used to invoke the PHPUnit test runner:
|
||||
|
||||
```bash
|
||||
$ ./phpunit --version
|
||||
```
|
||||
|
||||
## Running PHPUnit's own test suite
|
||||
|
||||
After following the steps shown above, PHPUnit's own test suite is run like this:
|
||||
|
||||
```bash
|
||||
$ ./phpunit
|
||||
```
|
||||
|
||||
## Reporting issues
|
||||
|
||||
Please use the most specific issue tracker to search for existing tickets and to open new tickets:
|
||||
|
||||
* [General problems](https://github.com/sebastianbergmann/phpunit/issues)
|
||||
* [Code Coverage](https://github.com/sebastianbergmann/php-code-coverage/issues)
|
||||
* [Documentation](https://github.com/sebastianbergmann/phpunit-documentation-english/issues)
|
||||
* [Website](https://github.com/sebastianbergmann/phpunit-website/issues)
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
patreon: s_bergmann
|
||||
custom: https://phpunit.de/donate.html
|
||||
@@ -0,0 +1,15 @@
|
||||
| Q | A
|
||||
| --------------------| ---------------
|
||||
| PHPUnit version | x.y.z
|
||||
| PHP version | x.y.z
|
||||
| Installation Method | Composer / PHAR
|
||||
|
||||
<!--
|
||||
- Please fill in this template according to your issue.
|
||||
- Please keep the table shown above at the top of your issue.
|
||||
- Please include the output of "composer info | sort" if you installed PHPUnit using Composer.
|
||||
- Please post code as text (using proper markup). Do not post screenshots of code.
|
||||
- Visit https://phpunit.de/support.html if you are looking for support.
|
||||
- Otherwise, replace this comment by the description of your issue.
|
||||
-->
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
name: CI
|
||||
|
||||
jobs:
|
||||
coding-guidelines:
|
||||
name: Coding Guidelines
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Run friendsofphp/php-cs-fixer
|
||||
run: php7.3 ./tools/php-cs-fixer fix --diff-format=udiff --dry-run --show-progress=dots --using-cache=no --verbose
|
||||
|
||||
type-checker:
|
||||
name: Type Checker
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Update dependencies with composer
|
||||
run: php7.3 ./tools/composer update --no-interaction --no-ansi --no-progress --no-suggest
|
||||
|
||||
- name: Run vimeo/psalm on public API
|
||||
run: php7.3 ./tools/psalm --config=.psalm/static-analysis.xml --no-progress --show-info=false
|
||||
|
||||
- name: Run vimeo/psalm on internal code
|
||||
run: php7.3 ./tools/psalm --config=.psalm/config.xml --no-progress --shepherd --show-info=false --stats
|
||||
|
||||
backward-compatibility:
|
||||
name: Backward Compatibility
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Run roave/backward-compatibility-check
|
||||
run: php7.3 ./tools/roave-backward-compatibility-check --from=8.3.3
|
||||
@@ -0,0 +1,21 @@
|
||||
/.ant_targets
|
||||
/.idea
|
||||
/.php_cs
|
||||
/.php_cs.cache
|
||||
/build/documentation
|
||||
/build/logfiles
|
||||
/build/phar
|
||||
/build/phar-scoped
|
||||
/build/phpdox
|
||||
/build/*.phar
|
||||
/build/*.phar.asc
|
||||
/build/binary-phar-autoload.php
|
||||
/cache.properties
|
||||
/composer.lock
|
||||
/tests/end-to-end/*.diff
|
||||
/tests/end-to-end/*.exp
|
||||
/tests/end-to-end/*.log
|
||||
/tests/end-to-end/*.out
|
||||
/tests/end-to-end/*.php
|
||||
/vendor
|
||||
.phpunit.result.cache
|
||||
Vendored
+207
@@ -0,0 +1,207 @@
|
||||
<?php declare(strict_types=1);
|
||||
$header = <<<'EOF'
|
||||
This file is part of PHPUnit.
|
||||
|
||||
(c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
EOF;
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setRules(
|
||||
[
|
||||
'align_multiline_comment' => true,
|
||||
'array_indentation' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'binary_operator_spaces' => [
|
||||
'operators' => [
|
||||
'=' => 'align',
|
||||
'=>' => 'align',
|
||||
],
|
||||
],
|
||||
'blank_line_after_namespace' => true,
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => [
|
||||
'break',
|
||||
'continue',
|
||||
'declare',
|
||||
'do',
|
||||
'for',
|
||||
'foreach',
|
||||
'if',
|
||||
'include',
|
||||
'include_once',
|
||||
'require',
|
||||
'require_once',
|
||||
'return',
|
||||
'switch',
|
||||
'throw',
|
||||
'try',
|
||||
'while',
|
||||
'yield',
|
||||
],
|
||||
],
|
||||
'braces' => true,
|
||||
'cast_spaces' => true,
|
||||
'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
|
||||
'combine_consecutive_issets' => true,
|
||||
'combine_consecutive_unsets' => true,
|
||||
'compact_nullable_typehint' => true,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'declare_equal_normalize' => ['space' => 'none'],
|
||||
'declare_strict_types' => true,
|
||||
'dir_constant' => true,
|
||||
'elseif' => true,
|
||||
'encoding' => true,
|
||||
'full_opening_tag' => true,
|
||||
'function_declaration' => true,
|
||||
'header_comment' => ['header' => $header, 'separate' => 'none'],
|
||||
'indentation_type' => true,
|
||||
'is_null' => true,
|
||||
'line_ending' => true,
|
||||
'list_syntax' => ['syntax' => 'short'],
|
||||
'logical_operators' => true,
|
||||
'lowercase_cast' => true,
|
||||
'lowercase_constants' => true,
|
||||
'lowercase_keywords' => true,
|
||||
'lowercase_static_reference' => true,
|
||||
'magic_constant_casing' => true,
|
||||
'method_argument_space' => ['ensure_fully_multiline' => true],
|
||||
'modernize_types_casting' => true,
|
||||
'multiline_comment_opening_closing' => true,
|
||||
'multiline_whitespace_before_semicolons' => true,
|
||||
'native_constant_invocation' => true,
|
||||
'native_function_casing' => true,
|
||||
'native_function_invocation' => true,
|
||||
'new_with_braces' => false,
|
||||
'no_alias_functions' => true,
|
||||
'no_alternative_syntax' => true,
|
||||
'no_blank_lines_after_class_opening' => true,
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
'no_blank_lines_before_namespace' => true,
|
||||
'no_closing_tag' => true,
|
||||
'no_empty_comment' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_empty_statement' => true,
|
||||
'no_extra_blank_lines' => true,
|
||||
'no_homoglyph_names' => true,
|
||||
'no_leading_import_slash' => true,
|
||||
'no_leading_namespace_whitespace' => true,
|
||||
'no_mixed_echo_print' => ['use' => 'print'],
|
||||
'no_multiline_whitespace_around_double_arrow' => true,
|
||||
'no_null_property_initialization' => true,
|
||||
'no_php4_constructor' => true,
|
||||
'no_short_bool_cast' => true,
|
||||
'no_short_echo_tag' => true,
|
||||
'no_singleline_whitespace_before_semicolons' => true,
|
||||
'no_spaces_after_function_name' => true,
|
||||
'no_spaces_inside_parenthesis' => true,
|
||||
'no_superfluous_elseif' => true,
|
||||
'no_superfluous_phpdoc_tags' => true,
|
||||
'no_trailing_comma_in_list_call' => true,
|
||||
'no_trailing_comma_in_singleline_array' => true,
|
||||
'no_trailing_whitespace' => true,
|
||||
'no_trailing_whitespace_in_comment' => true,
|
||||
'no_unneeded_control_parentheses' => true,
|
||||
'no_unneeded_curly_braces' => true,
|
||||
'no_unneeded_final_method' => true,
|
||||
'no_unreachable_default_argument_value' => true,
|
||||
'no_unset_on_property' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_useless_return' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'non_printable_character' => true,
|
||||
'normalize_index_brace' => true,
|
||||
'object_operator_without_whitespace' => true,
|
||||
'ordered_class_elements' => [
|
||||
'order' => [
|
||||
'use_trait',
|
||||
'constant_public',
|
||||
'constant_protected',
|
||||
'constant_private',
|
||||
'property_public_static',
|
||||
'property_protected_static',
|
||||
'property_private_static',
|
||||
'property_public',
|
||||
'property_protected',
|
||||
'property_private',
|
||||
'method_public_static',
|
||||
'construct',
|
||||
'destruct',
|
||||
'magic',
|
||||
'phpunit',
|
||||
'method_public',
|
||||
'method_protected',
|
||||
'method_private',
|
||||
'method_protected_static',
|
||||
'method_private_static',
|
||||
],
|
||||
],
|
||||
'ordered_imports' => true,
|
||||
'ordered_interfaces' => [
|
||||
'direction' => 'ascend',
|
||||
'order' => 'alpha',
|
||||
],
|
||||
'phpdoc_add_missing_param_annotation' => true,
|
||||
'phpdoc_align' => true,
|
||||
'phpdoc_annotation_without_dot' => true,
|
||||
'phpdoc_indent' => true,
|
||||
'phpdoc_no_access' => true,
|
||||
'phpdoc_no_empty_return' => true,
|
||||
'phpdoc_no_package' => true,
|
||||
'phpdoc_order' => true,
|
||||
'phpdoc_return_self_reference' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_separation' => true,
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_to_comment' => true,
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_trim_consecutive_blank_line_separation' => true,
|
||||
'phpdoc_types' => ['groups' => ['simple', 'meta']],
|
||||
'phpdoc_types_order' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'pow_to_exponentiation' => true,
|
||||
'protected_to_private' => true,
|
||||
'return_assignment' => true,
|
||||
'return_type_declaration' => ['space_before' => 'none'],
|
||||
'self_accessor' => true,
|
||||
'semicolon_after_instruction' => true,
|
||||
'set_type_to_cast' => true,
|
||||
'short_scalar_cast' => true,
|
||||
'simplified_null_return' => false,
|
||||
'single_blank_line_at_eof' => true,
|
||||
'single_import_per_statement' => true,
|
||||
'single_line_after_imports' => true,
|
||||
'single_quote' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'ternary_to_null_coalescing' => true,
|
||||
'trailing_comma_in_multiline_array' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'visibility_required' => [
|
||||
'elements' => [
|
||||
'const',
|
||||
'method',
|
||||
'property',
|
||||
],
|
||||
],
|
||||
'void_return' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
]
|
||||
)
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->files()
|
||||
->in(__DIR__ . '/src')
|
||||
->in(__DIR__ . '/tests/_files')
|
||||
->in(__DIR__ . '/tests/basic')
|
||||
->in(__DIR__ . '/tests/end-to-end')
|
||||
->in(__DIR__ . '/tests/fail')
|
||||
->in(__DIR__ . '/tests/unit')
|
||||
->notName('*.phpt')
|
||||
->notName('ClassWithAllPossibleReturnTypes.php')
|
||||
);
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace PHPSTORM_META {
|
||||
|
||||
override(
|
||||
\PHPUnit\Framework\TestCase::createMock(0),
|
||||
map([
|
||||
'@&\PHPUnit\Framework\MockObject\MockObject',
|
||||
])
|
||||
);
|
||||
|
||||
override(
|
||||
\PHPUnit\Framework\TestCase::createConfiguredMock(0),
|
||||
map([
|
||||
'@&\PHPUnit\Framework\MockObject\MockObject',
|
||||
])
|
||||
);
|
||||
|
||||
override(
|
||||
\PHPUnit\Framework\TestCase::createPartialMock(0),
|
||||
map([
|
||||
'@&\PHPUnit\Framework\MockObject\MockObject',
|
||||
])
|
||||
);
|
||||
|
||||
override(
|
||||
\PHPUnit\Framework\TestCase::createTestProxy(0),
|
||||
map([
|
||||
'@&\PHPUnit\Framework\MockObject\MockObject',
|
||||
])
|
||||
);
|
||||
|
||||
override(
|
||||
\PHPUnit\Framework\TestCase::getMockForAbstractClass(0),
|
||||
map([
|
||||
'@&\PHPUnit\Framework\MockObject\MockObject',
|
||||
])
|
||||
);
|
||||
}
|
||||
+536
@@ -0,0 +1,536 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="3.4.12@86e5e50c1bb492045e70f2ebe1da3cad06e4e9b2">
|
||||
<file src="src/Framework/Assert.php">
|
||||
<ArgumentTypeCoercion occurrences="2">
|
||||
<code>$expectedElement->childNodes->item($i)</code>
|
||||
<code>$actualElement->childNodes->item($i)</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<PossiblyInvalidArgument occurrences="3">
|
||||
<code>$subset</code>
|
||||
<code>$expected</code>
|
||||
<code>$expected</code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyNullArgument occurrences="2">
|
||||
<code>$expectedElement->childNodes->item($i)</code>
|
||||
<code>$actualElement->childNodes->item($i)</code>
|
||||
</PossiblyNullArgument>
|
||||
<PossiblyNullPropertyFetch occurrences="1">
|
||||
<code>$expectedAttribute->name</code>
|
||||
</PossiblyNullPropertyFetch>
|
||||
<UndefinedPropertyFetch occurrences="1">
|
||||
<code>$expectedAttribute->name</code>
|
||||
</UndefinedPropertyFetch>
|
||||
</file>
|
||||
<file src="src/Framework/Assert/Functions.php">
|
||||
<TooManyArguments occurrences="13">
|
||||
<code>Assert::anything(...\func_get_args())</code>
|
||||
<code>Assert::isTrue(...\func_get_args())</code>
|
||||
<code>Assert::isFalse(...\func_get_args())</code>
|
||||
<code>Assert::isJson(...\func_get_args())</code>
|
||||
<code>Assert::isNull(...\func_get_args())</code>
|
||||
<code>Assert::isFinite(...\func_get_args())</code>
|
||||
<code>Assert::isInfinite(...\func_get_args())</code>
|
||||
<code>Assert::isNan(...\func_get_args())</code>
|
||||
<code>Assert::isEmpty(...\func_get_args())</code>
|
||||
<code>Assert::isWritable(...\func_get_args())</code>
|
||||
<code>Assert::isReadable(...\func_get_args())</code>
|
||||
<code>Assert::directoryExists(...\func_get_args())</code>
|
||||
<code>Assert::fileExists(...\func_get_args())</code>
|
||||
</TooManyArguments>
|
||||
</file>
|
||||
<file src="src/Framework/Constraint/Count.php">
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$this->getCountOf($other)</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Framework/Constraint/ExceptionCode.php">
|
||||
<MoreSpecificImplementedParamType occurrences="1">
|
||||
<code>$other</code>
|
||||
</MoreSpecificImplementedParamType>
|
||||
</file>
|
||||
<file src="src/Framework/Constraint/ExceptionMessage.php">
|
||||
<MoreSpecificImplementedParamType occurrences="1">
|
||||
<code>$other</code>
|
||||
</MoreSpecificImplementedParamType>
|
||||
</file>
|
||||
<file src="src/Framework/Constraint/ExceptionMessageRegularExpression.php">
|
||||
<MoreSpecificImplementedParamType occurrences="1">
|
||||
<code>$other</code>
|
||||
</MoreSpecificImplementedParamType>
|
||||
</file>
|
||||
<file src="src/Framework/Constraint/IsInstanceOf.php">
|
||||
<ArgumentTypeCoercion occurrences="1">
|
||||
<code>$this->className</code>
|
||||
</ArgumentTypeCoercion>
|
||||
</file>
|
||||
<file src="src/Framework/Constraint/IsJson.php">
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$error</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Framework/Constraint/IsType.php">
|
||||
<InvalidReturnType occurrences="1">
|
||||
<code>bool</code>
|
||||
</InvalidReturnType>
|
||||
</file>
|
||||
<file src="src/Framework/Constraint/SameSize.php">
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$this->getCountOf($expected)</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Framework/Constraint/StringMatchesFormatDescription.php">
|
||||
<InvalidArgument occurrences="1">
|
||||
<code>"--- Expected\n+++ Actual\n"</code>
|
||||
</InvalidArgument>
|
||||
</file>
|
||||
<file src="src/Framework/Exception/ExpectationFailedException.php">
|
||||
<PossiblyNullPropertyAssignmentValue occurrences="1">
|
||||
<code>$comparisonFailure</code>
|
||||
</PossiblyNullPropertyAssignmentValue>
|
||||
</file>
|
||||
<file src="src/Framework/ExceptionWrapper.php">
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$t->getPrevious()</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Framework/MockObject/Builder/InvocationMocker.php">
|
||||
<ImplementedReturnTypeMismatch occurrences="1">
|
||||
<code>self</code>
|
||||
</ImplementedReturnTypeMismatch>
|
||||
<LessSpecificReturnStatement occurrences="8">
|
||||
<code>$this->will($stub)</code>
|
||||
<code>$this->will($stub)</code>
|
||||
<code>$this->will($stub)</code>
|
||||
<code>$this->will($stub)</code>
|
||||
<code>$this->will($stub)</code>
|
||||
<code>$this->will($stub)</code>
|
||||
<code>$this->will($stub)</code>
|
||||
<code>$this->will($stub)</code>
|
||||
</LessSpecificReturnStatement>
|
||||
<MoreSpecificReturnType occurrences="8">
|
||||
<code>self</code>
|
||||
<code>self</code>
|
||||
<code>self</code>
|
||||
<code>self</code>
|
||||
<code>self</code>
|
||||
<code>self</code>
|
||||
<code>self</code>
|
||||
<code>self</code>
|
||||
</MoreSpecificReturnType>
|
||||
<UndefinedInterfaceMethod occurrences="1">
|
||||
<code>registerId</code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="src/Framework/MockObject/Generator.php">
|
||||
<ArgumentTypeCoercion occurrences="4">
|
||||
<code>$className</code>
|
||||
<code>$className</code>
|
||||
<code>$interfaceName</code>
|
||||
<code>$className</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<InvalidArgument occurrences="1">
|
||||
<code>$e</code>
|
||||
</InvalidArgument>
|
||||
<PossiblyFalseArgument occurrences="1">
|
||||
<code>\strpos($args[$i], '$')</code>
|
||||
</PossiblyFalseArgument>
|
||||
<UndefinedConstant occurrences="1">
|
||||
<code>\WSDL_CACHE_NONE</code>
|
||||
</UndefinedConstant>
|
||||
</file>
|
||||
<file src="src/Framework/MockObject/InvocationMocker.php">
|
||||
<InvalidNullableReturnType occurrences="1">
|
||||
<code>Match</code>
|
||||
</InvalidNullableReturnType>
|
||||
<NullableReturnStatement occurrences="1">
|
||||
<code>null</code>
|
||||
</NullableReturnStatement>
|
||||
<UndefinedInterfaceMethod occurrences="1">
|
||||
<code>hasMatchers</code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="src/Framework/MockObject/Matcher.php">
|
||||
<InvalidPropertyAssignmentValue occurrences="1">
|
||||
<code>new AnyParameters</code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<PossiblyNullReference occurrences="2">
|
||||
<code>__phpunit_getInvocationMocker</code>
|
||||
<code>__phpunit_getInvocationMocker</code>
|
||||
</PossiblyNullReference>
|
||||
</file>
|
||||
<file src="src/Framework/MockObject/Matcher/ConsecutiveParameters.php">
|
||||
<TypeDoesNotContainNull occurrences="1">
|
||||
<code>$invocation === null</code>
|
||||
</TypeDoesNotContainNull>
|
||||
</file>
|
||||
<file src="src/Framework/MockObject/Matcher/Parameters.php">
|
||||
<InvalidPropertyAssignmentValue occurrences="1">
|
||||
<code>$this->doVerify()</code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<PossiblyNullPropertyAssignmentValue occurrences="1">
|
||||
<code>null</code>
|
||||
</PossiblyNullPropertyAssignmentValue>
|
||||
</file>
|
||||
<file src="src/Framework/MockObject/MockBuilder.php">
|
||||
<ArgumentTypeCoercion occurrences="2">
|
||||
<code>$this->type</code>
|
||||
<code>$this->type</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
|
||||
<code>$type</code>
|
||||
</PossiblyInvalidPropertyAssignmentValue>
|
||||
</file>
|
||||
<file src="src/Framework/MockObject/MockMethod.php">
|
||||
<PossiblyNullReference occurrences="1">
|
||||
<code>allowsNull</code>
|
||||
</PossiblyNullReference>
|
||||
</file>
|
||||
<file src="src/Framework/TestCase.php">
|
||||
<ArgumentTypeCoercion occurrences="2">
|
||||
<code>$class_name</code>
|
||||
<code>$this->expectedException</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<InvalidArgument occurrences="1">
|
||||
<code>$header</code>
|
||||
</InvalidArgument>
|
||||
<InvalidCatch occurrences="1"/>
|
||||
<PossiblyNullPropertyAssignmentValue occurrences="3">
|
||||
<code>null</code>
|
||||
<code>$beStrictAboutChangesToGlobalState</code>
|
||||
<code>null</code>
|
||||
</PossiblyNullPropertyAssignmentValue>
|
||||
<PossiblyNullReference occurrences="1">
|
||||
<code>filter</code>
|
||||
</PossiblyNullReference>
|
||||
<PossiblyUndefinedVariable occurrences="1">
|
||||
<code>$categories</code>
|
||||
</PossiblyUndefinedVariable>
|
||||
</file>
|
||||
<file src="src/Framework/TestFailure.php">
|
||||
<PossiblyNullReference occurrences="1">
|
||||
<code>getDiff</code>
|
||||
</PossiblyNullReference>
|
||||
</file>
|
||||
<file src="src/Framework/TestResult.php">
|
||||
<PossiblyUndefinedVariable occurrences="1">
|
||||
<code>$isAnyCoverageRequired</code>
|
||||
</PossiblyUndefinedVariable>
|
||||
</file>
|
||||
<file src="src/Framework/TestSuite.php">
|
||||
<ArgumentTypeCoercion occurrences="2">
|
||||
<code>$className</code>
|
||||
<code>$className</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<PossiblyUndefinedVariable occurrences="1">
|
||||
<code>$afterClassMethod</code>
|
||||
</PossiblyUndefinedVariable>
|
||||
</file>
|
||||
<file src="src/Runner/Filter/NameFilterIterator.php">
|
||||
<InvalidPropertyAssignmentValue occurrences="2">
|
||||
<code>$matches[2]</code>
|
||||
<code>$matches[3]</code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
</file>
|
||||
<file src="src/Runner/PhptTestCase.php">
|
||||
<PossiblyInvalidArgument occurrences="1">
|
||||
<code>$sections['FILEEOF']</code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyNullReference occurrences="1">
|
||||
<code>append</code>
|
||||
</PossiblyNullReference>
|
||||
<PossiblyUndefinedVariable occurrences="1">
|
||||
<code>$sectionOffset</code>
|
||||
</PossiblyUndefinedVariable>
|
||||
</file>
|
||||
<file src="src/Runner/StandardTestSuiteLoader.php">
|
||||
<PossiblyUndefinedVariable occurrences="1">
|
||||
<code>$filename</code>
|
||||
</PossiblyUndefinedVariable>
|
||||
</file>
|
||||
<file src="src/Runner/TestSuiteSorter.php">
|
||||
<PossiblyFalseArgument occurrences="1">
|
||||
<code>\strpos($test->getName(), '::')</code>
|
||||
</PossiblyFalseArgument>
|
||||
<UndefinedInterfaceMethod occurrences="1">
|
||||
<code>getName</code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="src/TextUI/Command.php">
|
||||
<ArgumentTypeCoercion occurrences="4">
|
||||
<code>$suite</code>
|
||||
<code>$suite</code>
|
||||
<code>$suite</code>
|
||||
<code>$printerClass</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<InvalidCatch occurrences="1"/>
|
||||
<LessSpecificReturnStatement occurrences="1">
|
||||
<code>$class->newInstance($outputStream)</code>
|
||||
</LessSpecificReturnStatement>
|
||||
<MoreSpecificReturnType occurrences="1">
|
||||
<code>null|Printer|string</code>
|
||||
</MoreSpecificReturnType>
|
||||
<PossiblyFalseArgument occurrences="1">
|
||||
<code>\strrpos($this->arguments['test'], '.')</code>
|
||||
</PossiblyFalseArgument>
|
||||
<PossiblyNullArgument occurrences="4">
|
||||
<code>$suite</code>
|
||||
<code>$suite</code>
|
||||
<code>$suite</code>
|
||||
<code>$suite</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/TextUI/Help.php">
|
||||
<PossiblyUndefinedArrayOffset occurrences="2">
|
||||
<code>$option['desc']</code>
|
||||
<code>$option['desc']</code>
|
||||
</PossiblyUndefinedArrayOffset>
|
||||
</file>
|
||||
<file src="src/TextUI/ResultPrinter.php">
|
||||
<PossiblyUndefinedVariable occurrences="1">
|
||||
<code>$color</code>
|
||||
</PossiblyUndefinedVariable>
|
||||
<TooManyArguments occurrences="1">
|
||||
<code>Color::colorize($color, \str_pad($line, $padding), false)</code>
|
||||
</TooManyArguments>
|
||||
</file>
|
||||
<file src="src/TextUI/TestRunner.php">
|
||||
<LessSpecificReturnStatement occurrences="1"/>
|
||||
<MoreSpecificReturnType occurrences="1">
|
||||
<code>Printer</code>
|
||||
</MoreSpecificReturnType>
|
||||
<PossiblyNullPropertyAssignmentValue occurrences="1">
|
||||
<code>$loader</code>
|
||||
</PossiblyNullPropertyAssignmentValue>
|
||||
<PossiblyUndefinedVariable occurrences="1">
|
||||
<code>$whitelistFromConfigurationFile</code>
|
||||
</PossiblyUndefinedVariable>
|
||||
<PropertyTypeCoercion occurrences="3">
|
||||
<code>$arguments['printer']</code>
|
||||
<code>$this->createPrinter($arguments['printer'], $arguments)</code>
|
||||
<code>$this->createPrinter(ResultPrinter::class, $arguments)</code>
|
||||
</PropertyTypeCoercion>
|
||||
</file>
|
||||
<file src="src/Util/Blacklist.php">
|
||||
<UndefinedClass occurrences="1">
|
||||
<code>Invoker</code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
<file src="src/Util/Configuration.php">
|
||||
<ArgumentTypeCoercion occurrences="2">
|
||||
<code>$testSuiteNodes->item(0)</code>
|
||||
<code>$testSuiteNode</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<InvalidNullableReturnType occurrences="1">
|
||||
<code>bool</code>
|
||||
</InvalidNullableReturnType>
|
||||
<NullableReturnStatement occurrences="1">
|
||||
<code>\version_compare(\PHP_VERSION, $phpVersion, $phpVersionOperator)</code>
|
||||
</NullableReturnStatement>
|
||||
<PossiblyInvalidArrayOffset occurrences="3">
|
||||
<code>$result[$array][$name]['verbatim']</code>
|
||||
<code>$result[$array][$name]['force']</code>
|
||||
<code>$result[$array][$name]['value']</code>
|
||||
</PossiblyInvalidArrayOffset>
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$testSuiteNodes->item(0)</code>
|
||||
</PossiblyNullArgument>
|
||||
<PossiblyNullReference occurrences="4">
|
||||
<code>hasAttribute</code>
|
||||
<code>getAttribute</code>
|
||||
<code>hasAttribute</code>
|
||||
<code>getAttribute</code>
|
||||
</PossiblyNullReference>
|
||||
<UndefinedMethod occurrences="7">
|
||||
<code>hasAttribute</code>
|
||||
<code>getAttribute</code>
|
||||
<code>hasAttribute</code>
|
||||
<code>getAttribute</code>
|
||||
<code>getAttribute</code>
|
||||
<code>getAttribute</code>
|
||||
<code>getAttribute</code>
|
||||
</UndefinedMethod>
|
||||
</file>
|
||||
<file src="src/Util/ErrorHandler.php">
|
||||
<InvalidArgument occurrences="1"/>
|
||||
</file>
|
||||
<file src="src/Util/Filter.php">
|
||||
<PossiblyNullReference occurrences="1">
|
||||
<code>getTrace</code>
|
||||
</PossiblyNullReference>
|
||||
</file>
|
||||
<file src="src/Util/Getopt.php">
|
||||
<InvalidOperand occurrences="3">
|
||||
<code>$i</code>
|
||||
<code>$i</code>
|
||||
<code>$i</code>
|
||||
</InvalidOperand>
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$long_options</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Util/GlobalState.php">
|
||||
<PossiblyInvalidIterator occurrences="1">
|
||||
<code>$constants['user']</code>
|
||||
</PossiblyInvalidIterator>
|
||||
</file>
|
||||
<file src="src/Util/Log/JUnit.php">
|
||||
<ArgumentTypeCoercion occurrences="1">
|
||||
<code>$suite->getName()</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<InvalidPropertyAssignmentValue occurrences="1">
|
||||
<code>$this->testSuiteTimes</code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<PossiblyNullPropertyAssignmentValue occurrences="1">
|
||||
<code>null</code>
|
||||
</PossiblyNullPropertyAssignmentValue>
|
||||
<UndefinedInterfaceMethod occurrences="2">
|
||||
<code>getName</code>
|
||||
<code>getName</code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="src/Util/Log/TeamCity.php">
|
||||
<ArgumentTypeCoercion occurrences="1">
|
||||
<code>$className</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<UndefinedInterfaceMethod occurrences="7">
|
||||
<code>getName</code>
|
||||
<code>getName</code>
|
||||
<code>getName</code>
|
||||
<code>getName</code>
|
||||
<code>getName</code>
|
||||
<code>getName</code>
|
||||
<code>getName</code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="src/Util/PHP/AbstractPhpProcess.php">
|
||||
<ArgumentTypeCoercion occurrences="2">
|
||||
<code>$this->getException($warnings[0])</code>
|
||||
<code>$this->getException($failures[0])</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<InvalidArgument occurrences="1"/>
|
||||
<LessSpecificReturnStatement occurrences="1">
|
||||
<code>$exception</code>
|
||||
</LessSpecificReturnStatement>
|
||||
<MoreSpecificReturnType occurrences="1">
|
||||
<code>Exception</code>
|
||||
</MoreSpecificReturnType>
|
||||
<PossiblyFalseOperand occurrences="1">
|
||||
<code>\strrpos($key, "\0")</code>
|
||||
</PossiblyFalseOperand>
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$childResult->getCodeCoverage()</code>
|
||||
</PossiblyNullArgument>
|
||||
<PossiblyNullReference occurrences="1">
|
||||
<code>merge</code>
|
||||
</PossiblyNullReference>
|
||||
<UndefinedInterfaceMethod occurrences="2">
|
||||
<code>setResult</code>
|
||||
<code>addToAssertionCount</code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="src/Util/Printer.php">
|
||||
<InvalidArgument occurrences="1">
|
||||
<code>$out[1]</code>
|
||||
</InvalidArgument>
|
||||
<InvalidScalarArgument occurrences="1">
|
||||
<code>$out[1]</code>
|
||||
</InvalidScalarArgument>
|
||||
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
|
||||
<code>$out</code>
|
||||
</PossiblyInvalidPropertyAssignmentValue>
|
||||
</file>
|
||||
<file src="src/Util/RegularExpression.php">
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$matches</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Util/Test.php">
|
||||
<ArgumentTypeCoercion occurrences="4">
|
||||
<code>$className</code>
|
||||
<code>$className</code>
|
||||
<code>$className</code>
|
||||
<code>$dataProviderClassName</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<InvalidArgument occurrences="1">
|
||||
<code>$e</code>
|
||||
</InvalidArgument>
|
||||
<InvalidCatch occurrences="1"/>
|
||||
<InvalidReturnStatement occurrences="1">
|
||||
<code>$data</code>
|
||||
</InvalidReturnStatement>
|
||||
<InvalidReturnType occurrences="1">
|
||||
<code>?array</code>
|
||||
</InvalidReturnType>
|
||||
<InvalidScalarArgument occurrences="1">
|
||||
<code>\array_flip($lineNumbers)</code>
|
||||
</InvalidScalarArgument>
|
||||
<PossiblyNullOperand occurrences="1">
|
||||
<code>$methodName</code>
|
||||
</PossiblyNullOperand>
|
||||
</file>
|
||||
<file src="src/Util/TestDox/CliTestDoxPrinter.php">
|
||||
<PossiblyInvalidArrayOffset occurrences="6">
|
||||
<code>$prefix['start']</code>
|
||||
<code>$prefix['message']</code>
|
||||
<code>$prefix['diff']</code>
|
||||
<code>$prefix['default']</code>
|
||||
<code>$prefix['trace']</code>
|
||||
<code>$prefix['last']</code>
|
||||
</PossiblyInvalidArrayOffset>
|
||||
</file>
|
||||
<file src="src/Util/TestDox/HtmlResultPrinter.php">
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$this->currentTestClassPrettified</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Util/TestDox/NamePrettifier.php">
|
||||
<InvalidCast occurrences="1">
|
||||
<code>$value</code>
|
||||
</InvalidCast>
|
||||
<PossiblyInvalidArgument occurrences="3">
|
||||
<code>$test->dataName()</code>
|
||||
<code>$name</code>
|
||||
<code>$name</code>
|
||||
</PossiblyInvalidArgument>
|
||||
</file>
|
||||
<file src="src/Util/TestDox/TestDoxPrinter.php">
|
||||
<UndefinedInterfaceMethod occurrences="1">
|
||||
<code>getName</code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="src/Util/TestDox/TextResultPrinter.php">
|
||||
<PossiblyNullOperand occurrences="1">
|
||||
<code>$this->currentTestClassPrettified</code>
|
||||
</PossiblyNullOperand>
|
||||
</file>
|
||||
<file src="src/Util/TextTestListRenderer.php">
|
||||
<ArgumentTypeCoercion occurrences="1">
|
||||
<code>$suite->getIterator()</code>
|
||||
</ArgumentTypeCoercion>
|
||||
</file>
|
||||
<file src="src/Util/Xml.php">
|
||||
<ArgumentTypeCoercion occurrences="1">
|
||||
<code>$item</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<LessSpecificReturnStatement occurrences="1">
|
||||
<code>(new DOMDocument)->importNode($element, true)</code>
|
||||
</LessSpecificReturnStatement>
|
||||
<MoreSpecificReturnType occurrences="1">
|
||||
<code>DOMElement</code>
|
||||
</MoreSpecificReturnType>
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$item</code>
|
||||
</PossiblyNullArgument>
|
||||
<PossiblyNullIterator occurrences="1">
|
||||
<code>$arguments</code>
|
||||
</PossiblyNullIterator>
|
||||
<PossiblyNullPropertyFetch occurrences="1">
|
||||
<code>$element->childNodes->item(0)->childNodes</code>
|
||||
</PossiblyNullPropertyFetch>
|
||||
</file>
|
||||
<file src="src/Util/XmlTestListRenderer.php">
|
||||
<ArgumentTypeCoercion occurrences="1">
|
||||
<code>$suite->getIterator()</code>
|
||||
</ArgumentTypeCoercion>
|
||||
</file>
|
||||
</files>
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
totallyTyped="false"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
errorBaseline=".psalm/baseline.xml"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
|
||||
<issueHandlers>
|
||||
<LessSpecificReturnType errorLevel="info" />
|
||||
|
||||
<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->
|
||||
|
||||
<DeprecatedMethod errorLevel="info" />
|
||||
<DeprecatedProperty errorLevel="info" />
|
||||
<DeprecatedClass errorLevel="info" />
|
||||
<DeprecatedConstant errorLevel="info" />
|
||||
<DeprecatedInterface errorLevel="info" />
|
||||
<DeprecatedTrait errorLevel="info" />
|
||||
|
||||
<InternalMethod errorLevel="info" />
|
||||
<InternalProperty errorLevel="info" />
|
||||
<InternalClass errorLevel="info" />
|
||||
|
||||
<MissingClosureReturnType errorLevel="info" />
|
||||
<MissingReturnType errorLevel="info" />
|
||||
<MissingPropertyType errorLevel="info" />
|
||||
<InvalidDocblock errorLevel="info" />
|
||||
<MisplacedRequiredParam errorLevel="info" />
|
||||
|
||||
<PropertyNotSetInConstructor errorLevel="info" />
|
||||
<MissingConstructor errorLevel="info" />
|
||||
<MissingClosureParamType errorLevel="info" />
|
||||
<MissingParamType errorLevel="info" />
|
||||
|
||||
<RedundantCondition errorLevel="info" />
|
||||
|
||||
<DocblockTypeContradiction errorLevel="info" />
|
||||
<RedundantConditionGivenDocblockType errorLevel="info" />
|
||||
|
||||
<UnresolvableInclude errorLevel="info" />
|
||||
|
||||
<RawObjectIteration errorLevel="info" />
|
||||
|
||||
<InvalidStringClass errorLevel="info" />
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
totallyTyped="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="tests/static-analysis" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
|
||||
<issueHandlers>
|
||||
<LessSpecificReturnType errorLevel="error" />
|
||||
|
||||
<DeprecatedMethod errorLevel="error" />
|
||||
<DeprecatedProperty errorLevel="error" />
|
||||
<DeprecatedClass errorLevel="error" />
|
||||
<DeprecatedConstant errorLevel="error" />
|
||||
<DeprecatedInterface errorLevel="error" />
|
||||
<DeprecatedTrait errorLevel="error" />
|
||||
|
||||
<InternalMethod errorLevel="error" />
|
||||
<InternalProperty errorLevel="error" />
|
||||
<InternalClass errorLevel="error" />
|
||||
|
||||
<MissingClosureReturnType errorLevel="error" />
|
||||
<MissingReturnType errorLevel="error" />
|
||||
<MissingPropertyType errorLevel="error" />
|
||||
<InvalidDocblock errorLevel="error" />
|
||||
<MisplacedRequiredParam errorLevel="error" />
|
||||
|
||||
<PropertyNotSetInConstructor errorLevel="info" />
|
||||
<MissingConstructor errorLevel="error" />
|
||||
<MissingClosureParamType errorLevel="error" />
|
||||
<MissingParamType errorLevel="error" />
|
||||
|
||||
<RedundantCondition errorLevel="error" />
|
||||
|
||||
<DocblockTypeContradiction errorLevel="error" />
|
||||
<RedundantConditionGivenDocblockType errorLevel="error" />
|
||||
|
||||
<UnresolvableInclude errorLevel="error" />
|
||||
|
||||
<RawObjectIteration errorLevel="error" />
|
||||
|
||||
<InvalidStringClass errorLevel="error" />
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
language: php
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libxml2-utils
|
||||
|
||||
php:
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4snapshot
|
||||
- nightly
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
fast_finish: true
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DEPENDENCIES="high"
|
||||
- DEPENDENCIES="low"
|
||||
global:
|
||||
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest"
|
||||
|
||||
before_install:
|
||||
- ./tools/composer clear-cache
|
||||
|
||||
install:
|
||||
- if [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry ./tools/composer update $DEFAULT_COMPOSER_FLAGS; fi
|
||||
- if [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry ./tools/composer update $DEFAULT_COMPOSER_FLAGS --prefer-lowest; fi
|
||||
|
||||
before_script:
|
||||
- echo 'zend.assertions=1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||
- echo 'assert.exception=On' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||
|
||||
script:
|
||||
- ./phpunit --coverage-clover=coverage.xml
|
||||
- ./phpunit --configuration ./build/travis-ci-fail.xml > /dev/null; if [ $? -eq 0 ]; then echo "SHOULD FAIL"; false; else echo "fail checked"; fi;
|
||||
- xmllint --noout --schema phpunit.xsd phpunit.xml
|
||||
- xmllint --noout --schema phpunit.xsd tests/_files/configuration.xml
|
||||
- xmllint --noout --schema phpunit.xsd tests/_files/configuration_empty.xml
|
||||
- xmllint --noout --schema phpunit.xsd tests/_files/configuration_xinclude.xml -xinclude
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
# Changes in PHPUnit 8.3
|
||||
|
||||
All notable changes of the PHPUnit 8.3 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [8.3.5] - 2019-09-14
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#3745](https://github.com/sebastianbergmann/phpunit/issues/3745): Performance degradation with test doubles
|
||||
* Fixed [#3801](https://github.com/sebastianbergmann/phpunit/issues/3801): Class constant as default parameter is undefined
|
||||
* Fixed [#3807](https://github.com/sebastianbergmann/phpunit/pull/3807): Fixed message of exception raised by `MockBuilder::addMethods()`
|
||||
* Fixed [#3834](https://github.com/sebastianbergmann/phpunit/issues/3834): Trailing slash breaks code coverage on Windows
|
||||
|
||||
## [8.3.4] - 2019-08-11
|
||||
|
||||
### Changed
|
||||
|
||||
* Implemented [#3788](https://github.com/sebastianbergmann/phpunit/pull/3788): Cast exception message to string
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#3772](https://github.com/sebastianbergmann/phpunit/issues/3772): Process Isolation does not work when PHPDBG is used
|
||||
|
||||
## [8.3.3] - 2019-08-03
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#3781](https://github.com/sebastianbergmann/phpunit/pull/3781): `MockBuilder::addMethods()` and `MockBuilder::onlyMethods()` do not handle empty parameter array correctly
|
||||
|
||||
## [8.3.2] - 2019-08-02
|
||||
|
||||
### Fixed
|
||||
|
||||
* More work on the fix for [#3774](https://github.com/sebastianbergmann/phpunit/issues/3774): Restored name of `PHPUnit\Framework\Error\Deprecated`
|
||||
|
||||
## [8.3.1] - 2019-08-02
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#3774](https://github.com/sebastianbergmann/phpunit/issues/3774): PHP errors, notices, etc. cannot be tested anymore with PHPUnit 8.3
|
||||
|
||||
## [8.3.0] - 2019-08-02
|
||||
|
||||
### Added
|
||||
|
||||
* Implemented [#3687](https://github.com/sebastianbergmann/phpunit/pull/3687): Introduce `MockBuilder::addMethods()` and `MockBuilder::onlyMethods()` as alternatives to `MockBuilder::setMethods()`
|
||||
* Implemented [#3741](https://github.com/sebastianbergmann/phpunit/issues/3741): Format class names as well as method names in TestDox output
|
||||
* Implemented [#3748](https://github.com/sebastianbergmann/phpunit/issues/3748): Add option to sort tests based on information from `@small`, `@medium`, and `@large`
|
||||
* Added `TestCase::getActualOutputForAssertion()` as a wrapper for `TestCase::getActualOutput()` to prevent a test being marked as risky when it prints output and that output is not expected using `TestCase::expectOutputString()` or `TestCase::expectOutputRegEx()`
|
||||
|
||||
### Changed
|
||||
|
||||
* Implemented [#2015](https://github.com/sebastianbergmann/phpunit/issues/2015): Prefix all code bundled in PHAR distribution with random/unique namespace
|
||||
* Implemented [#3503](https://github.com/sebastianbergmann/phpunit/issues/3503): The error handler has been refactored to not rely on global state
|
||||
* Implemented [#3521](https://github.com/sebastianbergmann/phpunit/issues/3521): The `@errorHandler` annotation, which controlled a feature that was not documented and did not work correctly, does not have an effect anymore
|
||||
* Implemented [#3522](https://github.com/sebastianbergmann/phpunit/issues/3522): The `TestCase::setUseErrorHandler()` method, which controlled a feature that was not documented and did not work correctly, has been deprecated and does not have an effect anymore
|
||||
* Implemented [#3687](https://github.com/sebastianbergmann/phpunit/pull/3687): `MockBuilder::setMethods()` is now deprecated
|
||||
|
||||
[8.3.5]: https://github.com/sebastianbergmann/phpunit/compare/8.3.4...8.3.5
|
||||
[8.3.4]: https://github.com/sebastianbergmann/phpunit/compare/8.3.3...8.3.4
|
||||
[8.3.3]: https://github.com/sebastianbergmann/phpunit/compare/8.3.2...8.3.3
|
||||
[8.3.2]: https://github.com/sebastianbergmann/phpunit/compare/8.3.1...8.3.2
|
||||
[8.3.1]: https://github.com/sebastianbergmann/phpunit/compare/8.3.0...8.3.1
|
||||
[8.3.0]: https://github.com/sebastianbergmann/phpunit/compare/8.2.5...8.3.0
|
||||
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
PHPUnit
|
||||
|
||||
Copyright (c) 2001-2019, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of Sebastian Bergmann nor the names of his
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
# PHPUnit
|
||||
|
||||
PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.
|
||||
|
||||
[](https://packagist.org/packages/phpunit/phpunit)
|
||||
[](https://php.net/)
|
||||
[](https://phpunit.de/build-status.html)
|
||||
[](https://shepherd.dev/github/sebastianbergmann/phpunit)
|
||||
|
||||
## Installation
|
||||
|
||||
We distribute a [PHP Archive (PHAR)](https://php.net/phar) that has all required (as well as some optional) dependencies of PHPUnit 8.3 bundled in a single file:
|
||||
|
||||
```bash
|
||||
$ wget https://phar.phpunit.de/phpunit-8.3.phar
|
||||
|
||||
$ php phpunit-8.3.phar --version
|
||||
```
|
||||
|
||||
Alternatively, you may use [Composer](https://getcomposer.org/) to download and install PHPUnit as well as its dependencies. Please refer to the "[Getting Started](https://phpunit.de/getting-started-with-phpunit.html)" guide for details on how to install PHPUnit.
|
||||
|
||||
## Contribute
|
||||
|
||||
Please refer to [CONTRIBUTING.md](https://github.com/sebastianbergmann/phpunit/blob/master/.github/CONTRIBUTING.md) for information on how to contribute to PHPUnit and its related projects.
|
||||
|
||||
## List of Contributors
|
||||
|
||||
Thanks to everyone who has contributed to PHPUnit! You can find a detailed list of contributors on every PHPUnit related package on GitHub. This list shows only the major components:
|
||||
|
||||
* [PHPUnit](https://github.com/sebastianbergmann/phpunit/graphs/contributors)
|
||||
* [php-code-coverage](https://github.com/sebastianbergmann/php-code-coverage/graphs/contributors)
|
||||
|
||||
A very special thanks to everyone who has contributed to the documentation and helps maintain the translations:
|
||||
|
||||
* [English](https://github.com/sebastianbergmann/phpunit-documentation-english/graphs/contributors)
|
||||
* [Spanish](https://github.com/sebastianbergmann/phpunit-documentation-spanish/graphs/contributors)
|
||||
* [French](https://github.com/sebastianbergmann/phpunit-documentation-french/graphs/contributors)
|
||||
* [Japanese](https://github.com/sebastianbergmann/phpunit-documentation-japanese/graphs/contributors)
|
||||
* [Brazilian Portuguese](https://github.com/sebastianbergmann/phpunit-documentation-brazilian-portuguese/graphs/contributors)
|
||||
* [Simplified Chinese](https://github.com/sebastianbergmann/phpunit-documentation-chinese/graphs/contributors)
|
||||
|
||||
Vendored
+467
@@ -0,0 +1,467 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="phpunit" default="setup" xmlns:if="ant:if" xmlns:unless="ant:unless">
|
||||
<target name="setup" depends="clean,install-dependencies"/>
|
||||
<target name="validate" depends="php-syntax-check,validate-composer-json,validate-phpunit-xsd"/>
|
||||
|
||||
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
|
||||
<delete dir="${basedir}/bin"/>
|
||||
<delete dir="${basedir}/vendor"/>
|
||||
<delete file="${basedir}/composer.lock"/>
|
||||
<delete dir="${basedir}/build/documentation"/>
|
||||
<delete dir="${basedir}/build/logfiles"/>
|
||||
<delete dir="${basedir}/build/phar"/>
|
||||
<delete dir="${basedir}/build/phar-scoped"/>
|
||||
<delete>
|
||||
<fileset dir="${basedir}/build">
|
||||
<include name="**/phpunit*.phar"/>
|
||||
<include name="**/phpunit*.phar.asc"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
<property name="clean.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
|
||||
<mkdir dir="${basedir}/build/documentation"/>
|
||||
<mkdir dir="${basedir}/build/logfiles"/>
|
||||
<property name="prepare.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="validate-composer-json" depends="clean" unless="validate-composer-json.done" description="Validate composer.json">
|
||||
<exec executable="${basedir}/tools/composer" failonerror="true" taskname="composer">
|
||||
<arg value="validate"/>
|
||||
<arg value="--strict"/>
|
||||
<arg value="${basedir}/composer.json"/>
|
||||
</exec>
|
||||
|
||||
<property name="validate-composer-json.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="-dependencies-installed">
|
||||
<available file="${basedir}/composer.lock" property="dependencies-installed"/>
|
||||
</target>
|
||||
|
||||
<target name="install-dependencies" unless="dependencies-installed" depends="-dependencies-installed,validate-composer-json" description="Install dependencies with Composer">
|
||||
<copy file="${basedir}/composer.json" tofile="${basedir}/composer.json.bak"/>
|
||||
|
||||
<exec executable="${basedir}/tools/composer" taskname="composer">
|
||||
<arg value="require"/>
|
||||
<arg value="--no-update"/>
|
||||
<arg value="phpunit/php-invoker:^2.0"/>
|
||||
</exec>
|
||||
|
||||
<exec executable="${basedir}/tools/composer" taskname="composer">
|
||||
<arg value="update"/>
|
||||
<arg value="--no-interaction"/>
|
||||
<arg value="--no-progress"/>
|
||||
<arg value="--no-ansi"/>
|
||||
<arg value="--no-suggest"/>
|
||||
</exec>
|
||||
|
||||
<move file="${basedir}/composer.json.bak" tofile="${basedir}/composer.json"/>
|
||||
</target>
|
||||
|
||||
<target name="check-dependencies" description="Performs check for outdated dependencies">
|
||||
<exec executable="${basedir}/tools/composer" taskname="composer">
|
||||
<arg value="show"/>
|
||||
<arg value="--minor-only"/>
|
||||
<arg value="--latest"/>
|
||||
<arg value="--direct"/>
|
||||
<arg value="--outdated"/>
|
||||
<arg value="--strict"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="php-syntax-check" unless="php-syntax-check.done" description="Perform syntax check on PHP files">
|
||||
<apply executable="php" failonerror="true" taskname="lint">
|
||||
<arg value="-l"/>
|
||||
|
||||
<fileset dir="${basedir}/src">
|
||||
<include name="**/*.php"/>
|
||||
<modified/>
|
||||
</fileset>
|
||||
|
||||
<fileset dir="${basedir}/tests">
|
||||
<include name="**/*.php"/>
|
||||
<modified/>
|
||||
</fileset>
|
||||
</apply>
|
||||
|
||||
<property name="php-syntax-check.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="validate-phpunit-xsd" unless="validate-phpunit-xsd.done" description="Validate phpunit.xsd">
|
||||
<exec executable="xmllint" failonerror="true" taskname="xmllint">
|
||||
<arg value="--noout"/>
|
||||
<arg path="${basedir}/phpunit.xsd"/>
|
||||
</exec>
|
||||
|
||||
<property name="validate-phpunit-xsd.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="test" depends="validate,install-dependencies" description="Run tests">
|
||||
<exec executable="${basedir}/phpunit" taskname="phpunit"/>
|
||||
</target>
|
||||
|
||||
<target name="signed-phar" depends="phar" description="Create signed PHAR archive of PHPUnit and all its dependencies">
|
||||
<exec executable="gpg" failonerror="true">
|
||||
<arg value="--local-user"/>
|
||||
<arg value="sb@sebastian-bergmann.de"/>
|
||||
<arg value="--armor"/>
|
||||
<arg value="--detach-sign"/>
|
||||
<arg path="${basedir}/build/phpunit-library-${version}.phar"/>
|
||||
</exec>
|
||||
|
||||
<exec executable="gpg" failonerror="true">
|
||||
<arg value="--local-user"/>
|
||||
<arg value="sb@sebastian-bergmann.de"/>
|
||||
<arg value="--armor"/>
|
||||
<arg value="--detach-sign"/>
|
||||
<arg path="${basedir}/build/phpunit-${version}.phar"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="phar" depends="-phar-prepare,-phar-determine-version" description="Create PHAR archive of PHPUnit and all its dependencies">
|
||||
<antcall target="-phar-build">
|
||||
<param name="type" value="release"/>
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="phar-nightly" depends="-phar-prepare" description="Create PHAR archive of PHPUnit and all its dependencies (nightly)">
|
||||
<antcall target="-phar-build">
|
||||
<param name="type" value="nightly"/>
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="-phar-prepare" depends="clean,install-dependencies">
|
||||
<mkdir dir="${basedir}/build/phar"/>
|
||||
<mkdir dir="${basedir}/build/phar-scoped"/>
|
||||
|
||||
<copy file="${basedir}/phpunit.xsd" tofile="${basedir}/build/phar/phpunit.xsd"/>
|
||||
|
||||
<exec executable="${basedir}/build/phar-manifest.php" output="${basedir}/build/phar/manifest.txt" failonerror="true"/>
|
||||
|
||||
<copy file="${basedir}/vendor/phpunit/php-code-coverage/LICENSE" tofile="${basedir}/build/phar/php-code-coverage/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/php-code-coverage">
|
||||
<fileset dir="${basedir}/vendor/phpunit/php-code-coverage/src">
|
||||
<include name="**/*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phpunit/php-file-iterator/LICENSE" tofile="${basedir}/build/phar/php-file-iterator/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/php-file-iterator">
|
||||
<fileset dir="${basedir}/vendor/phpunit/php-file-iterator/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${basedir}/build/phar/php-invoker">
|
||||
<fileset dir="${basedir}/vendor/phpunit/php-invoker/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phpunit/php-text-template/LICENSE" tofile="${basedir}/build/phar/php-text-template/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/php-text-template">
|
||||
<fileset dir="${basedir}/vendor/phpunit/php-text-template/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phpunit/php-timer/LICENSE" tofile="${basedir}/build/phar/php-timer/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/php-timer">
|
||||
<fileset dir="${basedir}/vendor/phpunit/php-timer/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phpunit/php-token-stream/LICENSE" tofile="${basedir}/build/phar/php-token-stream/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/php-token-stream">
|
||||
<fileset dir="${basedir}/vendor/phpunit/php-token-stream/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/code-unit-reverse-lookup/LICENSE" tofile="${basedir}/build/phar/sebastian-code-unit-reverse-lookup/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-code-unit-reverse-lookup">
|
||||
<fileset dir="${basedir}/vendor/sebastian/code-unit-reverse-lookup/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/comparator/LICENSE" tofile="${basedir}/build/phar/sebastian-comparator/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-comparator">
|
||||
<fileset dir="${basedir}/vendor/sebastian/comparator/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/diff/LICENSE" tofile="${basedir}/build/phar/sebastian-diff/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-diff">
|
||||
<fileset dir="${basedir}/vendor/sebastian/diff/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/environment/LICENSE" tofile="${basedir}/build/phar/sebastian-environment/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-environment">
|
||||
<fileset dir="${basedir}/vendor/sebastian/environment/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/exporter/LICENSE" tofile="${basedir}/build/phar/sebastian-exporter/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-exporter">
|
||||
<fileset dir="${basedir}/vendor/sebastian/exporter/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/global-state/LICENSE" tofile="${basedir}/build/phar/sebastian-global-state/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-global-state">
|
||||
<fileset dir="${basedir}/vendor/sebastian/global-state/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/object-enumerator/LICENSE" tofile="${basedir}/build/phar/object-enumerator/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-object-enumerator">
|
||||
<fileset dir="${basedir}/vendor/sebastian/object-enumerator/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/object-reflector/LICENSE" tofile="${basedir}/build/phar/object-reflector/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-object-reflector">
|
||||
<fileset dir="${basedir}/vendor/sebastian/object-reflector/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/recursion-context/LICENSE" tofile="${basedir}/build/phar/sebastian-recursion-context/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-recursion-context">
|
||||
<fileset dir="${basedir}/vendor/sebastian/recursion-context/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/resource-operations/LICENSE" tofile="${basedir}/build/phar/sebastian-resource-operations/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-resource-operations">
|
||||
<fileset dir="${basedir}/vendor/sebastian/resource-operations/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/type/LICENSE" tofile="${basedir}/build/phar/sebastian-type/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-type">
|
||||
<fileset dir="${basedir}/vendor/sebastian/type/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/sebastian/version/LICENSE" tofile="${basedir}/build/phar/sebastian-version/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/sebastian-version">
|
||||
<fileset dir="${basedir}/vendor/sebastian/version/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/doctrine/instantiator/LICENSE" tofile="${basedir}/build/phar/doctrine-instantiator/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/doctrine-instantiator">
|
||||
<fileset dir="${basedir}/vendor/doctrine/instantiator/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/myclabs/deep-copy/LICENSE" tofile="${basedir}/build/phar/myclabs-deep-copy/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/myclabs-deep-copy">
|
||||
<fileset dir="${basedir}/vendor/myclabs/deep-copy/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phar-io/manifest/LICENSE" tofile="${basedir}/build/phar/phar-io-manifest/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/phar-io-manifest">
|
||||
<fileset dir="${basedir}/vendor/phar-io/manifest/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phar-io/version/LICENSE" tofile="${basedir}/build/phar/phar-io-version/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/phar-io-version">
|
||||
<fileset dir="${basedir}/vendor/phar-io/version/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phpdocumentor/reflection-common/LICENSE" tofile="${basedir}/build/phar/phpdocumentor-reflection-common/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/phpdocumentor-reflection-common">
|
||||
<fileset dir="${basedir}/vendor/phpdocumentor/reflection-common/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phpdocumentor/reflection-docblock/LICENSE" tofile="${basedir}/build/phar/phpdocumentor-reflection-docblock/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/phpdocumentor-reflection-docblock">
|
||||
<fileset dir="${basedir}/vendor/phpdocumentor/reflection-docblock/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phpdocumentor/type-resolver/LICENSE" tofile="${basedir}/build/phar/phpdocumentor-type-resolver/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/phpdocumentor-type-resolver">
|
||||
<fileset dir="${basedir}/vendor/phpdocumentor/type-resolver/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/phpspec/prophecy/LICENSE" tofile="${basedir}/build/phar/phpspec-prophecy/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/phpspec-prophecy">
|
||||
<fileset dir="${basedir}/vendor/phpspec/prophecy/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/symfony/polyfill-ctype/LICENSE" tofile="${basedir}/build/phar/symfony-polyfill-ctype/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/symfony-polyfill-ctype">
|
||||
<fileset dir="${basedir}/vendor/symfony/polyfill-ctype">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/theseer/tokenizer/LICENSE" tofile="${basedir}/build/phar/theseer-tokenizer/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/theseer-tokenizer">
|
||||
<fileset dir="${basedir}/vendor/theseer/tokenizer/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${basedir}/vendor/webmozart/assert/LICENSE" tofile="${basedir}/build/phar/webmozart-assert/LICENSE"/>
|
||||
<copy todir="${basedir}/build/phar/webmozart-assert">
|
||||
<fileset dir="${basedir}/vendor/webmozart/assert/src">
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="-phar-build" depends="-phar-determine-version">
|
||||
<copy todir="${basedir}/build/phar/phpunit">
|
||||
<fileset dir="${basedir}/src">
|
||||
<include name="**/*.php"/>
|
||||
<include name="**/*.tpl*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<exec executable="${basedir}/build/phar-version.php" outputproperty="_version" failonerror="true">
|
||||
<arg value="${version}"/>
|
||||
<arg value="${type}"/>
|
||||
</exec>
|
||||
|
||||
<exec executable="${basedir}/tools/php-scoper" taskname="php-scoper">
|
||||
<arg value="add-prefix" />
|
||||
<arg value="--no-ansi" />
|
||||
<arg value="--force" />
|
||||
<arg value="--config" />
|
||||
<arg path="${basedir}/build/scoper.inc.php" />
|
||||
<arg value="--no-interaction" />
|
||||
<arg value="--stop-on-failure" />
|
||||
<arg value="--output-dir" />
|
||||
<arg path="${basedir}/build/phar-scoped" />
|
||||
<arg value="--prefix" />
|
||||
<arg value="PHPUnit" />
|
||||
<arg path="${basedir}/build/phar" />
|
||||
</exec>
|
||||
|
||||
<exec executable="${basedir}/tools/phpab" taskname="phpab" failonerror="true">
|
||||
<arg value="--all" />
|
||||
<arg value="--static" />
|
||||
<arg value="--once" />
|
||||
<arg value="--phar" />
|
||||
<arg value="--hash" />
|
||||
<arg value="SHA-1" />
|
||||
<arg value="--output" />
|
||||
<arg path="${basedir}/build/phpunit-library-${_version}.phar" />
|
||||
<arg value="--template" />
|
||||
<arg path="${basedir}/build/library-phar-autoload.php.in" />
|
||||
<arg path="${basedir}/build/phar-scoped" />
|
||||
</exec>
|
||||
|
||||
<copy file="${basedir}/build/binary-phar-autoload.php.in" tofile="${basedir}/build/binary-phar-autoload.php"/>
|
||||
<replace file="${basedir}/build/binary-phar-autoload.php" token="X.Y.Z" value="${_version}"/>
|
||||
|
||||
<exec executable="${basedir}/tools/phpab" taskname="phpab" failonerror="true">
|
||||
<arg value="--all" />
|
||||
<arg value="--nolower" />
|
||||
<arg value="--static" />
|
||||
<arg value="--phar" />
|
||||
<arg value="--hash" />
|
||||
<arg value="SHA-1" />
|
||||
<arg value="--output" />
|
||||
<arg path="${basedir}/build/phpunit-${_version}.phar" />
|
||||
<arg value="--template" />
|
||||
<arg path="${basedir}/build/binary-phar-autoload.php" />
|
||||
<arg path="${basedir}/build/phar-scoped" />
|
||||
</exec>
|
||||
|
||||
<chmod file="${basedir}/build/phpunit-${_version}.phar" perm="ugo+rx"/>
|
||||
|
||||
<delete dir="${basedir}/build/phar"/>
|
||||
<delete file="${basedir}/build/binary-phar-autoload.php"/>
|
||||
</target>
|
||||
|
||||
<target name="-phar-determine-version">
|
||||
<exec executable="${basedir}/build/version.php" outputproperty="version" failonerror="true" />
|
||||
</target>
|
||||
|
||||
<target name="generate-project-documentation" depends="-phploc,-checkstyle,-phpunit">
|
||||
<exec executable="${basedir}/tools/phpdox" dir="${basedir}/build" taskname="phpdox"/>
|
||||
</target>
|
||||
|
||||
<target name="update-tools">
|
||||
<exec executable="phive">
|
||||
<arg value="--no-progress"/>
|
||||
<arg value="update"/>
|
||||
</exec>
|
||||
|
||||
<exec executable="${basedir}/tools/composer">
|
||||
<arg value="self-update"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="generate-global-assert-wrappers" description="Generate global function wrappers for static methods in Assert and TestCase that are commonly used">
|
||||
<exec executable="${basedir}/build/generate_global_assert_wrappers.php" taskname="generate-global-assert-wrappers" failonerror="true"/>
|
||||
<exec executable="${basedir}/tools/php-cs-fixer" taskname="php-cs-fixer" failonerror="true">
|
||||
<arg value="fix"/>
|
||||
<arg path="${basedir}/src/Framework/Assert/Functions.php"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="-phploc" depends="prepare">
|
||||
<exec executable="${basedir}/tools/phploc" output="/dev/null" taskname="phploc">
|
||||
<arg value="--count-tests"/>
|
||||
<arg value="--log-xml"/>
|
||||
<arg path="${basedir}/build/logfiles/phploc.xml"/>
|
||||
<arg path="${basedir}/src"/>
|
||||
<arg path="${basedir}/tests"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="-checkstyle" depends="prepare">
|
||||
<exec executable="${basedir}/tools/php-cs-fixer" output="${basedir}/build/logfiles/checkstyle.xml" error="/dev/null" taskname="php-cs-fixer">
|
||||
<arg value="--diff"/>
|
||||
<arg value="--dry-run"/>
|
||||
<arg value="fix"/>
|
||||
<arg value="--format=checkstyle"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="-phpunit" depends="setup">
|
||||
<exec executable="${basedir}/phpunit" taskname="phpunit">
|
||||
<arg value="--coverage-xml"/>
|
||||
<arg path="${basedir}/build/logfiles/coverage"/>
|
||||
<arg value="--log-junit"/>
|
||||
<arg path="${basedir}/build/logfiles/junit.xml"/>
|
||||
</exec>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"description": "The PHP Unit Testing framework.",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"phpunit",
|
||||
"xunit",
|
||||
"testing"
|
||||
],
|
||||
"homepage": "https://phpunit.de/",
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues"
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"php": "^7.2",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"doctrine/instantiator": "^1.2.0",
|
||||
"myclabs/deep-copy": "^1.9.1",
|
||||
"phar-io/manifest": "^1.0.3",
|
||||
"phar-io/version": "^2.0.1",
|
||||
"phpspec/prophecy": "^1.8.1",
|
||||
"phpunit/php-code-coverage": "^7.0.7",
|
||||
"phpunit/php-file-iterator": "^2.0.2",
|
||||
"phpunit/php-text-template": "^1.2.1",
|
||||
"phpunit/php-timer": "^2.1.2",
|
||||
"sebastian/comparator": "^3.0.2",
|
||||
"sebastian/diff": "^3.0.2",
|
||||
"sebastian/environment": "^4.2.2",
|
||||
"sebastian/exporter": "^3.1.1",
|
||||
"sebastian/global-state": "^3.0.0",
|
||||
"sebastian/object-enumerator": "^3.0.3",
|
||||
"sebastian/resource-operations": "^2.0.1",
|
||||
"sebastian/type": "^1.1.3",
|
||||
"sebastian/version": "^2.0.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-PDO": "*"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.2.0"
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
},
|
||||
"suggest": {
|
||||
"phpunit/php-invoker": "^2.0.0",
|
||||
"ext-soap": "*",
|
||||
"ext-xdebug": "*"
|
||||
},
|
||||
"bin": [
|
||||
"phpunit"
|
||||
],
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"tests/"
|
||||
],
|
||||
"files": [
|
||||
"src/Framework/Assert/Functions.php",
|
||||
"tests/_files/CoverageNamespacedFunctionTest.php",
|
||||
"tests/_files/CoveredFunction.php",
|
||||
"tests/_files/NamespaceCoveredFunction.php"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "8.3-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phive xmlns="https://phar.io/phive">
|
||||
<phar name="phpab" version="^1.25" installed="1.25.6" location="./tools/phpab" copy="true"/>
|
||||
<phar name="php-cs-fixer" version="^2.14" installed="2.15.3" location="./tools/php-cs-fixer" copy="true"/>
|
||||
<phar name="phpdox" version="^0.11" installed="0.12.0" location="./tools/phpdox" copy="true"/>
|
||||
<phar name="phploc" version="^4.0" installed="4.0.1" location="./tools/phploc" copy="true"/>
|
||||
<phar name="psalm" version="^3.5" installed="3.5.1" location="./tools/psalm" copy="true"/>
|
||||
</phive>
|
||||
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if (version_compare('7.2.0', PHP_VERSION, '>')) {
|
||||
fwrite(
|
||||
STDERR,
|
||||
sprintf(
|
||||
'This version of PHPUnit is supported on PHP 7.2, PHP 7.3, and PHP 7.4.' . PHP_EOL .
|
||||
'You are using PHP %s (%s).' . PHP_EOL,
|
||||
PHP_VERSION,
|
||||
PHP_BINARY
|
||||
)
|
||||
);
|
||||
|
||||
die(1);
|
||||
}
|
||||
|
||||
if (!ini_get('date.timezone')) {
|
||||
ini_set('date.timezone', 'UTC');
|
||||
}
|
||||
|
||||
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
|
||||
if (file_exists($file)) {
|
||||
define('PHPUNIT_COMPOSER_INSTALL', $file);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unset($file);
|
||||
|
||||
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
|
||||
fwrite(
|
||||
STDERR,
|
||||
'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL .
|
||||
' composer install' . PHP_EOL . PHP_EOL .
|
||||
'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL
|
||||
);
|
||||
|
||||
die(1);
|
||||
}
|
||||
|
||||
$options = getopt('', array('prepend:'));
|
||||
|
||||
if (isset($options['prepend'])) {
|
||||
require $options['prepend'];
|
||||
}
|
||||
|
||||
unset($options);
|
||||
|
||||
require PHPUNIT_COMPOSER_INSTALL;
|
||||
|
||||
PHPUnit\TextUI\Command::main();
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="phpunit.xsd"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
colors="true"
|
||||
verbose="true">
|
||||
<testsuites>
|
||||
<testsuite name="unit">
|
||||
<directory>tests/unit</directory>
|
||||
</testsuite>
|
||||
|
||||
<testsuite name="end-to-end">
|
||||
<directory suffix=".phpt">tests/end-to-end</directory>
|
||||
<exclude>tests/end-to-end/_files</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
<exclude>
|
||||
<file>src/Framework/Assert/Functions.php</file>
|
||||
<file>src/Util/PHP/eval-stdin.php</file>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<php>
|
||||
<const name="PHPUNIT_TESTSUITE" value="true"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
Vendored
+317
@@ -0,0 +1,317 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:annotation>
|
||||
<xs:documentation source="https://phpunit.de/documentation.html">
|
||||
This Schema file defines the rules by which the XML configuration file of PHPUnit 8.3 may be structured.
|
||||
</xs:documentation>
|
||||
<xs:appinfo source="https://phpunit.de/documentation.html"/>
|
||||
</xs:annotation>
|
||||
<xs:element name="phpunit" type="phpUnitType">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Root Element</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:complexType name="filtersType">
|
||||
<xs:sequence>
|
||||
<xs:element name="whitelist" type="whiteListType" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="filterType">
|
||||
<xs:sequence>
|
||||
<xs:choice maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:group ref="pathGroup"/>
|
||||
<xs:element name="exclude">
|
||||
<xs:complexType>
|
||||
<xs:group ref="pathGroup"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="whiteListType">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="filterType">
|
||||
<xs:attribute name="addUncoveredFilesFromWhitelist" default="true" type="xs:boolean"/>
|
||||
<xs:attribute name="processUncoveredFilesFromWhitelist" default="false" type="xs:boolean"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="groupsType">
|
||||
<xs:choice>
|
||||
<xs:sequence>
|
||||
<xs:element name="include" type="groupType"/>
|
||||
<xs:element name="exclude" type="groupType" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
<xs:sequence>
|
||||
<xs:element name="exclude" type="groupType"/>
|
||||
</xs:sequence>
|
||||
</xs:choice>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="groupType">
|
||||
<xs:sequence>
|
||||
<xs:element name="group" type="xs:string" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="extensionsType">
|
||||
<xs:sequence>
|
||||
<xs:element name="extension" type="objectType" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="listenersType">
|
||||
<xs:sequence>
|
||||
<xs:element name="listener" type="objectType" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="objectType">
|
||||
<xs:sequence>
|
||||
<xs:element name="arguments" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:group ref="argumentsGroup"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="class" type="xs:string" use="required"/>
|
||||
<xs:attribute name="file" type="xs:anyURI"/>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="arrayType">
|
||||
<xs:sequence>
|
||||
<xs:element name="element" type="argumentType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="argumentType">
|
||||
<xs:group ref="argumentChoice"/>
|
||||
<xs:attribute name="key" use="required"/>
|
||||
</xs:complexType>
|
||||
<xs:group name="argumentsGroup">
|
||||
<xs:sequence>
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="array" type="arrayType" />
|
||||
<xs:element name="integer" type="xs:integer" />
|
||||
<xs:element name="string" type="xs:string" />
|
||||
<xs:element name="double" type="xs:double" />
|
||||
<xs:element name="null" />
|
||||
<xs:element name="object" type="objectType" />
|
||||
<xs:element name="file" type="xs:anyURI" />
|
||||
<xs:element name="directory" type="xs:anyURI" />
|
||||
<xs:element name="boolean" type="xs:boolean" />
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:group>
|
||||
<xs:group name="argumentChoice">
|
||||
<xs:choice>
|
||||
<xs:element name="array" type="arrayType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="integer" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="double" type="xs:double" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="null" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="object" type="objectType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="file" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="directory" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="boolean" type="xs:boolean" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:choice>
|
||||
</xs:group>
|
||||
<xs:simpleType name="columnsType">
|
||||
<xs:union>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:integer"/>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="max"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:union>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="loggersType">
|
||||
<xs:sequence>
|
||||
<xs:element name="log" type="loggerType" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="loggerType">
|
||||
<xs:attribute name="type">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="coverage-html"/>
|
||||
<xs:enumeration value="coverage-text"/>
|
||||
<xs:enumeration value="coverage-clover"/>
|
||||
<xs:enumeration value="coverage-crap4j"/>
|
||||
<xs:enumeration value="coverage-xml"/>
|
||||
<xs:enumeration value="coverage-php"/>
|
||||
<xs:enumeration value="json"/>
|
||||
<xs:enumeration value="plain"/>
|
||||
<xs:enumeration value="tap"/>
|
||||
<xs:enumeration value="teamcity"/>
|
||||
<xs:enumeration value="junit"/>
|
||||
<xs:enumeration value="testdox-html"/>
|
||||
<xs:enumeration value="testdox-text"/>
|
||||
<xs:enumeration value="testdox-xml"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="target" type="xs:anyURI"/>
|
||||
<xs:attribute name="lowUpperBound" type="xs:nonNegativeInteger" default="35"/>
|
||||
<xs:attribute name="highLowerBound" type="xs:nonNegativeInteger" default="70"/>
|
||||
<xs:attribute name="showUncoveredFiles" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="showOnlySummary" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="threshold" type="xs:nonNegativeInteger" default="30"/>
|
||||
</xs:complexType>
|
||||
<xs:group name="pathGroup">
|
||||
<xs:sequence>
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="directory" type="directoryFilterType"/>
|
||||
<xs:element name="file" type="fileFilterType"/>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:group>
|
||||
<xs:complexType name="directoryFilterType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:anyURI">
|
||||
<xs:attribute type="xs:string" name="prefix" default=""/>
|
||||
<xs:attribute type="xs:string" name="suffix" default="Test.php"/>
|
||||
<xs:attributeGroup ref="phpVersionGroup"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="executionOrderType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="default"/>
|
||||
<xs:enumeration value="defects"/>
|
||||
<xs:enumeration value="depends"/>
|
||||
<xs:enumeration value="depends,defects"/>
|
||||
<xs:enumeration value="depends,duration"/>
|
||||
<xs:enumeration value="depends,random"/>
|
||||
<xs:enumeration value="depends,reverse"/>
|
||||
<xs:enumeration value="depends,size"/>
|
||||
<xs:enumeration value="duration"/>
|
||||
<xs:enumeration value="no-depends"/>
|
||||
<xs:enumeration value="no-depends,defects"/>
|
||||
<xs:enumeration value="no-depends,duration"/>
|
||||
<xs:enumeration value="no-depends,random"/>
|
||||
<xs:enumeration value="no-depends,reverse"/>
|
||||
<xs:enumeration value="no-depends,size"/>
|
||||
<xs:enumeration value="random"/>
|
||||
<xs:enumeration value="reverse"/>
|
||||
<xs:enumeration value="size"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="fileFilterType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:anyURI">
|
||||
<xs:attributeGroup ref="phpVersionGroup"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:attributeGroup name="phpVersionGroup">
|
||||
<xs:attribute name="phpVersion" type="xs:string" default="5.3.0"/>
|
||||
<xs:attribute name="phpVersionOperator" type="xs:string" default=">="/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="phpType">
|
||||
<xs:sequence>
|
||||
<xs:choice maxOccurs="unbounded">
|
||||
<xs:element name="includePath" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="ini" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="const" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="var" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="env" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="post" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="get" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="cookie" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="server" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="files" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="request" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="namedValueType">
|
||||
<xs:attribute name="name" use="required" type="xs:string"/>
|
||||
<xs:attribute name="value" use="required" type="xs:anySimpleType"/>
|
||||
<xs:attribute name="verbatim" use="optional" type="xs:boolean"/>
|
||||
<xs:attribute name="force" use="optional" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="phpUnitType">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The main type specifying the document structure</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:group ref="configGroup"/>
|
||||
<xs:attributeGroup ref="configAttributeGroup"/>
|
||||
</xs:complexType>
|
||||
<xs:attributeGroup name="configAttributeGroup">
|
||||
<xs:attribute name="backupGlobals" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="backupStaticAttributes" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="bootstrap" type="xs:anyURI"/>
|
||||
<xs:attribute name="cacheResult" type="xs:boolean" default="true"/>
|
||||
<xs:attribute name="cacheResultFile" type="xs:anyURI"/>
|
||||
<xs:attribute name="cacheTokens" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="colors" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="columns" type="columnsType" default="80"/>
|
||||
<xs:attribute name="convertDeprecationsToExceptions" type="xs:boolean" default="true"/>
|
||||
<xs:attribute name="convertErrorsToExceptions" type="xs:boolean" default="true"/>
|
||||
<xs:attribute name="convertNoticesToExceptions" type="xs:boolean" default="true"/>
|
||||
<xs:attribute name="convertWarningsToExceptions" type="xs:boolean" default="true"/>
|
||||
<xs:attribute name="disableCodeCoverageIgnore" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="forceCoversAnnotation" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="printerClass" type="xs:string" default="PHPUnit\TextUI\ResultPrinter"/>
|
||||
<xs:attribute name="printerFile" type="xs:anyURI"/>
|
||||
<xs:attribute name="processIsolation" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="stopOnDefect" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="stopOnError" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="stopOnFailure" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="stopOnWarning" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="stopOnIncomplete" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="stopOnRisky" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="stopOnSkipped" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="failOnRisky" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="failOnWarning" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="beStrictAboutChangesToGlobalState" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="beStrictAboutOutputDuringTests" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="beStrictAboutResourceUsageDuringSmallTests" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="beStrictAboutTestsThatDoNotTestAnything" type="xs:boolean" default="true"/>
|
||||
<xs:attribute name="beStrictAboutTodoAnnotatedTests" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="beStrictAboutCoversAnnotation" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="defaultTimeLimit" type="xs:integer" default="0"/>
|
||||
<xs:attribute name="enforceTimeLimit" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="ignoreDeprecatedCodeUnitsFromCodeCoverage" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="timeoutForSmallTests" type="xs:integer" default="1"/>
|
||||
<xs:attribute name="timeoutForMediumTests" type="xs:integer" default="10"/>
|
||||
<xs:attribute name="timeoutForLargeTests" type="xs:integer" default="60"/>
|
||||
<xs:attribute name="testSuiteLoaderClass" type="xs:string" default="PHPUnit\Runner\StandardTestSuiteLoader"/>
|
||||
<xs:attribute name="testSuiteLoaderFile" type="xs:anyURI"/>
|
||||
<xs:attribute name="defaultTestSuite" type="xs:string" default=""/>
|
||||
<xs:attribute name="verbose" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="testdox" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="stderr" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="reverseDefectList" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="registerMockObjectsFromTestArgumentsRecursively" type="xs:boolean" default="false"/>
|
||||
<xs:attribute name="extensionsDirectory" type="xs:string"/>
|
||||
<xs:attribute name="executionOrder" type="executionOrderType" default="default"/>
|
||||
<xs:attribute name="resolveDependencies" type="xs:boolean" default="true"/>
|
||||
<xs:attribute name="noInteraction" type="xs:boolean" default="false"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:group name="configGroup">
|
||||
<xs:all>
|
||||
<xs:element ref="testSuiteFacet" minOccurs="0"/>
|
||||
<xs:element name="groups" type="groupsType" minOccurs="0"/>
|
||||
<xs:element name="testdoxGroups" type="groupsType" minOccurs="0"/>
|
||||
<xs:element name="filter" type="filtersType" minOccurs="0"/>
|
||||
<xs:element name="logging" type="loggersType" minOccurs="0"/>
|
||||
<xs:element name="extensions" type="extensionsType" minOccurs="0"/>
|
||||
<xs:element name="listeners" type="listenersType" minOccurs="0"/>
|
||||
<xs:element name="php" type="phpType" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:group>
|
||||
<xs:element name="testSuiteFacet" abstract="true"/>
|
||||
<xs:element name="testsuite" type="testSuiteType" substitutionGroup="testSuiteFacet"/>
|
||||
<xs:element name="testsuites" type="testSuitesType" substitutionGroup="testSuiteFacet"/>
|
||||
<xs:complexType name="testSuitesType">
|
||||
<xs:sequence>
|
||||
<xs:element name="testsuite" type="testSuiteType" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="testSuiteType">
|
||||
<xs:sequence>
|
||||
<xs:group ref="pathGroup"/>
|
||||
<xs:element name="exclude" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:string" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
interface Exception extends \Throwable
|
||||
{
|
||||
}
|
||||
+3313
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,80 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use ArrayAccess;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the array it is evaluated for has a given key.
|
||||
*
|
||||
* Uses array_key_exists() to check if the key is found in the input array, if
|
||||
* not found the evaluation fails.
|
||||
*
|
||||
* The array key is passed in the constructor.
|
||||
*/
|
||||
final class ArrayHasKey extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var int|string
|
||||
*/
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* @param int|string $key
|
||||
*/
|
||||
public function __construct($key)
|
||||
{
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'has the key ' . $this->exporter()->export($this->key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
if (\is_array($other)) {
|
||||
return \array_key_exists($this->key, $other);
|
||||
}
|
||||
|
||||
if ($other instanceof ArrayAccess) {
|
||||
return $other->offsetExists($this->key);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return 'an array ' . $this->toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the array it is evaluated for has a specified subset.
|
||||
*
|
||||
* Uses array_replace_recursive() to check if a key value subset is part of the
|
||||
* subject array.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/3494
|
||||
*/
|
||||
final class ArraySubset extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var iterable
|
||||
*/
|
||||
private $subset;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $strict;
|
||||
|
||||
public function __construct(iterable $subset, bool $strict = false)
|
||||
{
|
||||
$this->strict = $strict;
|
||||
$this->subset = $subset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
//type cast $other & $this->subset as an array to allow
|
||||
//support in standard array functions.
|
||||
$other = $this->toArray($other);
|
||||
$this->subset = $this->toArray($this->subset);
|
||||
|
||||
$patched = \array_replace_recursive($other, $this->subset);
|
||||
|
||||
if ($this->strict) {
|
||||
$result = $other === $patched;
|
||||
} else {
|
||||
$result = $other == $patched;
|
||||
}
|
||||
|
||||
if ($returnResult) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!$result) {
|
||||
$f = new ComparisonFailure(
|
||||
$patched,
|
||||
$other,
|
||||
\var_export($patched, true),
|
||||
\var_export($other, true)
|
||||
);
|
||||
|
||||
$this->fail($other, $description, $f);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'has the subset ' . $this->exporter()->export($this->subset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return 'an array ' . $this->toString();
|
||||
}
|
||||
|
||||
private function toArray(iterable $other): array
|
||||
{
|
||||
if (\is_array($other)) {
|
||||
return $other;
|
||||
}
|
||||
|
||||
if ($other instanceof \ArrayObject) {
|
||||
return $other->getArrayCopy();
|
||||
}
|
||||
|
||||
if ($other instanceof \Traversable) {
|
||||
return \iterator_to_array($other);
|
||||
}
|
||||
|
||||
// Keep BC even if we know that array would not be the expected one
|
||||
return (array) $other;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
final class Attribute extends Composite
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $attributeName;
|
||||
|
||||
public function __construct(Constraint $constraint, string $attributeName)
|
||||
{
|
||||
parent::__construct($constraint);
|
||||
|
||||
$this->attributeName = $attributeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
return parent::evaluate(
|
||||
Assert::readAttribute(
|
||||
$other,
|
||||
$this->attributeName
|
||||
),
|
||||
$description,
|
||||
$returnResult
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'attribute "' . $this->attributeName . '" ' . $this->innerConstraint()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return $this->toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that evaluates against a specified closure.
|
||||
*/
|
||||
final class Callback extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
public function __construct(callable $callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is accepted by specified callback';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $value. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \call_user_func($this->callback, $other);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the class it is evaluated for has a given
|
||||
* attribute.
|
||||
*
|
||||
* The attribute name is passed in the constructor.
|
||||
*/
|
||||
class ClassHasAttribute extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $attributeName;
|
||||
|
||||
public function __construct(string $attributeName)
|
||||
{
|
||||
$this->attributeName = $attributeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'has attribute "%s"',
|
||||
$this->attributeName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
try {
|
||||
return (new ReflectionClass($other))->hasProperty($this->attributeName);
|
||||
} catch (\ReflectionException $e) {
|
||||
throw new Exception(
|
||||
$e->getMessage(),
|
||||
(int) $e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
'%sclass "%s" %s',
|
||||
\is_object($other) ? 'object of ' : '',
|
||||
\is_object($other) ? \get_class($other) : $other,
|
||||
$this->toString()
|
||||
);
|
||||
}
|
||||
|
||||
protected function attributeName(): string
|
||||
{
|
||||
return $this->attributeName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the class it is evaluated for has a given
|
||||
* static attribute.
|
||||
*
|
||||
* The attribute name is passed in the constructor.
|
||||
*/
|
||||
final class ClassHasStaticAttribute extends ClassHasAttribute
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'has static attribute "%s"',
|
||||
$this->attributeName()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
try {
|
||||
$class = new ReflectionClass($other);
|
||||
|
||||
if ($class->hasProperty($this->attributeName())) {
|
||||
return $class->getProperty($this->attributeName())->isStatic();
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
throw new Exception(
|
||||
$e->getMessage(),
|
||||
(int) $e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
abstract class Composite extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var Constraint
|
||||
*/
|
||||
private $innerConstraint;
|
||||
|
||||
public function __construct(Constraint $innerConstraint)
|
||||
{
|
||||
$this->innerConstraint = $innerConstraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
try {
|
||||
return $this->innerConstraint->evaluate(
|
||||
$other,
|
||||
$description,
|
||||
$returnResult
|
||||
);
|
||||
} catch (ExpectationFailedException $e) {
|
||||
$this->fail($other, $description, $e->getComparisonFailure());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of constraint elements.
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return \count($this->innerConstraint);
|
||||
}
|
||||
|
||||
protected function innerConstraint(): Constraint
|
||||
{
|
||||
return $this->innerConstraint;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use Countable;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Framework\SelfDescribing;
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Abstract base class for constraints which can be applied to any value.
|
||||
*/
|
||||
abstract class Constraint implements Countable, SelfDescribing
|
||||
{
|
||||
/**
|
||||
* @var Exporter
|
||||
*/
|
||||
private $exporter;
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
$success = false;
|
||||
|
||||
if ($this->matches($other)) {
|
||||
$success = true;
|
||||
}
|
||||
|
||||
if ($returnResult) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
$this->fail($other, $description);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of constraint elements.
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function exporter(): Exporter
|
||||
{
|
||||
if ($this->exporter === null) {
|
||||
$this->exporter = new Exporter;
|
||||
}
|
||||
|
||||
return $this->exporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* This method can be overridden to implement the evaluation algorithm.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an exception for the given compared value and test description
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
* @param string $description Additional information about the test
|
||||
* @param ComparisonFailure $comparisonFailure
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
|
||||
{
|
||||
$failureDescription = \sprintf(
|
||||
'Failed asserting that %s.',
|
||||
$this->failureDescription($other)
|
||||
);
|
||||
|
||||
$additionalFailureDescription = $this->additionalFailureDescription($other);
|
||||
|
||||
if ($additionalFailureDescription) {
|
||||
$failureDescription .= "\n" . $additionalFailureDescription;
|
||||
}
|
||||
|
||||
if (!empty($description)) {
|
||||
$failureDescription = $description . "\n" . $failureDescription;
|
||||
}
|
||||
|
||||
throw new ExpectationFailedException(
|
||||
$failureDescription,
|
||||
$comparisonFailure
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return additional failure description where needed
|
||||
*
|
||||
* The function can be overridden to provide additional failure
|
||||
* information like a diff
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function additionalFailureDescription($other): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* To provide additional failure information additionalFailureDescription
|
||||
* can be used.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return $this->exporter()->export($other) . ' ' . $this->toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use Countable;
|
||||
use Generator;
|
||||
use Iterator;
|
||||
use IteratorAggregate;
|
||||
use Traversable;
|
||||
|
||||
class Count extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $expectedCount;
|
||||
|
||||
public function __construct(int $expected)
|
||||
{
|
||||
$this->expectedCount = $expected;
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'count matches %d',
|
||||
$this->expectedCount
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return $this->expectedCount === $this->getCountOf($other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterable $other
|
||||
*/
|
||||
protected function getCountOf($other): ?int
|
||||
{
|
||||
if ($other instanceof \EmptyIterator) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($other instanceof Countable || \is_array($other)) {
|
||||
return \count($other);
|
||||
}
|
||||
|
||||
if ($other instanceof Traversable) {
|
||||
while ($other instanceof IteratorAggregate) {
|
||||
$other = $other->getIterator();
|
||||
}
|
||||
|
||||
$iterator = $other;
|
||||
|
||||
if ($iterator instanceof Generator) {
|
||||
return $this->getCountOfGenerator($iterator);
|
||||
}
|
||||
|
||||
if (!$iterator instanceof Iterator) {
|
||||
return \iterator_count($iterator);
|
||||
}
|
||||
|
||||
$key = $iterator->key();
|
||||
$count = \iterator_count($iterator);
|
||||
|
||||
// Manually rewind $iterator to previous key, since iterator_count
|
||||
// moves pointer.
|
||||
if ($key !== null) {
|
||||
$iterator->rewind();
|
||||
|
||||
while ($iterator->valid() && $key !== $iterator->key()) {
|
||||
$iterator->next();
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of iterations from a generator.
|
||||
* This will fully exhaust the generator.
|
||||
*/
|
||||
protected function getCountOfGenerator(Generator $generator): int
|
||||
{
|
||||
for ($count = 0; $generator->valid(); $generator->next()) {
|
||||
++$count;
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure.
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
'actual size %d matches expected size %d',
|
||||
$this->getCountOf($other),
|
||||
$this->expectedCount
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that checks if the directory(name) that it is evaluated for exists.
|
||||
*
|
||||
* The file path to check is passed as $other in evaluate().
|
||||
*/
|
||||
final class DirectoryExists extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'directory exists';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \is_dir($other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
'directory "%s" exists',
|
||||
$other
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Util\Filter;
|
||||
use Throwable;
|
||||
|
||||
final class Exception extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $className;
|
||||
|
||||
public function __construct(string $className)
|
||||
{
|
||||
$this->className = $className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'exception of type "%s"',
|
||||
$this->className
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return $other instanceof $this->className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
if ($other !== null) {
|
||||
$message = '';
|
||||
|
||||
if ($other instanceof Throwable) {
|
||||
$message = '. Message was: "' . $other->getMessage() . '" at'
|
||||
. "\n" . Filter::getFilteredStacktrace($other);
|
||||
}
|
||||
|
||||
return \sprintf(
|
||||
'exception of type "%s" matches expected exception "%s"%s',
|
||||
\get_class($other),
|
||||
$this->className,
|
||||
$message
|
||||
);
|
||||
}
|
||||
|
||||
return \sprintf(
|
||||
'exception of type "%s" is thrown',
|
||||
$this->className
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
final class ExceptionCode extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var int|string
|
||||
*/
|
||||
private $expectedCode;
|
||||
|
||||
/**
|
||||
* @param int|string $expected
|
||||
*/
|
||||
public function __construct($expected)
|
||||
{
|
||||
$this->expectedCode = $expected;
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
return 'exception code is ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param \Throwable $other
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return (string) $other->getCode() === (string) $this->expectedCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
'%s is equal to expected exception code %s',
|
||||
$this->exporter()->export($other->getCode()),
|
||||
$this->exporter()->export($this->expectedCode)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
final class ExceptionMessage extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $expectedMessage;
|
||||
|
||||
public function __construct(string $expected)
|
||||
{
|
||||
$this->expectedMessage = $expected;
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
if ($this->expectedMessage === '') {
|
||||
return 'exception message is empty';
|
||||
}
|
||||
|
||||
return 'exception message contains ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param \Throwable $other
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
if ($this->expectedMessage === '') {
|
||||
return $other->getMessage() === '';
|
||||
}
|
||||
|
||||
return \strpos((string) $other->getMessage(), $this->expectedMessage) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
if ($this->expectedMessage === '') {
|
||||
return \sprintf(
|
||||
"exception message is empty but is '%s'",
|
||||
$other->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
return \sprintf(
|
||||
"exception message '%s' contains '%s'",
|
||||
$other->getMessage(),
|
||||
$this->expectedMessage
|
||||
);
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Util\RegularExpression as RegularExpressionUtil;
|
||||
|
||||
final class ExceptionMessageRegularExpression extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $expectedMessageRegExp;
|
||||
|
||||
public function __construct(string $expected)
|
||||
{
|
||||
$this->expectedMessageRegExp = $expected;
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
return 'exception message matches ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param \PHPUnit\Framework\Exception $other
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
$match = RegularExpressionUtil::safeMatch($this->expectedMessageRegExp, $other->getMessage());
|
||||
|
||||
if ($match === false) {
|
||||
throw new \PHPUnit\Framework\Exception(
|
||||
"Invalid expected exception message regex given: '{$this->expectedMessageRegExp}'"
|
||||
);
|
||||
}
|
||||
|
||||
return $match === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
"exception message '%s' matches '%s'",
|
||||
$other->getMessage(),
|
||||
$this->expectedMessageRegExp
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that checks if the file(name) that it is evaluated for exists.
|
||||
*
|
||||
* The file path to check is passed as $other in evaluate().
|
||||
*/
|
||||
final class FileExists extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'file exists';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \file_exists($other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
'file "%s" exists',
|
||||
$other
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the value it is evaluated for is greater
|
||||
* than a given value.
|
||||
*/
|
||||
final class GreaterThan extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var float|int
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param float|int $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is greater than ' . $this->exporter()->export($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return $this->value < $other;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* Constraint that accepts any input value.
|
||||
*/
|
||||
final class IsAnything extends Constraint
|
||||
{
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
return $returnResult ? true : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is anything';
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of constraint elements.
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use Countable;
|
||||
|
||||
/**
|
||||
* Constraint that checks whether a variable is empty().
|
||||
*/
|
||||
final class IsEmpty extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is empty';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
if ($other instanceof \EmptyIterator) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($other instanceof Countable) {
|
||||
return \count($other) === 0;
|
||||
}
|
||||
|
||||
return empty($other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
$type = \gettype($other);
|
||||
|
||||
return \sprintf(
|
||||
'%s %s %s',
|
||||
\strpos($type, 'a') === 0 || \strpos($type, 'o') === 0 ? 'an' : 'a',
|
||||
$type,
|
||||
$this->toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
|
||||
|
||||
/**
|
||||
* Constraint that checks if one value is equal to another.
|
||||
*
|
||||
* Equality is checked with PHP's == operator, the operator is explained in
|
||||
* detail at {@url https://php.net/manual/en/types.comparisons.php}.
|
||||
* Two values are equal if they have the same value disregarding type.
|
||||
*
|
||||
* The expected value is passed in the constructor.
|
||||
*/
|
||||
final class IsEqual extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $delta;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $canonicalize;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $ignoreCase;
|
||||
|
||||
public function __construct($value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->delta = $delta;
|
||||
$this->canonicalize = $canonicalize;
|
||||
$this->ignoreCase = $ignoreCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
// If $this->value and $other are identical, they are also equal.
|
||||
// This is the most common path and will allow us to skip
|
||||
// initialization of all the comparators.
|
||||
if ($this->value === $other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$comparatorFactory = ComparatorFactory::getInstance();
|
||||
|
||||
try {
|
||||
$comparator = $comparatorFactory->getComparatorFor(
|
||||
$this->value,
|
||||
$other
|
||||
);
|
||||
|
||||
$comparator->assertEquals(
|
||||
$this->value,
|
||||
$other,
|
||||
$this->delta,
|
||||
$this->canonicalize,
|
||||
$this->ignoreCase
|
||||
);
|
||||
} catch (ComparisonFailure $f) {
|
||||
if ($returnResult) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new ExpectationFailedException(
|
||||
\trim($description . "\n" . $f->getMessage()),
|
||||
$f
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
$delta = '';
|
||||
|
||||
if (\is_string($this->value)) {
|
||||
if (\strpos($this->value, "\n") !== false) {
|
||||
return 'is equal to <text>';
|
||||
}
|
||||
|
||||
return \sprintf(
|
||||
"is equal to '%s'",
|
||||
$this->value
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->delta != 0) {
|
||||
$delta = \sprintf(
|
||||
' with delta <%F>',
|
||||
$this->delta
|
||||
);
|
||||
}
|
||||
|
||||
return \sprintf(
|
||||
'is equal to %s%s',
|
||||
$this->exporter()->export($this->value),
|
||||
$delta
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that accepts false.
|
||||
*/
|
||||
final class IsFalse extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is false';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return $other === false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that accepts finite.
|
||||
*/
|
||||
final class IsFinite extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is finite';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \is_finite($other);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that one value is identical to another.
|
||||
*
|
||||
* Identical check is performed with PHP's === operator, the operator is
|
||||
* explained in detail at
|
||||
* {@url https://php.net/manual/en/types.comparisons.php}.
|
||||
* Two values are identical if they have the same value and are of the same
|
||||
* type.
|
||||
*
|
||||
* The expected value is passed in the constructor.
|
||||
*/
|
||||
final class IsIdentical extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private const EPSILON = 0.0000000001;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
if (\is_float($this->value) && \is_float($other) &&
|
||||
!\is_infinite($this->value) && !\is_infinite($other) &&
|
||||
!\is_nan($this->value) && !\is_nan($other)) {
|
||||
$success = \abs($this->value - $other) < self::EPSILON;
|
||||
} else {
|
||||
$success = $this->value === $other;
|
||||
}
|
||||
|
||||
if ($returnResult) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
$f = null;
|
||||
|
||||
// if both values are strings, make sure a diff is generated
|
||||
if (\is_string($this->value) && \is_string($other)) {
|
||||
$f = new ComparisonFailure(
|
||||
$this->value,
|
||||
$other,
|
||||
\sprintf("'%s'", $this->value),
|
||||
\sprintf("'%s'", $other)
|
||||
);
|
||||
}
|
||||
|
||||
// if both values are array, make sure a diff is generated
|
||||
if (\is_array($this->value) && \is_array($other)) {
|
||||
$f = new ComparisonFailure(
|
||||
$this->value,
|
||||
$other,
|
||||
$this->exporter()->export($this->value),
|
||||
$this->exporter()->export($other)
|
||||
);
|
||||
}
|
||||
|
||||
$this->fail($other, $description, $f);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
if (\is_object($this->value)) {
|
||||
return 'is identical to an object of class "' .
|
||||
\get_class($this->value) . '"';
|
||||
}
|
||||
|
||||
return 'is identical to ' . $this->exporter()->export($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
if (\is_object($this->value) && \is_object($other)) {
|
||||
return 'two variables reference the same object';
|
||||
}
|
||||
|
||||
if (\is_string($this->value) && \is_string($other)) {
|
||||
return 'two strings are identical';
|
||||
}
|
||||
|
||||
if (\is_array($this->value) && \is_array($other)) {
|
||||
return 'two arrays are identical';
|
||||
}
|
||||
|
||||
return parent::failureDescription($other);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that accepts infinite.
|
||||
*/
|
||||
final class IsInfinite extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is infinite';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \is_infinite($other);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the object it is evaluated for is an instance
|
||||
* of a given class.
|
||||
*
|
||||
* The expected class name is passed in the constructor.
|
||||
*/
|
||||
final class IsInstanceOf extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $className;
|
||||
|
||||
public function __construct(string $className)
|
||||
{
|
||||
$this->className = $className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'is instance of %s "%s"',
|
||||
$this->getType(),
|
||||
$this->className
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return $other instanceof $this->className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
'%s is an instance of %s "%s"',
|
||||
$this->exporter()->shortenedExport($other),
|
||||
$this->getType(),
|
||||
$this->className
|
||||
);
|
||||
}
|
||||
|
||||
private function getType(): string
|
||||
{
|
||||
try {
|
||||
$reflection = new ReflectionClass($this->className);
|
||||
|
||||
if ($reflection->isInterface()) {
|
||||
return 'interface';
|
||||
}
|
||||
} catch (ReflectionException $e) {
|
||||
}
|
||||
|
||||
return 'class';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that a string is valid JSON.
|
||||
*/
|
||||
final class IsJson extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is valid JSON';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
if ($other === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
\json_decode($other);
|
||||
|
||||
if (\json_last_error()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
if ($other === '') {
|
||||
return 'an empty string is valid JSON';
|
||||
}
|
||||
|
||||
\json_decode($other);
|
||||
$error = JsonMatchesErrorMessageProvider::determineJsonError(
|
||||
(string) \json_last_error()
|
||||
);
|
||||
|
||||
return \sprintf(
|
||||
'%s is valid JSON (%s)',
|
||||
$this->exporter()->shortenedExport($other),
|
||||
$error
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that accepts nan.
|
||||
*/
|
||||
final class IsNan extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is nan';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \is_nan($other);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that accepts null.
|
||||
*/
|
||||
final class IsNull extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is null';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return $other === null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that checks if the file/dir(name) that it is evaluated for is readable.
|
||||
*
|
||||
* The file path to check is passed as $other in evaluate().
|
||||
*/
|
||||
final class IsReadable extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is readable';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \is_readable($other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
'"%s" is readable',
|
||||
$other
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that accepts true.
|
||||
*/
|
||||
final class IsTrue extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is true';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return $other === true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the value it is evaluated for is of a
|
||||
* specified type.
|
||||
*
|
||||
* The expected value is passed in the constructor.
|
||||
*/
|
||||
final class IsType extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_ARRAY = 'array';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_BOOL = 'bool';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_FLOAT = 'float';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_INT = 'int';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_NULL = 'null';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_NUMERIC = 'numeric';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_OBJECT = 'object';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_RESOURCE = 'resource';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_STRING = 'string';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_SCALAR = 'scalar';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_CALLABLE = 'callable';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const TYPE_ITERABLE = 'iterable';
|
||||
|
||||
/**
|
||||
* @var array<string,bool>
|
||||
*/
|
||||
private const KNOWN_TYPES = [
|
||||
'array' => true,
|
||||
'boolean' => true,
|
||||
'bool' => true,
|
||||
'double' => true,
|
||||
'float' => true,
|
||||
'integer' => true,
|
||||
'int' => true,
|
||||
'null' => true,
|
||||
'numeric' => true,
|
||||
'object' => true,
|
||||
'real' => true,
|
||||
'resource' => true,
|
||||
'string' => true,
|
||||
'scalar' => true,
|
||||
'callable' => true,
|
||||
'iterable' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
public function __construct(string $type)
|
||||
{
|
||||
if (!isset(self::KNOWN_TYPES[$type])) {
|
||||
throw new \PHPUnit\Framework\Exception(
|
||||
\sprintf(
|
||||
'Type specified for PHPUnit\Framework\Constraint\IsType <%s> ' .
|
||||
'is not a valid type.',
|
||||
$type
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'is of type "%s"',
|
||||
$this->type
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
switch ($this->type) {
|
||||
case 'numeric':
|
||||
return \is_numeric($other);
|
||||
|
||||
case 'integer':
|
||||
case 'int':
|
||||
return \is_int($other);
|
||||
|
||||
case 'double':
|
||||
case 'float':
|
||||
case 'real':
|
||||
return \is_float($other);
|
||||
|
||||
case 'string':
|
||||
return \is_string($other);
|
||||
|
||||
case 'boolean':
|
||||
case 'bool':
|
||||
return \is_bool($other);
|
||||
|
||||
case 'null':
|
||||
return null === $other;
|
||||
|
||||
case 'array':
|
||||
return \is_array($other);
|
||||
|
||||
case 'object':
|
||||
return \is_object($other);
|
||||
|
||||
case 'resource':
|
||||
if (\is_resource($other)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
$resource = @\get_resource_type($other);
|
||||
|
||||
if (\is_string($resource)) {
|
||||
return true;
|
||||
}
|
||||
} catch (\TypeError $e) {
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
case 'scalar':
|
||||
return \is_scalar($other);
|
||||
|
||||
case 'callable':
|
||||
return \is_callable($other);
|
||||
|
||||
case 'iterable':
|
||||
return \is_iterable($other);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that checks if the file/dir(name) that it is evaluated for is writable.
|
||||
*
|
||||
* The file path to check is passed as $other in evaluate().
|
||||
*/
|
||||
final class IsWritable extends Constraint
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is writable';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \is_writable($other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
'"%s" is writable',
|
||||
$other
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Util\Json;
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
|
||||
/**
|
||||
* Asserts whether or not two JSON objects are equal.
|
||||
*/
|
||||
final class JsonMatches extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $value;
|
||||
|
||||
public function __construct(string $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the object.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'matches JSON string "%s"',
|
||||
$this->value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* This method can be overridden to implement the evaluation algorithm.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
[$error, $recodedOther] = Json::canonicalize($other);
|
||||
|
||||
if ($error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
[$error, $recodedValue] = Json::canonicalize($this->value);
|
||||
|
||||
if ($error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $recodedOther == $recodedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an exception for the given compared value and test description
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
* @param string $description Additional information about the test
|
||||
* @param ComparisonFailure $comparisonFailure
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
|
||||
{
|
||||
if ($comparisonFailure === null) {
|
||||
[$error] = Json::canonicalize($other);
|
||||
|
||||
if ($error) {
|
||||
parent::fail($other, $description);
|
||||
}
|
||||
|
||||
[$error] = Json::canonicalize($this->value);
|
||||
|
||||
if ($error) {
|
||||
parent::fail($other, $description);
|
||||
}
|
||||
|
||||
$comparisonFailure = new ComparisonFailure(
|
||||
\json_decode($this->value),
|
||||
\json_decode($other),
|
||||
Json::prettify($this->value),
|
||||
Json::prettify($other),
|
||||
false,
|
||||
'Failed asserting that two json values are equal.'
|
||||
);
|
||||
}
|
||||
|
||||
parent::fail($other, $description, $comparisonFailure);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Provides human readable messages for each JSON error.
|
||||
*/
|
||||
final class JsonMatchesErrorMessageProvider
|
||||
{
|
||||
/**
|
||||
* Translates JSON error to a human readable string.
|
||||
*/
|
||||
public static function determineJsonError(string $error, string $prefix = ''): ?string
|
||||
{
|
||||
switch ($error) {
|
||||
case \JSON_ERROR_NONE:
|
||||
return null;
|
||||
case \JSON_ERROR_DEPTH:
|
||||
return $prefix . 'Maximum stack depth exceeded';
|
||||
case \JSON_ERROR_STATE_MISMATCH:
|
||||
return $prefix . 'Underflow or the modes mismatch';
|
||||
case \JSON_ERROR_CTRL_CHAR:
|
||||
return $prefix . 'Unexpected control character found';
|
||||
case \JSON_ERROR_SYNTAX:
|
||||
return $prefix . 'Syntax error, malformed JSON';
|
||||
case \JSON_ERROR_UTF8:
|
||||
return $prefix . 'Malformed UTF-8 characters, possibly incorrectly encoded';
|
||||
default:
|
||||
return $prefix . 'Unknown error';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a given type to a human readable message prefix.
|
||||
*/
|
||||
public static function translateTypeToPrefix(string $type): string
|
||||
{
|
||||
switch (\strtolower($type)) {
|
||||
case 'expected':
|
||||
$prefix = 'Expected value JSON decode error - ';
|
||||
|
||||
break;
|
||||
case 'actual':
|
||||
$prefix = 'Actual value JSON decode error - ';
|
||||
|
||||
break;
|
||||
default:
|
||||
$prefix = '';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $prefix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the value it is evaluated for is less than
|
||||
* a given value.
|
||||
*/
|
||||
final class LessThan extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var float|int
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param float|int $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is less than ' . $this->exporter()->export($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return $this->value > $other;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* Logical AND.
|
||||
*/
|
||||
final class LogicalAnd extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var Constraint[]
|
||||
*/
|
||||
private $constraints = [];
|
||||
|
||||
public static function fromConstraints(Constraint ...$constraints): self
|
||||
{
|
||||
$constraint = new self;
|
||||
|
||||
$constraint->constraints = \array_values($constraints);
|
||||
|
||||
return $constraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Constraint[] $constraints
|
||||
*
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
public function setConstraints(array $constraints): void
|
||||
{
|
||||
$this->constraints = [];
|
||||
|
||||
foreach ($constraints as $constraint) {
|
||||
if (!($constraint instanceof Constraint)) {
|
||||
throw new \PHPUnit\Framework\Exception(
|
||||
'All parameters to ' . __CLASS__ .
|
||||
' must be a constraint object.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->constraints[] = $constraint;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
$success = true;
|
||||
|
||||
foreach ($this->constraints as $constraint) {
|
||||
if (!$constraint->evaluate($other, $description, true)) {
|
||||
$success = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnResult) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
$this->fail($other, $description);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
$text = '';
|
||||
|
||||
foreach ($this->constraints as $key => $constraint) {
|
||||
if ($key > 0) {
|
||||
$text .= ' and ';
|
||||
}
|
||||
|
||||
$text .= $constraint->toString();
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of constraint elements.
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
foreach ($this->constraints as $constraint) {
|
||||
$count += \count($constraint);
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* Logical NOT.
|
||||
*/
|
||||
final class LogicalNot extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var Constraint
|
||||
*/
|
||||
private $constraint;
|
||||
|
||||
public static function negate(string $string): string
|
||||
{
|
||||
$positives = [
|
||||
'contains ',
|
||||
'exists',
|
||||
'has ',
|
||||
'is ',
|
||||
'are ',
|
||||
'matches ',
|
||||
'starts with ',
|
||||
'ends with ',
|
||||
'reference ',
|
||||
'not not ',
|
||||
];
|
||||
|
||||
$negatives = [
|
||||
'does not contain ',
|
||||
'does not exist',
|
||||
'does not have ',
|
||||
'is not ',
|
||||
'are not ',
|
||||
'does not match ',
|
||||
'starts not with ',
|
||||
'ends not with ',
|
||||
'don\'t reference ',
|
||||
'not ',
|
||||
];
|
||||
|
||||
\preg_match('/(\'[\w\W]*\')([\w\W]*)("[\w\W]*")/i', $string, $matches);
|
||||
|
||||
if (\count($matches) > 0) {
|
||||
$nonInput = $matches[2];
|
||||
|
||||
$negatedString = \str_replace(
|
||||
$nonInput,
|
||||
\str_replace(
|
||||
$positives,
|
||||
$negatives,
|
||||
$nonInput
|
||||
),
|
||||
$string
|
||||
);
|
||||
} else {
|
||||
$negatedString = \str_replace(
|
||||
$positives,
|
||||
$negatives,
|
||||
$string
|
||||
);
|
||||
}
|
||||
|
||||
return $negatedString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Constraint|mixed $constraint
|
||||
*/
|
||||
public function __construct($constraint)
|
||||
{
|
||||
if (!($constraint instanceof Constraint)) {
|
||||
$constraint = new IsEqual($constraint);
|
||||
}
|
||||
|
||||
$this->constraint = $constraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
$success = !$this->constraint->evaluate($other, $description, true);
|
||||
|
||||
if ($returnResult) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
$this->fail($other, $description);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
switch (\get_class($this->constraint)) {
|
||||
case LogicalAnd::class:
|
||||
case self::class:
|
||||
case LogicalOr::class:
|
||||
return 'not( ' . $this->constraint->toString() . ' )';
|
||||
|
||||
default:
|
||||
return self::negate(
|
||||
$this->constraint->toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of constraint elements.
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return \count($this->constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
switch (\get_class($this->constraint)) {
|
||||
case LogicalAnd::class:
|
||||
case self::class:
|
||||
case LogicalOr::class:
|
||||
return 'not( ' . $this->constraint->failureDescription($other) . ' )';
|
||||
|
||||
default:
|
||||
return self::negate(
|
||||
$this->constraint->failureDescription($other)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* Logical OR.
|
||||
*/
|
||||
final class LogicalOr extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var Constraint[]
|
||||
*/
|
||||
private $constraints = [];
|
||||
|
||||
public static function fromConstraints(Constraint ...$constraints): self
|
||||
{
|
||||
$constraint = new self;
|
||||
|
||||
$constraint->constraints = \array_values($constraints);
|
||||
|
||||
return $constraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Constraint[] $constraints
|
||||
*/
|
||||
public function setConstraints(array $constraints): void
|
||||
{
|
||||
$this->constraints = [];
|
||||
|
||||
foreach ($constraints as $constraint) {
|
||||
if (!($constraint instanceof Constraint)) {
|
||||
$constraint = new IsEqual(
|
||||
$constraint
|
||||
);
|
||||
}
|
||||
|
||||
$this->constraints[] = $constraint;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
$success = false;
|
||||
|
||||
foreach ($this->constraints as $constraint) {
|
||||
if ($constraint->evaluate($other, $description, true)) {
|
||||
$success = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnResult) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
$this->fail($other, $description);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
$text = '';
|
||||
|
||||
foreach ($this->constraints as $key => $constraint) {
|
||||
if ($key > 0) {
|
||||
$text .= ' or ';
|
||||
}
|
||||
|
||||
$text .= $constraint->toString();
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of constraint elements.
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
foreach ($this->constraints as $constraint) {
|
||||
$count += \count($constraint);
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* Logical XOR.
|
||||
*/
|
||||
final class LogicalXor extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var Constraint[]
|
||||
*/
|
||||
private $constraints = [];
|
||||
|
||||
public static function fromConstraints(Constraint ...$constraints): self
|
||||
{
|
||||
$constraint = new self;
|
||||
|
||||
$constraint->constraints = \array_values($constraints);
|
||||
|
||||
return $constraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Constraint[] $constraints
|
||||
*/
|
||||
public function setConstraints(array $constraints): void
|
||||
{
|
||||
$this->constraints = [];
|
||||
|
||||
foreach ($constraints as $constraint) {
|
||||
if (!($constraint instanceof Constraint)) {
|
||||
$constraint = new IsEqual(
|
||||
$constraint
|
||||
);
|
||||
}
|
||||
|
||||
$this->constraints[] = $constraint;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
$success = true;
|
||||
$lastResult = null;
|
||||
|
||||
foreach ($this->constraints as $constraint) {
|
||||
$result = $constraint->evaluate($other, $description, true);
|
||||
|
||||
if ($result === $lastResult) {
|
||||
$success = false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$lastResult = $result;
|
||||
}
|
||||
|
||||
if ($returnResult) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
$this->fail($other, $description);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
$text = '';
|
||||
|
||||
foreach ($this->constraints as $key => $constraint) {
|
||||
if ($key > 0) {
|
||||
$text .= ' xor ';
|
||||
}
|
||||
|
||||
$text .= $constraint->toString();
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of constraint elements.
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
foreach ($this->constraints as $constraint) {
|
||||
$count += \count($constraint);
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use ReflectionObject;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the object it is evaluated for has a given
|
||||
* attribute.
|
||||
*
|
||||
* The attribute name is passed in the constructor.
|
||||
*/
|
||||
final class ObjectHasAttribute extends ClassHasAttribute
|
||||
{
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return (new ReflectionObject($other))->hasProperty($this->attributeName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the string it is evaluated for matches
|
||||
* a regular expression.
|
||||
*
|
||||
* Checks a given value using the Perl Compatible Regular Expression extension
|
||||
* in PHP. The pattern is matched by executing preg_match().
|
||||
*
|
||||
* The pattern string passed in the constructor.
|
||||
*/
|
||||
class RegularExpression extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pattern;
|
||||
|
||||
public function __construct(string $pattern)
|
||||
{
|
||||
$this->pattern = $pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'matches PCRE pattern "%s"',
|
||||
$this->pattern
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \preg_match($this->pattern, $other) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
final class SameSize extends Count
|
||||
{
|
||||
public function __construct(iterable $expected)
|
||||
{
|
||||
parent::__construct($this->getCountOf($expected));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the string it is evaluated for contains
|
||||
* a given string.
|
||||
*
|
||||
* Uses mb_strpos() to find the position of the string in the input, if not
|
||||
* found the evaluation fails.
|
||||
*
|
||||
* The sub-string is passed in the constructor.
|
||||
*/
|
||||
final class StringContains extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $string;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $ignoreCase;
|
||||
|
||||
public function __construct(string $string, bool $ignoreCase = false)
|
||||
{
|
||||
$this->string = $string;
|
||||
$this->ignoreCase = $ignoreCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
if ($this->ignoreCase) {
|
||||
$string = \mb_strtolower($this->string);
|
||||
} else {
|
||||
$string = $this->string;
|
||||
}
|
||||
|
||||
return \sprintf(
|
||||
'contains "%s"',
|
||||
$string
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
if ('' === $this->string) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->ignoreCase) {
|
||||
return \mb_stripos($other, $this->string) !== false;
|
||||
}
|
||||
|
||||
return \mb_strpos($other, $this->string) !== false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the string it is evaluated for ends with a given
|
||||
* suffix.
|
||||
*/
|
||||
final class StringEndsWith extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $suffix;
|
||||
|
||||
public function __construct(string $suffix)
|
||||
{
|
||||
$this->suffix = $suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'ends with "' . $this->suffix . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \substr($other, 0 - \strlen($this->suffix)) === $this->suffix;
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use SebastianBergmann\Diff\Differ;
|
||||
|
||||
/**
|
||||
* ...
|
||||
*/
|
||||
final class StringMatchesFormatDescription extends RegularExpression
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $string;
|
||||
|
||||
public function __construct(string $string)
|
||||
{
|
||||
parent::__construct(
|
||||
$this->createPatternFromFormat(
|
||||
$this->convertNewlines($string)
|
||||
)
|
||||
);
|
||||
|
||||
$this->string = $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return parent::matches(
|
||||
$this->convertNewlines($other)
|
||||
);
|
||||
}
|
||||
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return 'string matches format description';
|
||||
}
|
||||
|
||||
protected function additionalFailureDescription($other): string
|
||||
{
|
||||
$from = \explode("\n", $this->string);
|
||||
$to = \explode("\n", $this->convertNewlines($other));
|
||||
|
||||
foreach ($from as $index => $line) {
|
||||
if (isset($to[$index]) && $line !== $to[$index]) {
|
||||
$line = $this->createPatternFromFormat($line);
|
||||
|
||||
if (\preg_match($line, $to[$index]) > 0) {
|
||||
$from[$index] = $to[$index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->string = \implode("\n", $from);
|
||||
$other = \implode("\n", $to);
|
||||
|
||||
return (new Differ("--- Expected\n+++ Actual\n"))->diff($this->string, $other);
|
||||
}
|
||||
|
||||
private function createPatternFromFormat(string $string): string
|
||||
{
|
||||
$string = \strtr(
|
||||
\preg_quote($string, '/'),
|
||||
[
|
||||
'%%' => '%',
|
||||
'%e' => '\\' . \DIRECTORY_SEPARATOR,
|
||||
'%s' => '[^\r\n]+',
|
||||
'%S' => '[^\r\n]*',
|
||||
'%a' => '.+',
|
||||
'%A' => '.*',
|
||||
'%w' => '\s*',
|
||||
'%i' => '[+-]?\d+',
|
||||
'%d' => '\d+',
|
||||
'%x' => '[0-9a-fA-F]+',
|
||||
'%f' => '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?',
|
||||
'%c' => '.',
|
||||
]
|
||||
);
|
||||
|
||||
return '/^' . $string . '$/s';
|
||||
}
|
||||
|
||||
private function convertNewlines($text): string
|
||||
{
|
||||
return \preg_replace('/\r\n/', "\n", $text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Util\InvalidArgumentHelper;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the string it is evaluated for begins with a
|
||||
* given prefix.
|
||||
*/
|
||||
final class StringStartsWith extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $prefix;
|
||||
|
||||
public function __construct(string $prefix)
|
||||
{
|
||||
if (\strlen($prefix) === 0) {
|
||||
throw InvalidArgumentHelper::factory(1, 'non-empty string');
|
||||
}
|
||||
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'starts with "' . $this->prefix . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return \strpos((string) $other, $this->prefix) === 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use SplObjectStorage;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the Traversable it is applied to contains
|
||||
* a given value.
|
||||
*/
|
||||
final class TraversableContains extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $checkForObjectIdentity;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $checkForNonObjectIdentity;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
public function __construct($value, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)
|
||||
{
|
||||
$this->checkForObjectIdentity = $checkForObjectIdentity;
|
||||
$this->checkForNonObjectIdentity = $checkForNonObjectIdentity;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
if (\is_string($this->value) && \strpos($this->value, "\n") !== false) {
|
||||
return 'contains "' . $this->value . '"';
|
||||
}
|
||||
|
||||
return 'contains ' . $this->exporter()->export($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other. Returns true if the
|
||||
* constraint is met, false otherwise.
|
||||
*
|
||||
* @param mixed $other value or object to evaluate
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
if ($other instanceof SplObjectStorage) {
|
||||
return $other->contains($this->value);
|
||||
}
|
||||
|
||||
if (\is_object($this->value)) {
|
||||
foreach ($other as $element) {
|
||||
if ($this->checkForObjectIdentity && $element === $this->value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$this->checkForObjectIdentity && $element == $this->value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($other as $element) {
|
||||
if ($this->checkForNonObjectIdentity && $element === $this->value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$this->checkForNonObjectIdentity && $element == $this->value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the failure
|
||||
*
|
||||
* The beginning of failure messages is "Failed asserting that" in most
|
||||
* cases. This method should return the second part of that sentence.
|
||||
*
|
||||
* @param mixed $other evaluated value or object
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return \sprintf(
|
||||
'%s %s',
|
||||
\is_array($other) ? 'an array' : 'a traversable',
|
||||
$this->toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* Constraint that asserts that the Traversable it is applied to contains
|
||||
* only values of a given type.
|
||||
*/
|
||||
final class TraversableContainsOnly extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var Constraint
|
||||
*/
|
||||
private $constraint;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
public function __construct(string $type, bool $isNativeType = true)
|
||||
{
|
||||
if ($isNativeType) {
|
||||
$this->constraint = new IsType($type);
|
||||
} else {
|
||||
$this->constraint = new IsInstanceOf(
|
||||
$type
|
||||
);
|
||||
}
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the constraint for parameter $other
|
||||
*
|
||||
* If $returnResult is set to false (the default), an exception is thrown
|
||||
* in case of a failure. null is returned otherwise.
|
||||
*
|
||||
* If $returnResult is true, the result of the evaluation is returned as
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function evaluate($other, string $description = '', bool $returnResult = false)
|
||||
{
|
||||
$success = true;
|
||||
|
||||
foreach ($other as $item) {
|
||||
if (!$this->constraint->evaluate($item, '', true)) {
|
||||
$success = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnResult) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
$this->fail($other, $description);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the constraint.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'contains only values of type "' . $this->type . '"';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
use PHPUnit\Util\Test as TestUtil;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class DataProviderTestSuite extends TestSuite
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $dependencies = [];
|
||||
|
||||
/**
|
||||
* @param string[] $dependencies
|
||||
*/
|
||||
public function setDependencies(array $dependencies): void
|
||||
{
|
||||
$this->dependencies = $dependencies;
|
||||
|
||||
foreach ($this->tests as $test) {
|
||||
if (!$test instanceof TestCase) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$test->setDependencies($dependencies);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDependencies(): array
|
||||
{
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
public function hasDependencies(): bool
|
||||
{
|
||||
return \count($this->dependencies) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the each test created using the data provider(s)
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function getSize(): int
|
||||
{
|
||||
[$className, $methodName] = \explode('::', $this->getName());
|
||||
|
||||
return TestUtil::getSize($className, $methodName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Error;
|
||||
|
||||
final class Deprecated extends Error
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Error;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
class Error extends Exception
|
||||
{
|
||||
public function __construct(string $message, int $code, string $file, int $line, \Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
$this->file = $file;
|
||||
$this->line = $line;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Error;
|
||||
|
||||
final class Notice extends Error
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework\Error;
|
||||
|
||||
final class Warning extends Error
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
class AssertionFailedError extends Exception implements SelfDescribing
|
||||
{
|
||||
/**
|
||||
* Wrapper for getMessage() which is declared as final.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return $this->getMessage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
class CodeCoverageException extends Exception
|
||||
{
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class CoveredCodeNotExecutedException extends RiskyTestError
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
use PHPUnit\Util\Filter;
|
||||
|
||||
/**
|
||||
* Base class for all PHPUnit Framework exceptions.
|
||||
*
|
||||
* Ensures that exceptions thrown during a test run do not leave stray
|
||||
* references behind.
|
||||
*
|
||||
* Every Exception contains a stack trace. Each stack frame contains the 'args'
|
||||
* of the called function. The function arguments can contain references to
|
||||
* instantiated objects. The references prevent the objects from being
|
||||
* destructed (until test results are eventually printed), so memory cannot be
|
||||
* freed up.
|
||||
*
|
||||
* With enabled process isolation, test results are serialized in the child
|
||||
* process and unserialized in the parent process. The stack trace of Exceptions
|
||||
* may contain objects that cannot be serialized or unserialized (e.g., PDO
|
||||
* connections). Unserializing user-space objects from the child process into
|
||||
* the parent would break the intended encapsulation of process isolation.
|
||||
*
|
||||
* @see http://fabien.potencier.org/article/9/php-serialization-stack-traces-and-exceptions
|
||||
*
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
class Exception extends \RuntimeException implements \PHPUnit\Exception
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $serializableTrace;
|
||||
|
||||
public function __construct($message = '', $code = 0, \Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
$this->serializableTrace = $this->getTrace();
|
||||
|
||||
foreach ($this->serializableTrace as $i => $call) {
|
||||
unset($this->serializableTrace[$i]['args']);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$string = TestFailure::exceptionToString($this);
|
||||
|
||||
if ($trace = Filter::getFilteredStacktrace($this)) {
|
||||
$string .= "\n" . $trace;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function __sleep(): array
|
||||
{
|
||||
return \array_keys(\get_object_vars($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the serializable trace (without 'args').
|
||||
*/
|
||||
public function getSerializableTrace(): array
|
||||
{
|
||||
return $this->serializableTrace;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
|
||||
/**
|
||||
* Exception for expectations which failed their check.
|
||||
*
|
||||
* The exception contains the error message and optionally a
|
||||
* SebastianBergmann\Comparator\ComparisonFailure which is used to
|
||||
* generate diff output of the failed expectations.
|
||||
*
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class ExpectationFailedException extends AssertionFailedError
|
||||
{
|
||||
/**
|
||||
* @var ComparisonFailure
|
||||
*/
|
||||
protected $comparisonFailure;
|
||||
|
||||
public function __construct(string $message, ComparisonFailure $comparisonFailure = null, \Exception $previous = null)
|
||||
{
|
||||
$this->comparisonFailure = $comparisonFailure;
|
||||
|
||||
parent::__construct($message, 0, $previous);
|
||||
}
|
||||
|
||||
public function getComparisonFailure(): ?ComparisonFailure
|
||||
{
|
||||
return $this->comparisonFailure;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class IncompleteTestError extends AssertionFailedError implements IncompleteTest
|
||||
{
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class InvalidCoversTargetException extends CodeCoverageException
|
||||
{
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class InvalidDataProviderException extends Exception
|
||||
{
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class MissingCoversAnnotationException extends RiskyTestError
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class OutputError extends AssertionFailedError
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class PHPTAssertionFailedError extends SyntheticError
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $diff;
|
||||
|
||||
public function __construct(string $message, int $code, string $file, int $line, array $trace, string $diff)
|
||||
{
|
||||
parent::__construct($message, $code, $file, $line, $trace);
|
||||
$this->diff = $diff;
|
||||
}
|
||||
|
||||
public function getDiff(): string
|
||||
{
|
||||
return $this->diff;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
class RiskyTestError extends AssertionFailedError
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class SkippedTestError extends AssertionFailedError implements SkippedTest
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class SkippedTestSuiteError extends AssertionFailedError implements SkippedTest
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
class SyntheticError extends AssertionFailedError
|
||||
{
|
||||
/**
|
||||
* The synthetic file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $syntheticFile = '';
|
||||
|
||||
/**
|
||||
* The synthetic line number.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $syntheticLine = 0;
|
||||
|
||||
/**
|
||||
* The synthetic trace.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $syntheticTrace = [];
|
||||
|
||||
public function __construct(string $message, int $code, string $file, int $line, array $trace)
|
||||
{
|
||||
parent::__construct($message, $code);
|
||||
|
||||
$this->syntheticFile = $file;
|
||||
$this->syntheticLine = $line;
|
||||
$this->syntheticTrace = $trace;
|
||||
}
|
||||
|
||||
public function getSyntheticFile(): string
|
||||
{
|
||||
return $this->syntheticFile;
|
||||
}
|
||||
|
||||
public function getSyntheticLine(): int
|
||||
{
|
||||
return $this->syntheticLine;
|
||||
}
|
||||
|
||||
public function getSyntheticTrace(): array
|
||||
{
|
||||
return $this->syntheticTrace;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class SyntheticSkippedError extends SyntheticError implements SkippedTest
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
final class UnexpectedValueException extends Exception
|
||||
{
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class UnintentionallyCoveredCodeError extends RiskyTestError
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class Warning extends Exception implements SelfDescribing
|
||||
{
|
||||
/**
|
||||
* Wrapper for getMessage() which is declared as final.
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return $this->getMessage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
use PHPUnit\Util\Filter;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Wraps Exceptions thrown by code under test.
|
||||
*
|
||||
* Re-instantiates Exceptions thrown by user-space code to retain their original
|
||||
* class names, properties, and stack traces (but without arguments).
|
||||
*
|
||||
* Unlike PHPUnit\Framework_\Exception, the complete stack of previous Exceptions
|
||||
* is processed.
|
||||
*
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class ExceptionWrapper extends Exception
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $className;
|
||||
|
||||
/**
|
||||
* @var null|ExceptionWrapper
|
||||
*/
|
||||
protected $previous;
|
||||
|
||||
public function __construct(Throwable $t)
|
||||
{
|
||||
// PDOException::getCode() is a string.
|
||||
// @see https://php.net/manual/en/class.pdoexception.php#95812
|
||||
parent::__construct($t->getMessage(), (int) $t->getCode());
|
||||
$this->setOriginalException($t);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$string = TestFailure::exceptionToString($this);
|
||||
|
||||
if ($trace = Filter::getFilteredStacktrace($this)) {
|
||||
$string .= "\n" . $trace;
|
||||
}
|
||||
|
||||
if ($this->previous) {
|
||||
$string .= "\nCaused by\n" . $this->previous;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return $this->className;
|
||||
}
|
||||
|
||||
public function getPreviousWrapped(): ?self
|
||||
{
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
public function setClassName(string $className): void
|
||||
{
|
||||
$this->className = $className;
|
||||
}
|
||||
|
||||
public function setOriginalException(\Throwable $t): void
|
||||
{
|
||||
$this->originalException($t);
|
||||
|
||||
$this->className = \get_class($t);
|
||||
$this->file = $t->getFile();
|
||||
$this->line = $t->getLine();
|
||||
|
||||
$this->serializableTrace = $t->getTrace();
|
||||
|
||||
foreach ($this->serializableTrace as $i => $call) {
|
||||
unset($this->serializableTrace[$i]['args']);
|
||||
}
|
||||
|
||||
if ($t->getPrevious()) {
|
||||
$this->previous = new self($t->getPrevious());
|
||||
}
|
||||
}
|
||||
|
||||
public function getOriginalException(): ?Throwable
|
||||
{
|
||||
return $this->originalException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to contain static originalException to exclude it from stacktrace to prevent the stacktrace contents,
|
||||
* which can be quite big, from being garbage-collected, thus blocking memory until shutdown.
|
||||
* Approach works both for var_dump() and var_export() and print_r()
|
||||
*/
|
||||
private function originalException(Throwable $exceptionToStore = null): ?Throwable
|
||||
{
|
||||
static $originalExceptions;
|
||||
|
||||
$instanceId = \spl_object_hash($this);
|
||||
|
||||
if ($exceptionToStore) {
|
||||
$originalExceptions[$instanceId] = $exceptionToStore;
|
||||
}
|
||||
|
||||
return $originalExceptions[$instanceId] ?? null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
interface IncompleteTest
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
*/
|
||||
final class IncompleteTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $backupGlobals = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $backupStaticAttributes = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $runTestInSeparateProcess = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $useErrorHandler = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $message;
|
||||
|
||||
public function __construct(string $className, string $methodName, string $message = '')
|
||||
{
|
||||
parent::__construct($className . '::' . $methodName);
|
||||
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the test case.
|
||||
*
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function runTest(): void
|
||||
{
|
||||
$this->markTestIncomplete($this->message);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user