Changeset View
Changeset View
Standalone View
Standalone View
src/parser/__tests__/PhutilEditorConfigTestCase.php
- This file was added.
<?php | |||||
/** | |||||
* @group testcase | |||||
*/ | |||||
final class PhutilEditorConfigTestCase extends PhutilTestCase { | |||||
public function testGetPaths() { | |||||
$tests = array( | |||||
dirname(__FILE__) => array( | |||||
dirname(__FILE__).'/editorconfig/.editorconfig', | |||||
dirname(__FILE__).'/editorconfig/subdir1/.editorconfig', | |||||
dirname(__FILE__).'/editorconfig/subdir2/.editorconfig', | |||||
), | |||||
dirname(__FILE__).'/editorconfig/subdir1' => array( | |||||
dirname(__FILE__).'/editorconfig/subdir1/.editorconfig', | |||||
), | |||||
dirname(__FILE__).'/editorconfig/subdir2' => array( | |||||
dirname(__FILE__).'/editorconfig/subdir2/.editorconfig', | |||||
), | |||||
dirname(__FILE__).'/../../../' => array( | |||||
Filesystem::resolvePath('.editorconfig', dirname(__FILE__).'/../../..'), | |||||
dirname(__FILE__).'/editorconfig/.editorconfig', | |||||
dirname(__FILE__).'/editorconfig/subdir1/.editorconfig', | |||||
dirname(__FILE__).'/editorconfig/subdir2/.editorconfig', | |||||
), | |||||
); | |||||
foreach ($tests as $input => $expect) { | |||||
$editorconfig = new PhutilEditorConfig($input); | |||||
$this->assertEqual($expect, $editorconfig->getPaths()); | |||||
} | |||||
} | |||||
public function testGetRootPath() { | |||||
$tests = array( | |||||
dirname(__FILE__) => dirname(__FILE__), | |||||
dirname(__FILE__).'/editorconfig/subdir1' | |||||
=> dirname(__FILE__).'/editorconfig/subdir1', | |||||
dirname(__FILE__).'/editorconfig/subdir2' | |||||
=> dirname(__FILE__).'/editorconfig/subdir2', | |||||
); | |||||
foreach ($tests as $input => $expect) { | |||||
$editorconfig = new PhutilEditorConfig($input); | |||||
$this->assertEqual($expect, $editorconfig->getRootPath()); | |||||
} | |||||
} | |||||
} |