Skip to content

Commit

Permalink
Merge pull request #41 from Codeception/feature/specialized-assert-eq…
Browse files Browse the repository at this point in the history
…uals

Add specialized assertEquals methods
  • Loading branch information
Naktibalda authored Aug 24, 2019
2 parents fa0bb94 + 64d1d94 commit 532e526
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ verify($user->getRoles())->notEmpty();
* notString
* notScalar
* notCallable
* equalsCanonicalizing
* notEqualsCanonicalizing
* equalsIgnoringCase
* notEqualsIgnoringCase
* equalsWithDelta
* notEqualsWithDelta
```

Shorthands for testing truth/fallacy:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"require": {
"php": ">= 7.0",
"phpunit/phpunit": "> 6.0",
"codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.4"
"codeception/phpunit-wrapper": ">6.0.16 <6.1.0 | ^6.7.0 | ^7.7.1 | ^8.0.4"
},
"autoload": {
"files": ["src/Codeception/function.php"],
Expand Down
30 changes: 30 additions & 0 deletions src/Codeception/Verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,34 @@ public function notCallable()
{
a::assertIsNotCallable($this->actual, $this->description);
}

public function equalsCanonicalizing($expected)
{
a::assertEqualsCanonicalizing($expected, $this->actual, $this->description);
}

public function notEqualsCanonicalizing($expected)
{
a::assertNotEqualsCanonicalizing($expected, $this->actual, $this->description);
}

public function equalsIgnoringCase($expected)
{
a::assertEqualsIgnoringCase($expected, $this->actual, $this->description);
}

public function notEqualsIgnoringCase($expected)
{
a::assertNotEqualsIgnoringCase($expected, $this->actual, $this->description);
}

public function equalsWithDelta($expected, $delta)
{
a::assertEqualsWithDelta($expected, $this->actual, $delta, $this->description);
}

public function notEqualsWithDelta($expected, $delta)
{
a::assertNotEqualsWithDelta($expected, $this->actual, $delta, $this->description);
}
}
30 changes: 30 additions & 0 deletions tests/VerifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,36 @@ public function testIsCallable()
verify(function() {})->callable();
verify(false)->notCallable();
}

public function testEqualsCanonicalizing()
{
verify([3, 2, 1])->equalsCanonicalizing([1, 2, 3]);
}

public function testNotEqualsCanonicalizing()
{
verify([3, 2, 1])->notEqualsCanonicalizing([2, 3, 0, 1]);
}

public function testEqualsIgnoringCase()
{
verify('foo')->equalsIgnoringCase('FOO');
}

public function testNotEqualsIgnoringCase()
{
verify('foo')->notEqualsIgnoringCase('BAR');
}

public function testEqualsWithDelta()
{
verify(1.01)->equalsWithDelta(1.0, 0.1);
}

public function testNotEqualsWithDelta()
{
verify(1.2)->notEqualsWithDelta(1.0, 0.1);
}
}


Expand Down

0 comments on commit 532e526

Please sign in to comment.