3
* This file is part of the Comparator package.
5
* (c) Sebastian Bergmann <sebastian@phpunit.de>
7
* For the full copyright and license information, please view the LICENSE
8
* file that was distributed with this source code.
11
namespace SebastianBergmann\Comparator;
14
* @coversDefaultClass SebastianBergmann\Comparator\ArrayComparator
17
* @author Jeff Welch <whatthejeff@gmail.com>
18
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
19
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
20
* @link http://www.github.com/sebastianbergmann/comparator
22
class ArrayComparatorTest extends \PHPUnit_Framework_TestCase
26
protected function setUp()
28
$this->comparator = new ArrayComparator;
29
$this->comparator->setFactory(new Factory);
32
public function acceptsFailsProvider()
41
public function assertEqualsSucceedsProvider()
45
array('a' => 1, 'b' => 2),
46
array('b' => 2, 'a' => 1)
69
array(new Struct(2.3)),
70
array(new Struct(2.5)),
76
public function assertEqualsFailsProvider()
92
array(0 => 1, 1 => 2),
96
array('a', 'b' => array(1, 2)),
97
array('a', 'b' => array(2, 1))
110
array(new Struct(2.3)),
111
array(new Struct(4.2)),
120
public function testAcceptsSucceeds()
123
$this->comparator->accepts(array(), array())
129
* @dataProvider acceptsFailsProvider
131
public function testAcceptsFails($expected, $actual)
134
$this->comparator->accepts($expected, $actual)
139
* @covers ::assertEquals
140
* @dataProvider assertEqualsSucceedsProvider
142
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0, $canonicalize = false)
147
$this->comparator->assertEquals($expected, $actual, $delta, $canonicalize);
150
catch (ComparisonFailure $exception) {
153
$this->assertNull($exception, 'Unexpected ComparisonFailure');
157
* @covers ::assertEquals
158
* @dataProvider assertEqualsFailsProvider
160
public function testAssertEqualsFails($expected, $actual,$delta = 0.0, $canonicalize = false)
162
$this->setExpectedException(
163
'SebastianBergmann\\Comparator\\ComparisonFailure',
164
'Failed asserting that two arrays are equal'
166
$this->comparator->assertEquals($expected, $actual, $delta, $canonicalize);