Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
40
vendor/sebastian/comparator/.github/stale.yml
vendored
Normal file
40
vendor/sebastian/comparator/.github/stale.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
||||
daysUntilStale: 60
|
||||
|
||||
# Number of days of inactivity before a stale Issue or Pull Request is closed.
|
||||
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
||||
daysUntilClose: 7
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
- enhancement
|
||||
|
||||
# Set to true to ignore issues in a project (defaults to false)
|
||||
exemptProjects: false
|
||||
|
||||
# Set to true to ignore issues in a milestone (defaults to false)
|
||||
exemptMilestones: false
|
||||
|
||||
# Label to use when marking as stale
|
||||
staleLabel: stale
|
||||
|
||||
# Comment to post when marking as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.
|
||||
|
||||
# Comment to post when removing the stale label.
|
||||
# unmarkComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Comment to post when closing a stale Issue or Pull Request.
|
||||
closeComment: >
|
||||
This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.
|
||||
|
||||
# Limit the number of actions per hour, from 1-30. Default is 30
|
||||
limitPerRun: 30
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
only: issues
|
||||
|
113
vendor/sebastian/comparator/.php_cs.dist
vendored
113
vendor/sebastian/comparator/.php_cs.dist
vendored
@@ -12,71 +12,173 @@ return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setRules(
|
||||
[
|
||||
'align_multiline_comment' => true,
|
||||
'array_indentation' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'binary_operator_spaces' => [
|
||||
'align_double_arrow' => true,
|
||||
'align_equals' => true
|
||||
'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'],
|
||||
'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,
|
||||
'method_argument_space' => 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_consecutive_blank_lines' => 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,
|
||||
'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' => true,
|
||||
'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' => true,
|
||||
'single_blank_line_at_eof' => true,
|
||||
'single_import_per_statement' => true,
|
||||
'single_line_after_imports' => true,
|
||||
'single_quote' => true,
|
||||
'ternary_operator_spaces' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'ternary_to_null_coalescing' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'visibility_required' => true,
|
||||
//'void_return' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
]
|
||||
)
|
||||
->setFinder(
|
||||
@@ -84,5 +186,4 @@ return PhpCsFixer\Config::create()
|
||||
->files()
|
||||
->in(__DIR__ . '/src')
|
||||
->in(__DIR__ . '/tests')
|
||||
->name('*.php')
|
||||
);
|
||||
|
1
vendor/sebastian/comparator/.travis.yml
vendored
1
vendor/sebastian/comparator/.travis.yml
vendored
@@ -3,7 +3,6 @@ language: php
|
||||
sudo: false
|
||||
|
||||
php:
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- master
|
||||
|
28
vendor/sebastian/comparator/ChangeLog.md
vendored
28
vendor/sebastian/comparator/ChangeLog.md
vendored
@@ -2,6 +2,29 @@
|
||||
|
||||
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [3.0.2] - 2018-07-12
|
||||
|
||||
### Changed
|
||||
|
||||
* By default, `MockObjectComparator` is now tried before all other (default) comparators
|
||||
|
||||
## [3.0.1] - 2018-06-14
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#53](https://github.com/sebastianbergmann/comparator/pull/53): `DOMNodeComparator` ignores `$ignoreCase` parameter
|
||||
* Fixed [#58](https://github.com/sebastianbergmann/comparator/pull/58): `ScalarComparator` does not handle extremely ugly string comparison edge cases
|
||||
|
||||
## [3.0.0] - 2018-04-18
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#48](https://github.com/sebastianbergmann/comparator/issues/48): `DateTimeComparator` does not support fractional second deltas
|
||||
|
||||
### Removed
|
||||
|
||||
* Removed support for PHP 7.0
|
||||
|
||||
## [2.1.3] - 2018-02-01
|
||||
|
||||
### Changed
|
||||
@@ -12,7 +35,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix comparison of DateTimeImmutable objects
|
||||
* Fix comparison of `DateTimeImmutable` objects
|
||||
|
||||
## [2.1.1] - 2017-12-22
|
||||
|
||||
@@ -27,6 +50,9 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
|
||||
* Added `SebastianBergmann\Comparator\Factory::reset()` to unregister all non-default comparators
|
||||
* Added support for `phpunit/phpunit-mock-objects` version `^5.0`
|
||||
|
||||
[3.0.2]: https://github.com/sebastianbergmann/comparator/compare/3.0.1...3.0.2
|
||||
[3.0.1]: https://github.com/sebastianbergmann/comparator/compare/3.0.0...3.0.1
|
||||
[3.0.0]: https://github.com/sebastianbergmann/comparator/compare/2.1.3...3.0.0
|
||||
[2.1.3]: https://github.com/sebastianbergmann/comparator/compare/2.1.2...2.1.3
|
||||
[2.1.2]: https://github.com/sebastianbergmann/comparator/compare/2.1.1...2.1.2
|
||||
[2.1.1]: https://github.com/sebastianbergmann/comparator/compare/2.1.0...2.1.1
|
||||
|
2
vendor/sebastian/comparator/LICENSE
vendored
2
vendor/sebastian/comparator/LICENSE
vendored
@@ -1,6 +1,6 @@
|
||||
Comparator
|
||||
|
||||
Copyright (c) 2002-2017, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
Copyright (c) 2002-2018, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
8
vendor/sebastian/comparator/composer.json
vendored
8
vendor/sebastian/comparator/composer.json
vendored
@@ -24,12 +24,12 @@
|
||||
],
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"php": "^7.0",
|
||||
"sebastian/diff": "^2.0 || ^3.0",
|
||||
"php": "^7.1",
|
||||
"sebastian/diff": "^3.0",
|
||||
"sebastian/exporter": "^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.4"
|
||||
"phpunit/phpunit": "^7.1"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
@@ -47,7 +47,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.1.x-dev"
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
vendor/sebastian/comparator/phpunit.xml
vendored
11
vendor/sebastian/comparator/phpunit.xml
vendored
@@ -1,14 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.2/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
forceCoversAnnotation="true"
|
||||
beStrictAboutCoversAnnotation="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuite>
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
<testsuites>
|
||||
<testsuite name="default">
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
@@ -32,9 +31,6 @@ abstract class Comparator
|
||||
$this->exporter = new Exporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Factory $factory
|
||||
*/
|
||||
public function setFactory(Factory $factory)
|
||||
{
|
||||
$this->factory = $factory;
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use SebastianBergmann\Diff\Differ;
|
||||
@@ -62,13 +61,13 @@ class ComparisonFailure extends \RuntimeException
|
||||
/**
|
||||
* Initialises with the expected value and the actual value.
|
||||
*
|
||||
* @param mixed $expected Expected value retrieved.
|
||||
* @param mixed $actual Actual value retrieved.
|
||||
* @param mixed $expected expected value retrieved
|
||||
* @param mixed $actual actual value retrieved
|
||||
* @param string $expectedAsString
|
||||
* @param string $actualAsString
|
||||
* @param bool $identical
|
||||
* @param string $message A string which is prefixed on all returned lines
|
||||
* in the difference output.
|
||||
* @param string $message a string which is prefixed on all returned lines
|
||||
* in the difference output
|
||||
*/
|
||||
public function __construct($expected, $actual, $expectedAsString, $actualAsString, $identical = false, $message = '')
|
||||
{
|
||||
@@ -79,17 +78,11 @@ class ComparisonFailure extends \RuntimeException
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getActual()
|
||||
{
|
||||
return $this->actual;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getExpected()
|
||||
{
|
||||
return $this->expected;
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use DOMDocument;
|
||||
@@ -82,6 +81,6 @@ class DOMNodeComparator extends ObjectComparator
|
||||
|
||||
$text = $node instanceof DOMDocument ? $node->saveXML() : $document->saveXML($node);
|
||||
|
||||
return $ignoreCase ? $text : \strtolower($text);
|
||||
return $ignoreCase ? \strtolower($text) : $text;
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
@@ -26,7 +25,7 @@ class DateTimeComparator extends ObjectComparator
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return ($expected instanceof \DateTime || $expected instanceof \DateTimeInterface) &&
|
||||
($actual instanceof \DateTime || $actual instanceof \DateTimeInterface);
|
||||
($actual instanceof \DateTime || $actual instanceof \DateTimeInterface);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,13 +38,16 @@ class DateTimeComparator extends ObjectComparator
|
||||
* @param bool $ignoreCase Case is ignored when set to true
|
||||
* @param array $processed List of already processed elements (used to prevent infinite recursion)
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
|
||||
{
|
||||
/** @var \DateTimeInterface $expected */
|
||||
/** @var \DateTimeInterface $actual */
|
||||
$delta = new \DateInterval(\sprintf('PT%dS', \abs($delta)));
|
||||
$absDelta = \abs($delta);
|
||||
$delta = new \DateInterval(\sprintf('PT%dS', $absDelta));
|
||||
$delta->f = $absDelta - \floor($absDelta);
|
||||
|
||||
$actualClone = (clone $actual)
|
||||
->setTimezone(new \DateTimeZone('UTC'));
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
33
vendor/sebastian/comparator/src/Factory.php
vendored
33
vendor/sebastian/comparator/src/Factory.php
vendored
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
@@ -15,6 +14,11 @@ namespace SebastianBergmann\Comparator;
|
||||
*/
|
||||
class Factory
|
||||
{
|
||||
/**
|
||||
* @var Factory
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* @var Comparator[]
|
||||
*/
|
||||
@@ -25,11 +29,6 @@ class Factory
|
||||
*/
|
||||
private $defaultComparators = [];
|
||||
|
||||
/**
|
||||
* @var Factory
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* @return Factory
|
||||
*/
|
||||
@@ -116,23 +115,23 @@ class Factory
|
||||
|
||||
private function registerDefaultComparators()
|
||||
{
|
||||
$this->registerDefaultComparator(new TypeComparator);
|
||||
$this->registerDefaultComparator(new ScalarComparator);
|
||||
$this->registerDefaultComparator(new NumericComparator);
|
||||
$this->registerDefaultComparator(new DoubleComparator);
|
||||
$this->registerDefaultComparator(new ArrayComparator);
|
||||
$this->registerDefaultComparator(new ResourceComparator);
|
||||
$this->registerDefaultComparator(new ObjectComparator);
|
||||
$this->registerDefaultComparator(new ExceptionComparator);
|
||||
$this->registerDefaultComparator(new SplObjectStorageComparator);
|
||||
$this->registerDefaultComparator(new DOMNodeComparator);
|
||||
$this->registerDefaultComparator(new MockObjectComparator);
|
||||
$this->registerDefaultComparator(new DateTimeComparator);
|
||||
$this->registerDefaultComparator(new DOMNodeComparator);
|
||||
$this->registerDefaultComparator(new SplObjectStorageComparator);
|
||||
$this->registerDefaultComparator(new ExceptionComparator);
|
||||
$this->registerDefaultComparator(new ObjectComparator);
|
||||
$this->registerDefaultComparator(new ResourceComparator);
|
||||
$this->registerDefaultComparator(new ArrayComparator);
|
||||
$this->registerDefaultComparator(new DoubleComparator);
|
||||
$this->registerDefaultComparator(new NumericComparator);
|
||||
$this->registerDefaultComparator(new ScalarComparator);
|
||||
$this->registerDefaultComparator(new TypeComparator);
|
||||
}
|
||||
|
||||
private function registerDefaultComparator(Comparator $comparator)
|
||||
{
|
||||
\array_unshift($this->defaultComparators, $comparator);
|
||||
$this->defaultComparators[] = $comparator;
|
||||
|
||||
$comparator->setFactory($this);
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
@@ -46,11 +45,11 @@ class NumericComparator extends ScalarComparator
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
|
||||
{
|
||||
if (\is_infinite($actual) && \is_infinite($expected)) {
|
||||
return;
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
if ((\is_infinite($actual) xor \is_infinite($expected)) ||
|
||||
(\is_nan($actual) or \is_nan($expected)) ||
|
||||
(\is_nan($actual) || \is_nan($expected)) ||
|
||||
\abs($actual - $expected) > $delta) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
@@ -62,18 +61,18 @@ class ScalarComparator extends Comparator
|
||||
}
|
||||
}
|
||||
|
||||
if ($expectedToCompare != $actualToCompare) {
|
||||
if (\is_string($expected) && \is_string($actual)) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
$actual,
|
||||
$this->exporter->export($expected),
|
||||
$this->exporter->export($actual),
|
||||
false,
|
||||
'Failed asserting that two strings are equal.'
|
||||
);
|
||||
}
|
||||
if ($expectedToCompare !== $actualToCompare && \is_string($expected) && \is_string($actual)) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
$actual,
|
||||
$this->exporter->export($expected),
|
||||
$this->exporter->export($actual),
|
||||
false,
|
||||
'Failed asserting that two strings are equal.'
|
||||
);
|
||||
}
|
||||
|
||||
if ($expectedToCompare != $actualToCompare) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
$actual,
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
@@ -7,26 +7,25 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ArrayComparator
|
||||
* @covers \SebastianBergmann\Comparator\ArrayComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class ArrayComparatorTest extends TestCase
|
||||
final class ArrayComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ArrayComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new ArrayComparator;
|
||||
$this->comparator->setFactory(new Factory);
|
||||
@@ -35,92 +34,89 @@ class ArrayComparatorTest extends TestCase
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[[], null],
|
||||
[null, []],
|
||||
[null, null]
|
||||
[[], null],
|
||||
[null, []],
|
||||
[null, null]
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
['a' => 1, 'b' => 2],
|
||||
['b' => 2, 'a' => 1]
|
||||
],
|
||||
[
|
||||
[1],
|
||||
['1']
|
||||
],
|
||||
[
|
||||
[3, 2, 1],
|
||||
[2, 3, 1],
|
||||
0,
|
||||
true
|
||||
],
|
||||
[
|
||||
[2.3],
|
||||
[2.5],
|
||||
0.5
|
||||
],
|
||||
[
|
||||
[[2.3]],
|
||||
[[2.5]],
|
||||
0.5
|
||||
],
|
||||
[
|
||||
[new Struct(2.3)],
|
||||
[new Struct(2.5)],
|
||||
0.5
|
||||
],
|
||||
[
|
||||
['a' => 1, 'b' => 2],
|
||||
['b' => 2, 'a' => 1]
|
||||
],
|
||||
[
|
||||
[1],
|
||||
['1']
|
||||
],
|
||||
[
|
||||
[3, 2, 1],
|
||||
[2, 3, 1],
|
||||
0,
|
||||
true
|
||||
],
|
||||
[
|
||||
[2.3],
|
||||
[2.5],
|
||||
0.5
|
||||
],
|
||||
[
|
||||
[[2.3]],
|
||||
[[2.5]],
|
||||
0.5
|
||||
],
|
||||
[
|
||||
[new Struct(2.3)],
|
||||
[new Struct(2.5)],
|
||||
0.5
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
[],
|
||||
[0 => 1]
|
||||
],
|
||||
[
|
||||
[0 => 1],
|
||||
[]
|
||||
],
|
||||
[
|
||||
[0 => null],
|
||||
[]
|
||||
],
|
||||
[
|
||||
[0 => 1, 1 => 2],
|
||||
[0 => 1, 1 => 3]
|
||||
],
|
||||
[
|
||||
['a', 'b' => [1, 2]],
|
||||
['a', 'b' => [2, 1]]
|
||||
],
|
||||
[
|
||||
[2.3],
|
||||
[4.2],
|
||||
0.5
|
||||
],
|
||||
[
|
||||
[[2.3]],
|
||||
[[4.2]],
|
||||
0.5
|
||||
],
|
||||
[
|
||||
[new Struct(2.3)],
|
||||
[new Struct(4.2)],
|
||||
0.5
|
||||
]
|
||||
[
|
||||
[],
|
||||
[0 => 1]
|
||||
],
|
||||
[
|
||||
[0 => 1],
|
||||
[]
|
||||
],
|
||||
[
|
||||
[0 => null],
|
||||
[]
|
||||
],
|
||||
[
|
||||
[0 => 1, 1 => 2],
|
||||
[0 => 1, 1 => 3]
|
||||
],
|
||||
[
|
||||
['a', 'b' => [1, 2]],
|
||||
['a', 'b' => [2, 1]]
|
||||
],
|
||||
[
|
||||
[2.3],
|
||||
[4.2],
|
||||
0.5
|
||||
],
|
||||
[
|
||||
[[2.3]],
|
||||
[[4.2]],
|
||||
0.5
|
||||
],
|
||||
[
|
||||
[new Struct(2.3)],
|
||||
[new Struct(4.2)],
|
||||
0.5
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
*/
|
||||
public function testAcceptsSucceeds()
|
||||
public function testAcceptsSucceeds(): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts([], [])
|
||||
@@ -128,10 +124,9 @@ class ArrayComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -139,10 +134,9 @@ class ArrayComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0, $canonicalize = false)
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0, $canonicalize = false): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -155,10 +149,9 @@ class ArrayComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0, $canonicalize = false)
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0, $canonicalize = false): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage('Failed asserting that two arrays are equal');
|
||||
|
@@ -7,17 +7,18 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @covers \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
*/
|
||||
final class ComparisonFailureTest extends TestCase
|
||||
{
|
||||
public function testComparisonFailure()
|
||||
public function testComparisonFailure(): void
|
||||
{
|
||||
$actual = "\nB\n";
|
||||
$expected = "\nA\n";
|
||||
@@ -49,7 +50,7 @@ final class ComparisonFailureTest extends TestCase
|
||||
$this->assertSame($message . $diff, $failure->toString());
|
||||
}
|
||||
|
||||
public function testDiffNotPossible()
|
||||
public function testDiffNotPossible(): void
|
||||
{
|
||||
$failure = new ComparisonFailure('a', 'b', false, false, true, 'test');
|
||||
$this->assertSame('', $failure->getDiff());
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use DOMDocument;
|
||||
@@ -15,17 +14,20 @@ use DOMNode;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\DOMNodeComparator
|
||||
* @covers \SebastianBergmann\Comparator\DOMNodeComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class DOMNodeComparatorTest extends TestCase
|
||||
final class DOMNodeComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var DOMNodeComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new DOMNodeComparator;
|
||||
}
|
||||
@@ -36,10 +38,10 @@ class DOMNodeComparatorTest extends TestCase
|
||||
$node = new DOMNode;
|
||||
|
||||
return [
|
||||
[$document, $document],
|
||||
[$node, $node],
|
||||
[$document, $node],
|
||||
[$node, $document]
|
||||
[$document, $document],
|
||||
[$node, $node],
|
||||
[$document, $node],
|
||||
[$node, $document]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -48,60 +50,125 @@ class DOMNodeComparatorTest extends TestCase
|
||||
$document = new DOMDocument;
|
||||
|
||||
return [
|
||||
[$document, null],
|
||||
[null, $document],
|
||||
[null, null]
|
||||
[$document, null],
|
||||
[null, $document],
|
||||
[null, null]
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
$this->createDOMDocument('<root></root>'),
|
||||
$this->createDOMDocument('<root/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<root attr="bar"></root>'),
|
||||
$this->createDOMDocument('<root attr="bar"/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<root><foo attr="bar"></foo></root>'),
|
||||
$this->createDOMDocument('<root><foo attr="bar"/></root>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument("<root>\n <child/>\n</root>"),
|
||||
$this->createDOMDocument('<root><child/></root>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<root></root>'),
|
||||
$this->createDOMDocument('<root/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<root attr="bar"></root>'),
|
||||
$this->createDOMDocument('<root attr="bar"/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<root><foo attr="bar"></foo></root>'),
|
||||
$this->createDOMDocument('<root><foo attr="bar"/></root>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument("<root>\n <child/>\n</root>"),
|
||||
$this->createDOMDocument('<root><child/></root>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<Root></Root>'),
|
||||
$this->createDOMDocument('<root></root>'),
|
||||
$ignoreCase = true
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument("<a x='' a=''/>"),
|
||||
$this->createDOMDocument("<a a='' x=''/>"),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
$this->createDOMDocument('<root></root>'),
|
||||
$this->createDOMDocument('<bar/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<foo attr1="bar"/>'),
|
||||
$this->createDOMDocument('<foo attr1="foobar"/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<foo> bar </foo>'),
|
||||
$this->createDOMDocument('<foo />')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<foo xmlns="urn:myns:bar"/>'),
|
||||
$this->createDOMDocument('<foo xmlns="urn:notmyns:bar"/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<foo> bar </foo>'),
|
||||
$this->createDOMDocument('<foo> bir </foo>')
|
||||
]
|
||||
[
|
||||
$this->createDOMDocument('<root></root>'),
|
||||
$this->createDOMDocument('<bar/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<foo attr1="bar"/>'),
|
||||
$this->createDOMDocument('<foo attr1="foobar"/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<foo> bar </foo>'),
|
||||
$this->createDOMDocument('<foo />')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<foo xmlns="urn:myns:bar"/>'),
|
||||
$this->createDOMDocument('<foo xmlns="urn:notmyns:bar"/>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<foo> bar </foo>'),
|
||||
$this->createDOMDocument('<foo> bir </foo>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<Root></Root>'),
|
||||
$this->createDOMDocument('<root></root>')
|
||||
],
|
||||
[
|
||||
$this->createDOMDocument('<root> bar </root>'),
|
||||
$this->createDOMDocument('<root> BAR </root>')
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $ignoreCase = false): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$delta = 0.0;
|
||||
$canonicalize = false;
|
||||
$this->comparator->assertEquals($expected, $actual, $delta, $canonicalize, $ignoreCase);
|
||||
} catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage('Failed asserting that two DOM');
|
||||
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
private function createDOMDocument($content)
|
||||
{
|
||||
$document = new DOMDocument;
|
||||
@@ -110,54 +177,4 @@ class DOMNodeComparatorTest extends TestCase
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
} catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual)
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage('Failed asserting that two DOM');
|
||||
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use DateTime;
|
||||
@@ -16,20 +15,20 @@ use DateTimeZone;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\DateTimeComparator
|
||||
* @covers \SebastianBergmann\Comparator\DateTimeComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class DateTimeComparatorTest extends TestCase
|
||||
final class DateTimeComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var DateTimeComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new DateTimeComparator;
|
||||
}
|
||||
@@ -39,9 +38,9 @@ class DateTimeComparatorTest extends TestCase
|
||||
$datetime = new DateTime;
|
||||
|
||||
return [
|
||||
[$datetime, null],
|
||||
[null, $datetime],
|
||||
[null, null]
|
||||
[$datetime, null],
|
||||
[null, $datetime],
|
||||
[null, null]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -93,6 +92,11 @@ class DateTimeComparatorTest extends TestCase
|
||||
new DateTimeImmutable('2013-03-29 23:01:30', new DateTimeZone('America/Chicago')),
|
||||
100
|
||||
],
|
||||
[
|
||||
new DateTimeImmutable('2013-03-30 12:00:00', new DateTimeZone('UTC')),
|
||||
new DateTimeImmutable('2013-03-30 12:00:00.5', new DateTimeZone('UTC')),
|
||||
0.5
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -146,10 +150,7 @@ class DateTimeComparatorTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
*/
|
||||
public function testAcceptsSucceeds()
|
||||
public function testAcceptsSucceeds(): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts(
|
||||
@@ -160,10 +161,9 @@ class DateTimeComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -171,10 +171,9 @@ class DateTimeComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -187,10 +186,9 @@ class DateTimeComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0)
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage('Failed asserting that two DateTime objects are equal.');
|
||||
@@ -198,20 +196,12 @@ class DateTimeComparatorTest extends TestCase
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.5
|
||||
* @covers ::accepts
|
||||
*/
|
||||
public function testAcceptsDateTimeInterface()
|
||||
public function testAcceptsDateTimeInterface(): void
|
||||
{
|
||||
$this->assertTrue($this->comparator->accepts(new DateTime, new DateTimeImmutable));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.5
|
||||
* @covers ::assertEquals
|
||||
*/
|
||||
public function testSupportsDateTimeInterface()
|
||||
public function testSupportsDateTimeInterface(): void
|
||||
{
|
||||
$this->assertNull(
|
||||
$this->comparator->assertEquals(
|
||||
|
@@ -7,23 +7,25 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\DoubleComparator
|
||||
* @covers \SebastianBergmann\Comparator\DoubleComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class DoubleComparatorTest extends TestCase
|
||||
final class DoubleComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var DoubleComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new DoubleComparator;
|
||||
}
|
||||
@@ -31,65 +33,64 @@ class DoubleComparatorTest extends TestCase
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[0, 5.0],
|
||||
[5.0, 0],
|
||||
['5', 4.5],
|
||||
[1.2e3, 7E-10],
|
||||
[3, \acos(8)],
|
||||
[\acos(8), 3],
|
||||
[\acos(8), \acos(8)]
|
||||
[0, 5.0],
|
||||
[5.0, 0],
|
||||
['5', 4.5],
|
||||
[1.2e3, 7E-10],
|
||||
[3, \acos(8)],
|
||||
[\acos(8), 3],
|
||||
[\acos(8), \acos(8)]
|
||||
];
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[5, 5],
|
||||
['4.5', 5],
|
||||
[0x539, 02471],
|
||||
[5.0, false],
|
||||
[null, 5.0]
|
||||
[5, 5],
|
||||
['4.5', 5],
|
||||
[0x539, 02471],
|
||||
[5.0, false],
|
||||
[null, 5.0]
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[2.3, 2.3],
|
||||
['2.3', 2.3],
|
||||
[5.0, 5],
|
||||
[5, 5.0],
|
||||
[5.0, '5'],
|
||||
[1.2e3, 1200],
|
||||
[2.3, 2.5, 0.5],
|
||||
[3, 3.05, 0.05],
|
||||
[1.2e3, 1201, 1],
|
||||
[(string) (1 / 3), 1 - 2 / 3],
|
||||
[1 / 3, (string) (1 - 2 / 3)]
|
||||
[2.3, 2.3],
|
||||
['2.3', 2.3],
|
||||
[5.0, 5],
|
||||
[5, 5.0],
|
||||
[5.0, '5'],
|
||||
[1.2e3, 1200],
|
||||
[2.3, 2.5, 0.5],
|
||||
[3, 3.05, 0.05],
|
||||
[1.2e3, 1201, 1],
|
||||
[(string) (1 / 3), 1 - 2 / 3],
|
||||
[1 / 3, (string) (1 - 2 / 3)]
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[2.3, 4.2],
|
||||
['2.3', 4.2],
|
||||
[5.0, '4'],
|
||||
[5.0, 6],
|
||||
[1.2e3, 1201],
|
||||
[2.3, 2.5, 0.2],
|
||||
[3, 3.05, 0.04],
|
||||
[3, \acos(8)],
|
||||
[\acos(8), 3],
|
||||
[\acos(8), \acos(8)]
|
||||
[2.3, 4.2],
|
||||
['2.3', 4.2],
|
||||
[5.0, '4'],
|
||||
[5.0, 6],
|
||||
[1.2e3, 1201],
|
||||
[2.3, 2.5, 0.2],
|
||||
[3, 3.05, 0.04],
|
||||
[3, \acos(8)],
|
||||
[\acos(8), 3],
|
||||
[\acos(8), \acos(8)]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
public function testAcceptsSucceeds($expected, $actual): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -97,10 +98,9 @@ class DoubleComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -108,10 +108,9 @@ class DoubleComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -124,10 +123,9 @@ class DoubleComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0)
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage('matches expected');
|
||||
|
@@ -7,25 +7,27 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use \Exception;
|
||||
use \RuntimeException;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ExceptionComparator
|
||||
* @covers \SebastianBergmann\Comparator\ExceptionComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class ExceptionComparatorTest extends TestCase
|
||||
final class ExceptionComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ExceptionComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new ExceptionComparator;
|
||||
$this->comparator->setFactory(new Factory);
|
||||
@@ -34,18 +36,18 @@ class ExceptionComparatorTest extends TestCase
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[new Exception, new Exception],
|
||||
[new RuntimeException, new RuntimeException],
|
||||
[new Exception, new RuntimeException]
|
||||
[new Exception, new Exception],
|
||||
[new RuntimeException, new RuntimeException],
|
||||
[new Exception, new RuntimeException]
|
||||
];
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[new Exception, null],
|
||||
[null, new Exception],
|
||||
[null, null]
|
||||
[new Exception, null],
|
||||
[null, new Exception],
|
||||
[null, null]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -58,10 +60,10 @@ class ExceptionComparatorTest extends TestCase
|
||||
$exception4 = new RuntimeException('Error', 100);
|
||||
|
||||
return [
|
||||
[$exception1, $exception1],
|
||||
[$exception1, $exception2],
|
||||
[$exception3, $exception3],
|
||||
[$exception3, $exception4]
|
||||
[$exception1, $exception1],
|
||||
[$exception1, $exception2],
|
||||
[$exception3, $exception3],
|
||||
[$exception3, $exception4]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -78,19 +80,18 @@ class ExceptionComparatorTest extends TestCase
|
||||
$exception5 = new RuntimeException('Error', 101);
|
||||
|
||||
return [
|
||||
[$exception1, $exception2, $equalMessage],
|
||||
[$exception1, $exception3, $equalMessage],
|
||||
[$exception1, $exception4, $typeMessage],
|
||||
[$exception2, $exception3, $equalMessage],
|
||||
[$exception4, $exception5, $equalMessage]
|
||||
[$exception1, $exception2, $equalMessage],
|
||||
[$exception1, $exception3, $equalMessage],
|
||||
[$exception1, $exception4, $typeMessage],
|
||||
[$exception2, $exception3, $equalMessage],
|
||||
[$exception4, $exception5, $equalMessage]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
public function testAcceptsSucceeds($expected, $actual): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -98,10 +99,9 @@ class ExceptionComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -109,10 +109,9 @@ class ExceptionComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
public function testAssertEqualsSucceeds($expected, $actual): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -125,10 +124,9 @@ class ExceptionComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $message)
|
||||
public function testAssertEqualsFails($expected, $actual, $message): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
|
@@ -7,19 +7,18 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\Factory
|
||||
* @covers \SebastianBergmann\Comparator\Factory
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class FactoryTest extends TestCase
|
||||
final class FactoryTest extends TestCase
|
||||
{
|
||||
public function instanceProvider()
|
||||
{
|
||||
@@ -70,20 +69,15 @@ class FactoryTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider instanceProvider
|
||||
* @covers ::getComparatorFor
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testGetComparatorFor($a, $b, $expected)
|
||||
public function testGetComparatorFor($a, $b, $expected): void
|
||||
{
|
||||
$factory = new Factory;
|
||||
$actual = $factory->getComparatorFor($a, $b);
|
||||
$this->assertInstanceOf($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::register
|
||||
*/
|
||||
public function testRegister()
|
||||
public function testRegister(): void
|
||||
{
|
||||
$comparator = new TestClassComparator;
|
||||
|
||||
@@ -99,10 +93,7 @@ class FactoryTest extends TestCase
|
||||
$this->assertInstanceOf($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::unregister
|
||||
*/
|
||||
public function testUnregister()
|
||||
public function testUnregister(): void
|
||||
{
|
||||
$comparator = new TestClassComparator;
|
||||
|
||||
@@ -118,7 +109,7 @@ class FactoryTest extends TestCase
|
||||
$this->assertInstanceOf($expected, $actual);
|
||||
}
|
||||
|
||||
public function testIsSingleton()
|
||||
public function testIsSingleton(): void
|
||||
{
|
||||
$f = Factory::getInstance();
|
||||
$this->assertSame($f, Factory::getInstance());
|
||||
|
@@ -7,24 +7,26 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\MockObjectComparator
|
||||
* @covers \SebastianBergmann\Comparator\MockObjectComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class MockObjectComparatorTest extends TestCase
|
||||
final class MockObjectComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var MockObjectComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new MockObjectComparator;
|
||||
$this->comparator->setFactory(new Factory);
|
||||
@@ -36,9 +38,9 @@ class MockObjectComparatorTest extends TestCase
|
||||
$stdmock = $this->createMock(stdClass::class);
|
||||
|
||||
return [
|
||||
[$testmock, $testmock],
|
||||
[$stdmock, $stdmock],
|
||||
[$stdmock, $testmock]
|
||||
[$testmock, $testmock],
|
||||
[$stdmock, $stdmock],
|
||||
[$stdmock, $testmock]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -47,9 +49,9 @@ class MockObjectComparatorTest extends TestCase
|
||||
$stdmock = $this->createMock(stdClass::class);
|
||||
|
||||
return [
|
||||
[$stdmock, null],
|
||||
[null, $stdmock],
|
||||
[null, null]
|
||||
[$stdmock, null],
|
||||
[null, $stdmock],
|
||||
[null, null]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -67,15 +69,15 @@ class MockObjectComparatorTest extends TestCase
|
||||
$object2 = $this->getMockBuilder(SampleClass::class)->setMethods(null)->setConstructorArgs([4, 8, 15])->getMock();
|
||||
|
||||
return [
|
||||
[$object1, $object1],
|
||||
[$object1, $object2],
|
||||
[$book1, $book1],
|
||||
[$book1, $book2],
|
||||
[
|
||||
$this->getMockBuilder(Struct::class)->setMethods(null)->setConstructorArgs([2.3])->getMock(),
|
||||
$this->getMockBuilder(Struct::class)->setMethods(null)->setConstructorArgs([2.5])->getMock(),
|
||||
0.5
|
||||
]
|
||||
[$object1, $object1],
|
||||
[$object1, $object2],
|
||||
[$book1, $book1],
|
||||
[$book1, $book2],
|
||||
[
|
||||
$this->getMockBuilder(Struct::class)->setMethods(null)->setConstructorArgs([2.3])->getMock(),
|
||||
$this->getMockBuilder(Struct::class)->setMethods(null)->setConstructorArgs([2.5])->getMock(),
|
||||
0.5
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -101,28 +103,27 @@ class MockObjectComparatorTest extends TestCase
|
||||
$object2 = $this->getMockBuilder(SampleClass::class)->setMethods(null)->setConstructorArgs([16, 23, 42])->getMock();
|
||||
|
||||
return [
|
||||
[
|
||||
$this->getMockBuilder(SampleClass::class)->setMethods(null)->setConstructorArgs([4, 8, 15])->getMock(),
|
||||
$this->getMockBuilder(SampleClass::class)->setMethods(null)->setConstructorArgs([16, 23, 42])->getMock(),
|
||||
$equalMessage
|
||||
],
|
||||
[$object1, $object2, $equalMessage],
|
||||
[$book1, $book2, $equalMessage],
|
||||
[$book3, $book4, $typeMessage],
|
||||
[
|
||||
$this->getMockBuilder(Struct::class)->setMethods(null)->setConstructorArgs([2.3])->getMock(),
|
||||
$this->getMockBuilder(Struct::class)->setMethods(null)->setConstructorArgs([4.2])->getMock(),
|
||||
$equalMessage,
|
||||
0.5
|
||||
]
|
||||
[
|
||||
$this->getMockBuilder(SampleClass::class)->setMethods(null)->setConstructorArgs([4, 8, 15])->getMock(),
|
||||
$this->getMockBuilder(SampleClass::class)->setMethods(null)->setConstructorArgs([16, 23, 42])->getMock(),
|
||||
$equalMessage
|
||||
],
|
||||
[$object1, $object2, $equalMessage],
|
||||
[$book1, $book2, $equalMessage],
|
||||
[$book3, $book4, $typeMessage],
|
||||
[
|
||||
$this->getMockBuilder(Struct::class)->setMethods(null)->setConstructorArgs([2.3])->getMock(),
|
||||
$this->getMockBuilder(Struct::class)->setMethods(null)->setConstructorArgs([4.2])->getMock(),
|
||||
$equalMessage,
|
||||
0.5
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
public function testAcceptsSucceeds($expected, $actual): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -130,10 +131,9 @@ class MockObjectComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -141,10 +141,9 @@ class MockObjectComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -157,10 +156,9 @@ class MockObjectComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $message, $delta = 0.0)
|
||||
public function testAssertEqualsFails($expected, $actual, $message, $delta = 0.0): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
|
@@ -7,23 +7,25 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\NumericComparator
|
||||
* @covers \SebastianBergmann\Comparator\NumericComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class NumericComparatorTest extends TestCase
|
||||
final class NumericComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var NumericComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new NumericComparator;
|
||||
}
|
||||
@@ -31,53 +33,52 @@ class NumericComparatorTest extends TestCase
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[5, 10],
|
||||
[8, '0'],
|
||||
['10', 0],
|
||||
[0x74c3b00c, 42],
|
||||
[0755, 0777]
|
||||
[5, 10],
|
||||
[8, '0'],
|
||||
['10', 0],
|
||||
[0x74c3b00c, 42],
|
||||
[0755, 0777]
|
||||
];
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return [
|
||||
['5', '10'],
|
||||
[8, 5.0],
|
||||
[5.0, 8],
|
||||
[10, null],
|
||||
[false, 12]
|
||||
['5', '10'],
|
||||
[8, 5.0],
|
||||
[5.0, 8],
|
||||
[10, null],
|
||||
[false, 12]
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[1337, 1337],
|
||||
['1337', 1337],
|
||||
[0x539, 1337],
|
||||
[02471, 1337],
|
||||
[1337, 1338, 1],
|
||||
['1337', 1340, 5],
|
||||
[1337, 1337],
|
||||
['1337', 1337],
|
||||
[0x539, 1337],
|
||||
[02471, 1337],
|
||||
[1337, 1338, 1],
|
||||
['1337', 1340, 5],
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[1337, 1338],
|
||||
['1338', 1337],
|
||||
[0x539, 1338],
|
||||
[1337, 1339, 1],
|
||||
['1337', 1340, 2],
|
||||
[1337, 1338],
|
||||
['1338', 1337],
|
||||
[0x539, 1338],
|
||||
[1337, 1339, 1],
|
||||
['1337', 1340, 2],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
public function testAcceptsSucceeds($expected, $actual): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -85,10 +86,9 @@ class NumericComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -96,10 +96,9 @@ class NumericComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -112,10 +111,9 @@ class NumericComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0)
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage('matches expected');
|
||||
|
@@ -7,24 +7,26 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ObjectComparator
|
||||
* @covers \SebastianBergmann\Comparator\ObjectComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class ObjectComparatorTest extends TestCase
|
||||
final class ObjectComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new ObjectComparator;
|
||||
$this->comparator->setFactory(new Factory);
|
||||
@@ -33,18 +35,18 @@ class ObjectComparatorTest extends TestCase
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[new TestClass, new TestClass],
|
||||
[new stdClass, new stdClass],
|
||||
[new stdClass, new TestClass]
|
||||
[new TestClass, new TestClass],
|
||||
[new stdClass, new stdClass],
|
||||
[new stdClass, new TestClass]
|
||||
];
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[new stdClass, null],
|
||||
[null, new stdClass],
|
||||
[null, null]
|
||||
[new stdClass, null],
|
||||
[null, new stdClass],
|
||||
[null, null]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -62,11 +64,11 @@ class ObjectComparatorTest extends TestCase
|
||||
$object2 = new SampleClass(4, 8, 15);
|
||||
|
||||
return [
|
||||
[$object1, $object1],
|
||||
[$object1, $object2],
|
||||
[$book1, $book1],
|
||||
[$book1, $book2],
|
||||
[new Struct(2.3), new Struct(2.5), 0.5]
|
||||
[$object1, $object1],
|
||||
[$object1, $object2],
|
||||
[$book1, $book1],
|
||||
[$book1, $book2],
|
||||
[new Struct(2.3), new Struct(2.5), 0.5]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -92,19 +94,18 @@ class ObjectComparatorTest extends TestCase
|
||||
$object2 = new SampleClass(16, 23, 42);
|
||||
|
||||
return [
|
||||
[new SampleClass(4, 8, 15), new SampleClass(16, 23, 42), $equalMessage],
|
||||
[$object1, $object2, $equalMessage],
|
||||
[$book1, $book2, $equalMessage],
|
||||
[$book3, $book4, $typeMessage],
|
||||
[new Struct(2.3), new Struct(4.2), $equalMessage, 0.5]
|
||||
[new SampleClass(4, 8, 15), new SampleClass(16, 23, 42), $equalMessage],
|
||||
[$object1, $object2, $equalMessage],
|
||||
[$book1, $book2, $equalMessage],
|
||||
[$book3, $book4, $typeMessage],
|
||||
[new Struct(2.3), new Struct(4.2), $equalMessage, 0.5]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
public function testAcceptsSucceeds($expected, $actual): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -112,10 +113,9 @@ class ObjectComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -123,10 +123,9 @@ class ObjectComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -139,10 +138,9 @@ class ObjectComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $message, $delta = 0.0)
|
||||
public function testAssertEqualsFails($expected, $actual, $message, $delta = 0.0): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
|
@@ -7,23 +7,25 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ResourceComparator
|
||||
* @covers \SebastianBergmann\Comparator\ResourceComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class ResourceComparatorTest extends TestCase
|
||||
final class ResourceComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ResourceComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new ResourceComparator;
|
||||
}
|
||||
@@ -34,9 +36,9 @@ class ResourceComparatorTest extends TestCase
|
||||
$tmpfile2 = \tmpfile();
|
||||
|
||||
return [
|
||||
[$tmpfile1, $tmpfile1],
|
||||
[$tmpfile2, $tmpfile2],
|
||||
[$tmpfile1, $tmpfile2]
|
||||
[$tmpfile1, $tmpfile1],
|
||||
[$tmpfile2, $tmpfile2],
|
||||
[$tmpfile1, $tmpfile2]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -45,9 +47,9 @@ class ResourceComparatorTest extends TestCase
|
||||
$tmpfile1 = \tmpfile();
|
||||
|
||||
return [
|
||||
[$tmpfile1, null],
|
||||
[null, $tmpfile1],
|
||||
[null, null]
|
||||
[$tmpfile1, null],
|
||||
[null, $tmpfile1],
|
||||
[null, null]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -57,8 +59,8 @@ class ResourceComparatorTest extends TestCase
|
||||
$tmpfile2 = \tmpfile();
|
||||
|
||||
return [
|
||||
[$tmpfile1, $tmpfile1],
|
||||
[$tmpfile2, $tmpfile2]
|
||||
[$tmpfile1, $tmpfile1],
|
||||
[$tmpfile2, $tmpfile2]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -68,16 +70,15 @@ class ResourceComparatorTest extends TestCase
|
||||
$tmpfile2 = \tmpfile();
|
||||
|
||||
return [
|
||||
[$tmpfile1, $tmpfile2],
|
||||
[$tmpfile2, $tmpfile1]
|
||||
[$tmpfile1, $tmpfile2],
|
||||
[$tmpfile2, $tmpfile1]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
public function testAcceptsSucceeds($expected, $actual): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -85,10 +86,9 @@ class ResourceComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -96,10 +96,9 @@ class ResourceComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
public function testAssertEqualsSucceeds($expected, $actual): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -112,10 +111,9 @@ class ResourceComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual)
|
||||
public function testAssertEqualsFails($expected, $actual): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
|
||||
|
@@ -7,23 +7,25 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ScalarComparator
|
||||
* @covers \SebastianBergmann\Comparator\ScalarComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class ScalarComparatorTest extends TestCase
|
||||
final class ScalarComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ScalarComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new ScalarComparator;
|
||||
}
|
||||
@@ -31,55 +33,55 @@ class ScalarComparatorTest extends TestCase
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
['string', 'string'],
|
||||
[new ClassWithToString, 'string'],
|
||||
['string', new ClassWithToString],
|
||||
['string', null],
|
||||
[false, 'string'],
|
||||
[false, true],
|
||||
[null, false],
|
||||
[null, null],
|
||||
['10', 10],
|
||||
['', false],
|
||||
['1', true],
|
||||
[1, true],
|
||||
[0, false],
|
||||
[0.1, '0.1']
|
||||
['string', 'string'],
|
||||
[new ClassWithToString, 'string'],
|
||||
['string', new ClassWithToString],
|
||||
['string', null],
|
||||
[false, 'string'],
|
||||
[false, true],
|
||||
[null, false],
|
||||
[null, null],
|
||||
['10', 10],
|
||||
['', false],
|
||||
['1', true],
|
||||
[1, true],
|
||||
[0, false],
|
||||
[0.1, '0.1']
|
||||
];
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[[], []],
|
||||
['string', []],
|
||||
[new ClassWithToString, new ClassWithToString],
|
||||
[false, new ClassWithToString],
|
||||
[\tmpfile(), \tmpfile()]
|
||||
[[], []],
|
||||
['string', []],
|
||||
[new ClassWithToString, new ClassWithToString],
|
||||
[false, new ClassWithToString],
|
||||
[\tmpfile(), \tmpfile()]
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
['string', 'string'],
|
||||
[new ClassWithToString, new ClassWithToString],
|
||||
['string representation', new ClassWithToString],
|
||||
[new ClassWithToString, 'string representation'],
|
||||
['string', 'STRING', true],
|
||||
['STRING', 'string', true],
|
||||
['String Representation', new ClassWithToString, true],
|
||||
[new ClassWithToString, 'String Representation', true],
|
||||
['10', 10],
|
||||
['', false],
|
||||
['1', true],
|
||||
[1, true],
|
||||
[0, false],
|
||||
[0.1, '0.1'],
|
||||
[false, null],
|
||||
[false, false],
|
||||
[true, true],
|
||||
[null, null]
|
||||
['string', 'string'],
|
||||
[new ClassWithToString, new ClassWithToString],
|
||||
['string representation', new ClassWithToString],
|
||||
[new ClassWithToString, 'string representation'],
|
||||
['string', 'STRING', true],
|
||||
['STRING', 'string', true],
|
||||
['String Representation', new ClassWithToString, true],
|
||||
[new ClassWithToString, 'String Representation', true],
|
||||
['10', 10],
|
||||
['', false],
|
||||
['1', true],
|
||||
[1, true],
|
||||
[0, false],
|
||||
[0.1, '0.1'],
|
||||
[false, null],
|
||||
[false, false],
|
||||
[true, true],
|
||||
[null, null]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -89,31 +91,35 @@ class ScalarComparatorTest extends TestCase
|
||||
$otherException = 'matches expected';
|
||||
|
||||
return [
|
||||
['string', 'other string', $stringException],
|
||||
['string', 'STRING', $stringException],
|
||||
['STRING', 'string', $stringException],
|
||||
['string', 'other string', $stringException],
|
||||
// https://github.com/sebastianbergmann/phpunit/issues/1023
|
||||
['9E6666666','9E7777777', $stringException],
|
||||
[new ClassWithToString, 'does not match', $otherException],
|
||||
['does not match', new ClassWithToString, $otherException],
|
||||
[0, 'Foobar', $otherException],
|
||||
['Foobar', 0, $otherException],
|
||||
['10', 25, $otherException],
|
||||
['1', false, $otherException],
|
||||
['', true, $otherException],
|
||||
[false, true, $otherException],
|
||||
[true, false, $otherException],
|
||||
[null, true, $otherException],
|
||||
[0, true, $otherException]
|
||||
['string', 'other string', $stringException],
|
||||
['string', 'STRING', $stringException],
|
||||
['STRING', 'string', $stringException],
|
||||
['string', 'other string', $stringException],
|
||||
// https://github.com/sebastianbergmann/phpunit/issues/1023
|
||||
['9E6666666', '9E7777777', $stringException],
|
||||
[new ClassWithToString, 'does not match', $otherException],
|
||||
['does not match', new ClassWithToString, $otherException],
|
||||
[0, 'Foobar', $otherException],
|
||||
['Foobar', 0, $otherException],
|
||||
['10', 25, $otherException],
|
||||
['1', false, $otherException],
|
||||
['', true, $otherException],
|
||||
[false, true, $otherException],
|
||||
[true, false, $otherException],
|
||||
[null, true, $otherException],
|
||||
[0, true, $otherException],
|
||||
['0', '0.0', $stringException],
|
||||
['0.', '0.0', $stringException],
|
||||
['0e1', '0e2', $stringException],
|
||||
["\n\n\n0.0", ' 0.', $stringException],
|
||||
['0.0', '25e-10000', $stringException],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
public function testAcceptsSucceeds($expected, $actual): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -121,10 +127,9 @@ class ScalarComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -132,10 +137,9 @@ class ScalarComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $ignoreCase = false)
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $ignoreCase = false): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -148,10 +152,9 @@ class ScalarComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $message)
|
||||
public function testAssertEqualsFails($expected, $actual, $message): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -15,17 +14,20 @@ use SplObjectStorage;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\SplObjectStorageComparator
|
||||
* @covers \SebastianBergmann\Comparator\SplObjectStorageComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class SplObjectStorageComparatorTest extends TestCase
|
||||
final class SplObjectStorageComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var SplObjectStorageComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new SplObjectStorageComparator;
|
||||
}
|
||||
@@ -33,9 +35,9 @@ class SplObjectStorageComparatorTest extends TestCase
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[new SplObjectStorage, new stdClass],
|
||||
[new stdClass, new SplObjectStorage],
|
||||
[new stdClass, new stdClass]
|
||||
[new SplObjectStorage, new stdClass],
|
||||
[new stdClass, new SplObjectStorage],
|
||||
[new stdClass, new stdClass]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -56,10 +58,10 @@ class SplObjectStorageComparatorTest extends TestCase
|
||||
$storage4->attach($object1);
|
||||
|
||||
return [
|
||||
[$storage1, $storage1],
|
||||
[$storage1, $storage2],
|
||||
[$storage3, $storage3],
|
||||
[$storage3, $storage4]
|
||||
[$storage1, $storage1],
|
||||
[$storage1, $storage2],
|
||||
[$storage3, $storage3],
|
||||
[$storage3, $storage4]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -78,16 +80,13 @@ class SplObjectStorageComparatorTest extends TestCase
|
||||
$storage3->attach($object1);
|
||||
|
||||
return [
|
||||
[$storage1, $storage2],
|
||||
[$storage1, $storage3],
|
||||
[$storage2, $storage3],
|
||||
[$storage1, $storage2],
|
||||
[$storage1, $storage3],
|
||||
[$storage2, $storage3],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
*/
|
||||
public function testAcceptsSucceeds()
|
||||
public function testAcceptsSucceeds(): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts(
|
||||
@@ -98,10 +97,9 @@ class SplObjectStorageComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
public function testAcceptsFails($expected, $actual): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -109,10 +107,9 @@ class SplObjectStorageComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
public function testAssertEqualsSucceeds($expected, $actual): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -125,10 +122,9 @@ class SplObjectStorageComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual)
|
||||
public function testAssertEqualsFails($expected, $actual): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage('Failed asserting that two objects are equal.');
|
||||
@@ -136,7 +132,7 @@ class SplObjectStorageComparatorTest extends TestCase
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testAssertEqualsFails2()
|
||||
public function testAssertEqualsFails2(): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage('Failed asserting that two objects are equal.');
|
||||
|
@@ -7,24 +7,26 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\TypeComparator
|
||||
* @covers \SebastianBergmann\Comparator\TypeComparator<extended>
|
||||
*
|
||||
* @uses SebastianBergmann\Comparator\Comparator
|
||||
* @uses SebastianBergmann\Comparator\Factory
|
||||
* @uses SebastianBergmann\Comparator\ComparisonFailure
|
||||
* @uses \SebastianBergmann\Comparator\Comparator
|
||||
* @uses \SebastianBergmann\Comparator\Factory
|
||||
* @uses \SebastianBergmann\Comparator\ComparisonFailure
|
||||
*/
|
||||
class TypeComparatorTest extends TestCase
|
||||
final class TypeComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var TypeComparator
|
||||
*/
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comparator = new TypeComparator;
|
||||
}
|
||||
@@ -32,46 +34,45 @@ class TypeComparatorTest extends TestCase
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[true, 1],
|
||||
[false, [1]],
|
||||
[null, new stdClass],
|
||||
[1.0, 5],
|
||||
['', '']
|
||||
[true, 1],
|
||||
[false, [1]],
|
||||
[null, new stdClass],
|
||||
[1.0, 5],
|
||||
['', '']
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return [
|
||||
[true, true],
|
||||
[true, false],
|
||||
[false, false],
|
||||
[null, null],
|
||||
[new stdClass, new stdClass],
|
||||
[0, 0],
|
||||
[1.0, 2.0],
|
||||
['hello', 'world'],
|
||||
['', ''],
|
||||
[[], [1,2,3]]
|
||||
[true, true],
|
||||
[true, false],
|
||||
[false, false],
|
||||
[null, null],
|
||||
[new stdClass, new stdClass],
|
||||
[0, 0],
|
||||
[1.0, 2.0],
|
||||
['hello', 'world'],
|
||||
['', ''],
|
||||
[[], [1, 2, 3]]
|
||||
];
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return [
|
||||
[true, null],
|
||||
[null, false],
|
||||
[1.0, 0],
|
||||
[new stdClass, []],
|
||||
['1', 1]
|
||||
[true, null],
|
||||
[null, false],
|
||||
[1.0, 0],
|
||||
[new stdClass, []],
|
||||
['1', 1]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
public function testAcceptsSucceeds($expected, $actual): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
@@ -79,10 +80,9 @@ class TypeComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
public function testAssertEqualsSucceeds($expected, $actual): void
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
@@ -95,10 +95,9 @@ class TypeComparatorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual)
|
||||
public function testAssertEqualsFails($expected, $actual): void
|
||||
{
|
||||
$this->expectException(ComparisonFailure::class);
|
||||
$this->expectExceptionMessage('does not match expected type');
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
@@ -16,5 +15,5 @@ namespace SebastianBergmann\Comparator;
|
||||
class Book
|
||||
{
|
||||
// the order of properties is important for testing the cycle!
|
||||
public $author = null;
|
||||
public $author;
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
class ClassWithToString
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
@@ -16,7 +15,9 @@ namespace SebastianBergmann\Comparator;
|
||||
class SampleClass
|
||||
{
|
||||
public $a;
|
||||
|
||||
protected $b;
|
||||
|
||||
protected $c;
|
||||
|
||||
public function __construct($a, $b, $c)
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
class TestClass
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
class TestClassComparator extends ObjectComparator
|
||||
|
Reference in New Issue
Block a user