Skip to content

Commit 6ce94f8

Browse files
authored
Merge pull request #211 from bogkonstantin/fix-func-map-check
When you expect value null to be returned, fake functions was not invoked
2 parents 7247230 + dd3a8d9 commit 6ce94f8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/AspectMock/Core/Mocker.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function fakeFunctionAndRegisterCalls($namespace, $function, $args)
7171
$fullFuncName = sprintf('%s\%s', $namespace, $function);
7272
Registry::registerFunctionCall($fullFuncName, $args);
7373

74-
if (isset($this->funcMap[$fullFuncName])) {
74+
if (array_key_exists($fullFuncName, $this->funcMap)) {
7575
$func = $this->funcMap[$fullFuncName];
7676
$result = is_callable($func) ? call_user_func_array($func, $args) : $func;
7777
}

tests/unit/FunctionInjectorTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public function testReimplementFunc()
6565
verify(strlen('hello'))->equals(10);
6666
}
6767

68+
public function testFuncReturnsNull()
69+
{
70+
test::func('demo', 'strlen', null);
71+
verify(strlen('hello'))->equals(null);
72+
}
73+
6874
public function testVerifier()
6975
{
7076
$func = test::func('demo', 'strlen', 10);

0 commit comments

Comments
 (0)