Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php
| Show All 18 Lines | $this->assertEqual( | ||||
| 1, | 1, | ||||
| self::$allTestsCounter, | self::$allTestsCounter, | ||||
| pht( | pht( | ||||
| 'Expect %s has been called once.', | 'Expect %s has been called once.', | ||||
| 'willRunTests()')); | 'willRunTests()')); | ||||
| self::$allTestsCounter--; | self::$allTestsCounter--; | ||||
| $actual_test_count = 4; | $actual_test_count = 5; | ||||
| $this->assertEqual( | $this->assertEqual( | ||||
| $actual_test_count, | $actual_test_count, | ||||
| count(self::$distinctWillRunTests), | count(self::$distinctWillRunTests), | ||||
| pht( | pht( | ||||
| 'Expect %s was called once for each test.', | 'Expect %s was called once for each test.', | ||||
| 'willRunOneTest()')); | 'willRunOneTest()')); | ||||
| $this->assertEqual( | $this->assertEqual( | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | final class PhutilUnitTestEngineTestCase extends PhutilTestCase { | ||||
| } | } | ||||
| protected function throwIfFalsey($input) { | protected function throwIfFalsey($input) { | ||||
| if (!$input) { | if (!$input) { | ||||
| throw new Exception(pht('This is a negative test case!')); | throw new Exception(pht('This is a negative test case!')); | ||||
| } | } | ||||
| } | } | ||||
| public function testGetTestPaths() { | |||||
| $tests = array( | |||||
| array( | |||||
| array(), | |||||
| array(), | |||||
| ), | |||||
| array( | |||||
| array(__FILE__), | |||||
| array(__FILE__), | |||||
| ), | |||||
| array( | |||||
| array(dirname(__FILE__)), | |||||
| array( | |||||
| dirname(dirname(__FILE__)).'/__tests__/', | |||||
| dirname(dirname(dirname(__FILE__))).'/__tests__/', | |||||
| ), | |||||
| ), | |||||
| ); | |||||
| $test_engine = id(new PhutilUnitTestEngine()) | |||||
| ->setWorkingCopy($this->getWorkingCopy()); | |||||
| foreach ($tests as $test) { | |||||
| list($paths, $tests) = $test; | |||||
| $expected = array(); | |||||
| foreach ($tests as $path) { | |||||
| $library_root = phutil_get_library_root_for_path($path); | |||||
| $library = phutil_get_library_name_for_root($library_root); | |||||
| $expected[] = array( | |||||
| 'library' => $library, | |||||
| 'path' => Filesystem::readablePath($path, $library_root), | |||||
| ); | |||||
| } | |||||
| $test_engine->setPaths($paths); | |||||
| $this->assertEqual($expected, array_values($test_engine->getTestPaths())); | |||||
| } | |||||
| } | |||||
| } | } | ||||