Skip to content

Commit a0323ed

Browse files
committed
Add TupleSort test
1 parent c07c8ac commit a0323ed

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

tests/Diff/DiffUtilsTest.php

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?php
2+
3+
namespace Tests\Diff;
4+
5+
use jblond\Diff\DiffUtils;
6+
use PHPUnit\Framework\TestCase;
7+
8+
/**
9+
* PHPUnit Test for Diff Utils of PHP DiffLib.
10+
*
11+
* PHP version 7.3 or greater
12+
*
13+
* @package Tests\Diff
14+
* @author Mario Brandt <[email protected]>
15+
* @author Ferry Cools <[email protected]>
16+
* @copyright (c) 2021 Mario Brandt
17+
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
18+
* @version 2.4.0
19+
* @link https://github.com/JBlond/php-diff
20+
*/
21+
class DiffUtilsTest extends TestCase
22+
{
23+
/**
24+
* Test the sorting of an array by the nested arrays it contains
25+
*/
26+
public function testTupleSort(): void
27+
{
28+
$this->assertEquals(
29+
1,
30+
DiffUtils::tupleSort(
31+
[
32+
33+
0 => [
34+
'hashtag' => 'a7e87329b5eab8578f4f1098a152d6f4',
35+
'title' => 'Flower',
36+
'order' => 3,
37+
],
38+
1 => [
39+
'hashtag' => 'b24ce0cd392a5b0b8dedc66c25213594',
40+
'title' => 'Free',
41+
'order' => 2,
42+
],
43+
44+
2 => [
45+
'hashtag' => 'e7d31fc0602fb2ede144d18cdffd816b',
46+
'title' => 'Ready',
47+
'order' => 1
48+
]
49+
],
50+
[
51+
52+
0 => [
53+
'hashtag' => 'a7e87329b5eab8578f4f1098a152d6f4',
54+
'title' => 'Flower',
55+
'order' => 3,
56+
],
57+
1 => [
58+
'hashtag' => 'b24ce0cd392a5b0b8dedc66c25213594',
59+
'title' => 'Free',
60+
'order' => 2,
61+
],
62+
63+
2 => [
64+
]
65+
],
66+
)
67+
);
68+
69+
$this->assertEquals(
70+
0,
71+
DiffUtils::tupleSort(
72+
[
73+
74+
0 => [
75+
'hashtag' => 'a7e87329b5eab8578f4f1098a152d6f4',
76+
'title' => 'Flower',
77+
'order' => 3,
78+
],
79+
1 => [
80+
'hashtag' => 'b24ce0cd392a5b0b8dedc66c25213594',
81+
'title' => 'Free',
82+
'order' => 2,
83+
],
84+
85+
2 => [
86+
'hashtag' => 'e7d31fc0602fb2ede144d18cdffd816b',
87+
'title' => 'Ready',
88+
'order' => 1
89+
]
90+
],
91+
[
92+
93+
0 => [
94+
'hashtag' => 'a7e87329b5eab8578f4f1098a152d6f4',
95+
'title' => 'Flower',
96+
'order' => 3,
97+
],
98+
1 => [
99+
'hashtag' => 'b24ce0cd392a5b0b8dedc66c25213594',
100+
'title' => 'Free',
101+
'order' => 2,
102+
],
103+
104+
2 => [
105+
'hashtag' => 'e7d31fc0602fb2ede144d18cdffd816b',
106+
'title' => 'Ready',
107+
'order' => 1
108+
]
109+
],
110+
)
111+
);
112+
113+
$this->assertEquals(
114+
-1,
115+
DiffUtils::tupleSort(
116+
[
117+
118+
0 => [
119+
'hashtag' => 'a7e87329b5eab8578f4f1098a152d6f4',
120+
'title' => 'Flower',
121+
'order' => 3,
122+
],
123+
1 => [
124+
'hashtag' => 'b24ce0cd392a5b0b8dedc66c25213594',
125+
'title' => 'Free',
126+
'order' => 2,
127+
],
128+
129+
2 => [
130+
131+
]
132+
],
133+
[
134+
135+
0 => [
136+
'hashtag' => 'a7e87329b5eab8578f4f1098a152d6f4',
137+
'title' => 'Flower',
138+
'order' => 3,
139+
],
140+
1 => [
141+
'hashtag' => 'b24ce0cd392a5b0b8dedc66c25213594',
142+
'title' => 'Free',
143+
'order' => 2,
144+
],
145+
146+
2 => [
147+
'hashtag' => 'e7d31fc0602fb2ede144d18cdffd816b',
148+
'title' => 'Ready',
149+
'order' => 1
150+
]
151+
],
152+
)
153+
);
154+
}
155+
}

0 commit comments

Comments
 (0)