Completed
Push — master ( d4745e...9b9256 )
by
unknown
27s
created

ComparableComparerTest::unequalProvider()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 24
rs 8.9713
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
3
namespace Diff\Tests\Comparer;
4
5
use Diff\Comparer\ComparableComparer;
6
use Diff\Tests\DiffTestCase;
7
use Diff\Tests\Fixtures\StubComparable;
8
9
/**
10
 * @covers Diff\Comparer\ComparableComparer
11
 *
12
 * @group Diff
13
 * @group Comparer
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class ComparableComparerTest extends DiffTestCase {
19
20
	/**
21
	 * @dataProvider equalProvider
22
	 */
23
	public function testEqualValuesAreEqual( $firstValue, $secondValue ) {
24
		$comparer = new ComparableComparer();
25
26
		$this->assertTrue( $comparer->valuesAreEqual( $firstValue, $secondValue ) );
27
	}
28
29
	public function equalProvider() {
30
		return array(
31
			array(
32
				new StubComparable( 100 ),
33
				new StubComparable( 100 ),
34
			),
35
			array(
36
				new StubComparable( 'abc' ),
37
				new StubComparable( 'abc' ),
38
			),
39
			array(
40
				new StubComparable( null ),
41
				new StubComparable( null ),
42
			),
43
		);
44
	}
45
46
	/**
47
	 * @dataProvider unequalProvider
48
	 */
49
	public function testDifferentValuesAreNotEqual( $firstValue, $secondValue ) {
50
		$comparer = new ComparableComparer();
51
52
		$this->assertFalse( $comparer->valuesAreEqual( $firstValue, $secondValue ) );
53
	}
54
55
	public function unequalProvider() {
56
		return array(
57
			array(
58
				null,
59
				null
60
			),
61
			array(
62
				new StubComparable( 1 ),
63
				null
64
			),
65
			array(
66
				new StubComparable( 1 ),
67
				new StubComparable( 2 ),
68
			),
69
			array(
70
				new StubComparable( 1 ),
71
				new StubComparable( '1' ),
72
			),
73
			array(
74
				new StubComparable( null ),
75
				new StubComparable( false ),
76
			),
77
		);
78
	}
79
80
}
81