Skip to content

Commit 532e526

Browse files
authored
Merge pull request #41 from Codeception/feature/specialized-assert-equals
Add specialized assertEquals methods
2 parents fa0bb94 + 64d1d94 commit 532e526

4 files changed

Lines changed: 67 additions & 1 deletion

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ verify($user->getRoles())->notEmpty();
6868
* notString
6969
* notScalar
7070
* notCallable
71+
* equalsCanonicalizing
72+
* notEqualsCanonicalizing
73+
* equalsIgnoringCase
74+
* notEqualsIgnoringCase
75+
* equalsWithDelta
76+
* notEqualsWithDelta
7177
```
7278

7379
Shorthands for testing truth/fallacy:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"require": {
1212
"php": ">= 7.0",
1313
"phpunit/phpunit": "> 6.0",
14-
"codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.4"
14+
"codeception/phpunit-wrapper": ">6.0.16 <6.1.0 | ^6.7.0 | ^7.7.1 | ^8.0.4"
1515
},
1616
"autoload": {
1717
"files": ["src/Codeception/function.php"],

src/Codeception/Verify.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,4 +427,34 @@ public function notCallable()
427427
{
428428
a::assertIsNotCallable($this->actual, $this->description);
429429
}
430+
431+
public function equalsCanonicalizing($expected)
432+
{
433+
a::assertEqualsCanonicalizing($expected, $this->actual, $this->description);
434+
}
435+
436+
public function notEqualsCanonicalizing($expected)
437+
{
438+
a::assertNotEqualsCanonicalizing($expected, $this->actual, $this->description);
439+
}
440+
441+
public function equalsIgnoringCase($expected)
442+
{
443+
a::assertEqualsIgnoringCase($expected, $this->actual, $this->description);
444+
}
445+
446+
public function notEqualsIgnoringCase($expected)
447+
{
448+
a::assertNotEqualsIgnoringCase($expected, $this->actual, $this->description);
449+
}
450+
451+
public function equalsWithDelta($expected, $delta)
452+
{
453+
a::assertEqualsWithDelta($expected, $this->actual, $delta, $this->description);
454+
}
455+
456+
public function notEqualsWithDelta($expected, $delta)
457+
{
458+
a::assertNotEqualsWithDelta($expected, $this->actual, $delta, $this->description);
459+
}
430460
}

tests/VerifyTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,36 @@ public function testIsCallable()
290290
verify(function() {})->callable();
291291
verify(false)->notCallable();
292292
}
293+
294+
public function testEqualsCanonicalizing()
295+
{
296+
verify([3, 2, 1])->equalsCanonicalizing([1, 2, 3]);
297+
}
298+
299+
public function testNotEqualsCanonicalizing()
300+
{
301+
verify([3, 2, 1])->notEqualsCanonicalizing([2, 3, 0, 1]);
302+
}
303+
304+
public function testEqualsIgnoringCase()
305+
{
306+
verify('foo')->equalsIgnoringCase('FOO');
307+
}
308+
309+
public function testNotEqualsIgnoringCase()
310+
{
311+
verify('foo')->notEqualsIgnoringCase('BAR');
312+
}
313+
314+
public function testEqualsWithDelta()
315+
{
316+
verify(1.01)->equalsWithDelta(1.0, 0.1);
317+
}
318+
319+
public function testNotEqualsWithDelta()
320+
{
321+
verify(1.2)->notEqualsWithDelta(1.0, 0.1);
322+
}
293323
}
294324

295325

0 commit comments

Comments
 (0)