exceptions
1 year ago
ArrayComparator.php
1 year ago
Comparator.php
1 year ago
ComparisonFailure.php
1 year ago
DOMNodeComparator.php
1 year ago
DateTimeComparator.php
1 year ago
DoubleComparator.php
1 year ago
ExceptionComparator.php
1 year ago
Factory.php
1 year ago
MockObjectComparator.php
1 year ago
NumericComparator.php
1 year ago
ObjectComparator.php
1 year ago
ResourceComparator.php
1 year ago
ScalarComparator.php
1 year ago
SplObjectStorageComparator.php
1 year ago
TypeComparator.php
1 year ago
MockObjectComparator.php
49 lines
| 1 | <?php declare(strict_types=1); |
| 2 | /* |
| 3 | * This file is part of sebastian/comparator. |
| 4 | * |
| 5 | * (c) Sebastian Bergmann <sebastian@phpunit.de> |
| 6 | * |
| 7 | * For the full copyright and license information, please view the LICENSE |
| 8 | * file that was distributed with this source code. |
| 9 | */ |
| 10 | namespace SebastianBergmann\Comparator; |
| 11 | |
| 12 | use PHPUnit\Framework\MockObject\MockObject; |
| 13 | |
| 14 | /** |
| 15 | * Compares PHPUnit\Framework\MockObject\MockObject instances for equality. |
| 16 | */ |
| 17 | class MockObjectComparator extends ObjectComparator |
| 18 | { |
| 19 | /** |
| 20 | * Returns whether the comparator can compare two values. |
| 21 | * |
| 22 | * @param mixed $expected The first value to compare |
| 23 | * @param mixed $actual The second value to compare |
| 24 | * |
| 25 | * @return bool |
| 26 | */ |
| 27 | public function accepts($expected, $actual) |
| 28 | { |
| 29 | return $expected instanceof MockObject && $actual instanceof MockObject; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Converts an object to an array containing all of its private, protected |
| 34 | * and public properties. |
| 35 | * |
| 36 | * @param object $object |
| 37 | * |
| 38 | * @return array |
| 39 | */ |
| 40 | protected function toArray($object) |
| 41 | { |
| 42 | $array = parent::toArray($object); |
| 43 | |
| 44 | unset($array['__phpunit_invocationMocker']); |
| 45 | |
| 46 | return $array; |
| 47 | } |
| 48 | } |
| 49 |