Skip to content

Commit

Permalink
refactor: rearrange assertAll params, make assert optional in key
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Feb 28, 2019
1 parent 3260cdf commit 99a31a2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Asserts.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ public function assertArrayHasKeys(array $expectedKeys, array $actualArray, stri
}
}

public function assertAll($actual, array $assertions, array $messages = [])
public function assertAll(array $expectations, $actual, array $messages = [])
{
foreach ($assertions as $assert => $expected) {
$this->{$assert}($expected, $actual, $messages[$assert] ?? null);
foreach ($expectations as $assert => $expected) {
if (strpos($assert, 'assert') === false) {
$assert = 'assert' . ucfirst($assert);
}

$msgKey = \str_replace('assert', '', $assert);

$this->{$assert}($expected, $actual, $messages[$assert] ?? $messages[$msgKey] ?? null);
}
}
}

0 comments on commit 99a31a2

Please sign in to comment.