$id, 'section' => $section, 'markdown' => $markdown, 'expectedHtml' => $expectedHtml ]; } } } } else { $this->fail('The CommonMark cache folder ' . $dir . ' is empty or not readable.'); } return $data; } /** * @group update * @dataProvider dataUpdate * @param $id * @param $section * @param $markdown * @param $expectedHtml */ public function testUpdateDatabase($id, $section, $markdown, $expectedHtml) { parent::testExample($id, $section, $markdown, $expectedHtml); // you can only get here when the test passes $dir = static::getDataDir(true); $basename = $id . '-' . \preg_replace('/[^\w.-]/', '_', $section); \file_put_contents($dir . $basename . '.md', $markdown); \file_put_contents($dir . $basename . '.html', $expectedHtml); } /** * @return array */ public function dataUpdate() { return parent::data(); } public static function getDataDir($mkdir = false) { $dir = __DIR__ . '/commonmark/'; if ($mkdir) { if (!\file_exists($dir)) { @\mkdir($dir); } if (!\is_dir($dir)) { static::fail('Unable to create CommonMark cache folder ' . $dir . '.'); } } return $dir; } }