function xautoload_Mock_InjectedAPI_findFile::finish in X Autoload 7.2
Same name and namespace in other branches
- 7.3 lib/Mock/InjectedAPI/findFile.php \xautoload_Mock_InjectedAPI_findFile::finish()
File
- lib/
Mock/ InjectedAPI/ findFile.php, line 54
Class
- xautoload_Mock_InjectedAPI_findFile
- To help testability, we use an injected API instead of just a return value. The injected API can be mocked to provide a mocked file_exists(), and to monitor all suggested candidates, not just the correct return value.
Code
function finish() {
$n = count($this->expectedSuggestions);
$this
->assert($this->index === $n || $this->accepted, "Finish at {$this->index} of {$n} for '{$this->className}'.");
if ($n <= 1) {
return;
}
$expected = '';
foreach ($this->expectedSuggestions as $i => $file) {
if ($i === $this->iAccept) {
$file .= ' (accept)';
}
$expected .= '<li>' . $file . '</li>';
}
$suggested = '';
foreach ($this->incomingSuggestions as $file) {
$suggested .= '<li>' . $file . '</li>';
}
$msg = <<<EOT
Suggestions must be made in the correct sequence.
<div>Expected:<ol>{<span class="php-variable">$expected</span>}</ol></div>
<div>Suggested:<ol>{<span class="php-variable">$suggested</span>}</ol></div>
EOT;
$this
->assert($this->incomingSuggestions === array_slice($this->expectedSuggestions, 0, $this->index), $msg);
}