function PhptTestCase::assertPhptExpectation
Throws
1 call to PhptTestCase::assertPhptExpectation()
- PhptTestCase::run in vendor/
phpunit/ phpunit/ src/ Runner/ PhptTestCase.php - Runs a test and collects its result in a TestResult instance.
File
-
vendor/
phpunit/ phpunit/ src/ Runner/ PhptTestCase.php, line 374
Class
- PhptTestCase
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\RunnerCode
private function assertPhptExpectation(array $sections, string $output) : void {
$assertions = [
'EXPECT' => 'assertEquals',
'EXPECTF' => 'assertStringMatchesFormat',
'EXPECTREGEX' => 'assertMatchesRegularExpression',
];
$actual = preg_replace('/\\r\\n/', "\n", trim($output));
foreach ($assertions as $sectionName => $sectionAssertion) {
if (isset($sections[$sectionName])) {
$sectionContent = preg_replace('/\\r\\n/', "\n", trim($sections[$sectionName]));
$expected = $sectionName === 'EXPECTREGEX' ? "/{$sectionContent}/" : $sectionContent;
Assert::$sectionAssertion($expected, $actual);
return;
}
}
throw new InvalidPhptFileException();
}