diff --git a/tests/Core/Files/FileList/AbstractFileListTestCase.php b/tests/Core/Files/FileList/AbstractFileListTestCase.php deleted file mode 100644 index abced07317..0000000000 --- a/tests/Core/Files/FileList/AbstractFileListTestCase.php +++ /dev/null @@ -1,55 +0,0 @@ -filter = __DIR__.'/FilterDouble.php'; - self::$ruleset = new Ruleset(self::$config); - } - - }//end initializeConfigAndRuleset() - - -}//end class diff --git a/tests/Core/Files/FileList/AddFileTest.php b/tests/Core/Files/FileList/AddFileTest.php deleted file mode 100644 index 4346fbbf95..0000000000 --- a/tests/Core/Files/FileList/AddFileTest.php +++ /dev/null @@ -1,138 +0,0 @@ -files = []; - $this->fileList = new FileList(self::$config, self::$ruleset); - - }//end initializeFileList() - - - /** - * Test adding a file to the list. - * - * @param string $fileName The name of the file to add. - * @param object|null $fileObject An optional file object to add instead of creating a new one. - * - * @dataProvider dataAddFile - * - * @return void - */ - public function testAddFile($fileName, $fileObject=null) - { - $this->assertCount(0, $this->fileList); - - $this->fileList->addFile($fileName, $fileObject); - - $fileListArray = iterator_to_array($this->fileList); - - $this->assertCount(1, $this->fileList, 'File count mismatch'); - $this->assertArrayHasKey($fileName, $fileListArray, 'File not found in list'); - - if (isset($fileObject) === true) { - $this->assertSame($fileObject, $fileListArray[$fileName], 'File object mismatch'); - } else { - $this->assertInstanceOf( - 'PHP_CodeSniffer\Files\File', - $fileListArray[$fileName], - 'File object not found in list' - ); - } - - }//end testAddFile() - - - /** - * Data provider for testAddFile. - * - * @return array> - */ - public static function dataAddFile() - { - self::initializeConfigAndRuleset(); - - return [ - 'Regular file' => [ - 'fileName' => 'test1.php', - ], - 'STDIN' => [ - 'fileName' => 'STDIN', - ], - 'Regular file with file object' => [ - 'fileName' => 'test1.php', - 'fileObject' => new File('test1.php', self::$ruleset, self::$config), - ], - ]; - - }//end dataAddFile() - - - /** - * Test that it is not possible to add the same file twice. - * - * @return void - */ - public function testAddFileShouldNotAddTheSameFileTwice() - { - $file1 = 'test1.php'; - $file2 = 'test2.php'; - $expectedFiles = [ - $file1, - $file2, - ]; - - // Add $file1 once. - $this->fileList->addFile($file1); - $this->assertCount(1, $this->fileList); - $this->assertSame([$file1], array_keys(iterator_to_array($this->fileList))); - - // Try to add $file1 again. Should be ignored. - $this->fileList->addFile($file1); - $this->assertCount(1, $this->fileList); - $this->assertSame([$file1], array_keys(iterator_to_array($this->fileList))); - - // Add $file2. Should be added. - $this->fileList->addFile($file2); - $this->assertCount(2, $this->fileList); - $this->assertSame($expectedFiles, array_keys(iterator_to_array($this->fileList))); - - }//end testAddFileShouldNotAddTheSameFileTwice() - - -}//end class diff --git a/tests/Core/Files/FileList/ConstructTest.php b/tests/Core/Files/FileList/ConstructTest.php deleted file mode 100644 index f40a400993..0000000000 --- a/tests/Core/Files/FileList/ConstructTest.php +++ /dev/null @@ -1,122 +0,0 @@ - $files List of file paths in the Config class. - * @param array $expectedFiles List of expected file paths in the FileList. - * - * @dataProvider dataConstruct - * - * @return void - */ - public function testConstruct($files, $expectedFiles) - { - self::$config->files = $files; - - $fileList = new FileList(self::$config, self::$ruleset); - - $this->assertSame(self::$config, $fileList->config, 'Config object mismatch'); - $this->assertSame(self::$ruleset, $fileList->ruleset, 'Ruleset object mismatch'); - - $this->assertCount(count($expectedFiles), $fileList, 'File count mismatch'); - - $i = 0; - - // Sort the values to make the tests stable as different OSes will read directories - // in a different order and the order is not relevant for these tests. Just the values. - $fileListArray = iterator_to_array($fileList); - ksort($fileListArray); - - foreach ($fileListArray as $filePath => $fileObject) { - $this->assertSame( - $expectedFiles[$i], - $filePath, - sprintf('File path mismatch: expected "%s", got "%s"', $expectedFiles[$i], $filePath) - ); - $this->assertInstanceOf( - 'PHP_CodeSniffer\Files\File', - $fileObject, - sprintf('File object for "%s" is not an instance of PHP_CodeSniffer\Files\File', $filePath) - ); - $i++; - } - - }//end testConstruct() - - - /** - * Data provider for testConstruct. - * - * @return array>> - */ - public static function dataConstruct() - { - $fixturesDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR; - - return [ - 'No files' => [ - 'files' => [], - 'expectedFiles' => [], - ], - 'Two files' => [ - 'files' => [ - 'file1.php', - 'file2.php', - ], - 'expectedFiles' => [ - 'file1.php', - 'file2.php', - ], - ], - 'A directory' => [ - 'files' => [$fixturesDir], - 'expectedFiles' => [ - $fixturesDir.'file1.php', - $fixturesDir.'file2.php', - ], - ], - 'Same file twice' => [ - 'files' => [ - 'file1.php', - 'file1.php', - ], - 'expectedFiles' => [ - 'file1.php', - ], - ], - 'File and then directory containing that file' => [ - 'files' => [ - $fixturesDir.'file1.php', - $fixturesDir, - ], - 'expectedFiles' => [ - $fixturesDir.'file1.php', - $fixturesDir.'file2.php', - ], - ], - ]; - - }//end dataConstruct() - - -}//end class diff --git a/tests/Core/Files/FileList/FilterDouble.php b/tests/Core/Files/FileList/FilterDouble.php deleted file mode 100644 index 99952ef63c..0000000000 --- a/tests/Core/Files/FileList/FilterDouble.php +++ /dev/null @@ -1,31 +0,0 @@ -