Differential D20187 Diff 48214 src/applications/differential/__tests__/DifferentialParseRenderTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/__tests__/DifferentialParseRenderTestCase.php
<?php | <?php | ||||
final class DifferentialParseRenderTestCase extends PhabricatorTestCase { | final class DifferentialParseRenderTestCase extends PhabricatorTestCase { | ||||
private function getTestDataDirectory() { | private function getTestDataDirectory() { | ||||
return dirname(__FILE__).'/data/'; | return dirname(__FILE__).'/data/'; | ||||
} | } | ||||
public function testParseRender() { | public function testParseRender() { | ||||
$dir = $this->getTestDataDirectory(); | $dir = $this->getTestDataDirectory(); | ||||
foreach (Filesystem::listDirectory($dir, $show_hidden = false) as $file) { | foreach (Filesystem::listDirectory($dir, $show_hidden = false) as $file) { | ||||
if (!preg_match('/\.diff$/', $file)) { | if (!preg_match('/\.diff$/', $file)) { | ||||
continue; | continue; | ||||
} | } | ||||
$data = Filesystem::readFile($dir.$file); | $data = Filesystem::readFile($dir.$file); | ||||
// Strip trailing "~" characters from inputs so they may contain | |||||
// trailing whitespace. | |||||
$data = preg_replace('/~$/m', '', $data); | |||||
$opt_file = $dir.$file.'.options'; | $opt_file = $dir.$file.'.options'; | ||||
if (Filesystem::pathExists($opt_file)) { | if (Filesystem::pathExists($opt_file)) { | ||||
$options = Filesystem::readFile($opt_file); | $options = Filesystem::readFile($opt_file); | ||||
try { | try { | ||||
$options = phutil_json_decode($options); | $options = phutil_json_decode($options); | ||||
} catch (PhutilJSONParserException $ex) { | } catch (PhutilJSONParserException $ex) { | ||||
throw new PhutilProxyException( | throw new PhutilProxyException( | ||||
pht('Invalid options file: %s.', $opt_file), | pht('Invalid options file: %s.', $opt_file), | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |