Skip to content

Commit 925d699

Browse files
committed
test(unit) add more coverage for replaceInOrder method
1 parent 63e8a13 commit 925d699

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

tests/tad/FunctionMocker/FunctionReplacementInOrderTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function returnValues()
2727
* @test
2828
* @dataProvider returnValues
2929
*/
30-
public function replace_function_should_be_retunr_values_in_order( $values ) {
30+
public function replace_function_should_be_return_values_in_order(array $values) {
3131
$f = 'Some\Name\Space\func' . uniqid(rand(1, 9999));
3232
$spy = FunctionMocker::replaceInOrder( $f, $values );
3333

@@ -38,4 +38,17 @@ public function replace_function_should_be_retunr_values_in_order( $values ) {
3838
$spy->wasCalledTimes(count($values));
3939
}
4040

41+
/**
42+
* Test replace static methods should replace values in order
43+
* @dataProvider returnValues
44+
*/
45+
public function test_replace_static_methods_should_replace_values_in_order(array $values) {
46+
$f = 'tad\FunctionMocker\Tests\AClass::staticMethod';
47+
$spy = FunctionMocker::replaceInOrder( $f, $values );
48+
49+
foreach ( $values as $value ) {
50+
$this->assertEquals( $value, $f() );
51+
}
52+
$spy->wasCalledTimes(count($values));
53+
}
4154
}

tests/tad/FunctionMocker/FunctionReplacementTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,19 @@ public function allow_replacing_a_non_defined_namespaced_function()
158158
$this->assertEquals(2324, $f());
159159
$spy->wasCalledOnce();
160160
}
161+
162+
/**
163+
* It should allow replacing a function result w/ an array
164+
*
165+
* @test
166+
*/
167+
public function should_allow_replacing_a_function_result_w_an_array() {
168+
$f = 'Some\Name\Space\func' . uniqid(rand(1, 9999));
169+
170+
$spy = FunctionMocker::replace($f, [23,89,2389]);
171+
172+
$this->assertTrue(function_exists($f));
173+
$this->assertEquals([23,89,2389], $f());
174+
$spy->wasCalledOnce();
175+
}
161176
}

0 commit comments

Comments
 (0)