1<?php
2/*
3 * This file is part of the Comparator package.
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
11namespace SebastianBergmann\Comparator;
12
13/**
14 * Compares PHPUnit_Framework_MockObject_MockObject instances for equality.
15 */
16class MockObjectComparator extends ObjectComparator
17{
18    /**
19     * Returns whether the comparator can compare two values.
20     *
21     * @param  mixed $expected The first value to compare
22     * @param  mixed $actual   The second value to compare
23     * @return bool
24     */
25    public function accepts($expected, $actual)
26    {
27        return $expected instanceof \PHPUnit_Framework_MockObject_MockObject && $actual instanceof \PHPUnit_Framework_MockObject_MockObject;
28    }
29
30    /**
31     * Converts an object to an array containing all of its private, protected
32     * and public properties.
33     *
34     * @param  object $object
35     * @return array
36     */
37    protected function toArray($object)
38    {
39        $array = parent::toArray($object);
40
41        unset($array['__phpunit_invocationMocker']);
42
43        return $array;
44    }
45}