Skip to content

Commit

Permalink
Merge pull request #211 from bogkonstantin/fix-func-map-check
Browse files Browse the repository at this point in the history
When you expect value null to be returned, fake functions was not invoked
  • Loading branch information
Naktibalda authored Nov 16, 2024
2 parents 7247230 + dd3a8d9 commit 6ce94f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AspectMock/Core/Mocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function fakeFunctionAndRegisterCalls($namespace, $function, $args)
$fullFuncName = sprintf('%s\%s', $namespace, $function);
Registry::registerFunctionCall($fullFuncName, $args);

if (isset($this->funcMap[$fullFuncName])) {
if (array_key_exists($fullFuncName, $this->funcMap)) {
$func = $this->funcMap[$fullFuncName];
$result = is_callable($func) ? call_user_func_array($func, $args) : $func;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/FunctionInjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public function testReimplementFunc()
verify(strlen('hello'))->equals(10);
}

public function testFuncReturnsNull()
{
test::func('demo', 'strlen', null);
verify(strlen('hello'))->equals(null);
}

public function testVerifier()
{
$func = test::func('demo', 'strlen', 10);
Expand Down

0 comments on commit 6ce94f8

Please sign in to comment.