function CallLog::assertCalls in X Autoload 7.5
Parameters
\PHPUnit_Framework_TestCase $testCase:
array[] $expectedCalls:
File
- tests/
src/ Util/ CallLog.php, line 34
Class
Namespace
Drupal\xautoload\Tests\UtilCode
function assertCalls(\PHPUnit_Framework_TestCase $testCase, array $expectedCalls) {
if (array_values($expectedCalls) !== $expectedCalls) {
throw new \InvalidArgumentException('$expectedCalls must be a numeric array with no keys missing.');
}
$extractFunction = array(
$this,
'callGetFunction',
);
$testCase
->assertEquals("\n" . implode("\n", array_map($extractFunction, $expectedCalls)) . "\n", "\n" . implode("\n", array_map($extractFunction, $this->calls)) . "\n");
$testCase
->assertEquals($expectedCalls, $this->calls);
for ($i = 0; TRUE; ++$i) {
$actualCall = isset($this->calls[$i]) ? $this->calls[$i] : NULL;
$expectedCall = isset($expectedCalls[$i]) ? $expectedCalls[$i] : NULL;
if (NULL === $actualCall && NULL === $expectedCall) {
break;
}
if (NULL === $actualCall) {
$testCase
->fail("Call {$i} missing.\nExpected: " . var_export($expectedCall, TRUE));
break;
}
if (NULL === $expectedCall) {
$testCase
->fail("Call {$i} was not expected.\nActual: " . var_export($actualCall, TRUE));
break;
}
if ($actualCall !== $expectedCall) {
$testCase
->fail("Call {$i} mismatch.\nExpected: " . var_export($expectedCall, TRUE) . "\nActual: " . var_export($this->calls[$i], TRUE));
break;
}
}
$testCase
->assertEquals($expectedCalls, $this->calls);
}