function run() { $raw = is_readable($this->file) ? file_get_contents($this->file) : ''; $sections = array_values(array_filter(array_map('trim', preg_split('/^--(TEST|FILE|EXPECTF)--$/m', $raw)))); if (3 === count($sections)) { list($this->name, $this->source, $this->expected) = $sections; try { $this->out = yay_parse($this->source); if (false !== strpos($this->name, '--pretty-print')) { $this->out = yay_pretty($this->out) . PHP_EOL . PHP_EOL . '?>'; } } catch (YayParseError $e) { $this->out = $e->getMessage(); // $this->out = (string) $e; } catch (\PhpParser\Error $e) { $this->out = 'PHP ' . $e->getMessage(); // $this->out = (string) $e; } catch (Exception $e) { $this->out = (string) $e; } try { Assert::assertStringMatchesFormat($this->expected, $this->out); $this->status = self::PASSED; } catch (Exception $e) { $this->status = self::FAILED; throw $e; } } else { $this->status = self::BORKED; } }
/** * Asserts that a string matches a given format string. * * @param string $format * @param string $string * @param string $message * @since Method available since Release 3.5.0 */ function assertStringMatchesFormat($format, $string, $message = '') { return PHPUnit_Framework_Assert::assertStringMatchesFormat($format, $string, $message); }
/** * Assert that collected data matches expected format * * @param string $expectedData */ public static function assertCollectedData($expectedData) { PHPUnit_Framework_Assert::assertStringMatchesFormat($expectedData, self::$_collectedData, 'Expected data went through the stream.'); }
public function toMatchFormat($format) { if ($this->negate) { a::assertStringNotMatchesFormat($format, $this->actual); } else { a::assertStringMatchesFormat($format, $this->actual); } }
public function matchesFormat($format) { Assert::assertStringMatchesFormat($format, $this->actual, $this->description); return $this; }
public function matchesFormat($format) { a::assertStringMatchesFormat($format, $this->actual, $this->description); }
/** * Expect that a string matches a given format string. * * @param string $format * @param string $message * * @return Expect */ public function toMatchFormat($format, $message = '') { Assert::assertStringMatchesFormat($format, $this->value, $message); return $this; }