Closed viniciusalonso closed 4 years ago
I was working in some exercises using TDD and I needed to write an example like this:
$rule = $this->prophesize(MultipleThreeRule::class); $rule->condition(Argument::that(function($arg) { return in_array($arg, [3, 6, 9, 12]); }))->willReturn(true);
The idea is guarantee that a value is in array.
$rule->condition(12); // returns true
Then, I implemented an easier way to get to same result:
$rule = $this->prophesize(MultipleThreeRule::class); $rule->condition(Argument::in([3, 6, 9, 12]))->willReturn(true);
And I also I implemented the opposite way, when value is not in array:
$rule = $this->prophesize(MultipleThreeRule::class); $rule->condition(Argument::notIn([3, 6, 9, 12]))->willReturn(false);
Thanks @viniciusalonso - looks good
I was working in some exercises using TDD and I needed to write an example like this:
The idea is guarantee that a value is in array.
Then, I implemented an easier way to get to same result:
And I also I implemented the opposite way, when value is not in array: