You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static function reportError($mailArgs = []) {
print("\nready to call mail");
$result = mail($mailArgs['email'], $mailArgs['subject'], $mailArgs['body']);
print("\nresult " . $result);
return $result;
}
Output
composer test
phpunit --colors=always
PHPUnit 5.7.23 by Sebastian Bergmann and contributors.
F 1 / 1 (100%) ready to call mail
result 1
Time: 59 ms, Memory: 5.00MB
There was 1 failure:
Tests\UtilTest::testReportError
Expectation failed for method name is equal to string:delegate when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
The text was updated successfully, but these errors were encountered:
Yes, that is correct.
If the SUT is in a different namespace, you can dynamically get the namespace using PHP ReflectionClass.
See here https://stackoverflow.com/a/67696809/6909825
The "mail" built in function is not getting mocked...Not sure what I'm missing.
Test case:
SUT Util.php
Output
composer test
F 1 / 1 (100%)
ready to call mail
result 1
Time: 59 ms, Memory: 5.00MB
There was 1 failure:
Expectation failed for method name is equal to string:delegate when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
The text was updated successfully, but these errors were encountered: