/** * Run the test * * @param \PHPUnit_Framework_TestResult $result * @param Zept $zept * @return \PHPUnit_Framework_TestResult */ private function doRun(\PHPUnit_Framework_TestResult $result, Zept $zept) { $time = 0; \PHP_Timer::start(); try { $jobResult = $this->codeRunner->run($zept->getZephirCode(), $zept->getPhpCode(), $this->silent); $time = \PHP_Timer::stop(); $assertion = $zept->getAssertion(); \PHPUnit_Framework_Assert::$assertion($this->cleanString($zept->getExpected()), $this->cleanString($jobResult['stdout'])); } catch (\Exception $exception) { $result->addError($this, $exception, $time); } catch (\Throwable $throwable) { $result->addError($this, $throwable, $time); } $result->endTest($this, $time); $result->flushListeners(); return $result; }
/** * Parse the assertion * * @param Zept $zept * @param array $sections * @return \ZephirTestCase\Zept */ private function parseAssertion(Zept $zept, array $sections) { if (isset($sections['EXPECT'])) { $zept->setAssertion('assertEquals'); $zept->setExpected($sections['EXPECT']); return $zept; } $zept->setAssertion('assertStringMatchesFormat'); $zept->setExpected($sections['EXPECTF']); return $zept; }