Skip to content

Commit a01cf4c

Browse files
jrfnlgrogy
authored andcommitted
Tests: move test fixtures to a "fixtures" subdirectory
Test fixtures are "dummy" files to be used by the actual tests. These files will often contain parse errors and do not need comply with code standards. Let's make this very clear by moving the files to a dedicated `fixtures` subdirectory of tests, as `examples` could mislead people into thinking the directory contains examples of how to _use_ PHP Parallel Lint.
1 parent 3eb8e00 commit a01cf4c

File tree

18 files changed

+23
-35
lines changed

18 files changed

+23
-35
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ jobs:
122122

123123
- name: 'Integration test 1 - linting own code, no colors'
124124
continue-on-error: true
125-
run: ./parallel-lint --exclude vendor --exclude tests/examples --no-colors .
125+
run: ./parallel-lint --exclude vendor --exclude tests/fixtures --no-colors .
126126

127127
- name: 'Integration test 2 - linting own code'
128-
run: ./parallel-lint --exclude vendor --exclude tests/examples .
128+
run: ./parallel-lint --exclude vendor --exclude tests/fixtures .
129129

130130
- name: 'Run unit tests PHP <= 5.5'
131131
if: ${{ matrix.php < 5.6 }}
@@ -140,4 +140,4 @@ jobs:
140140
name: parallel-lint-phar
141141

142142
- name: Run linter against codebase using the phar
143-
run: php ./parallel-lint.phar --exclude vendor --exclude tests/examples .
143+
run: php ./parallel-lint.phar --exclude vendor --exclude tests/fixtures .

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ install:
2626

2727
test_script:
2828
- php composer.phar test
29-
- php parallel-lint --exclude vendor --exclude tests\examples --no-colors .
30-
- php parallel-lint --exclude vendor --exclude tests\examples .
29+
- php parallel-lint --exclude vendor --exclude tests\fixtures --no-colors .
30+
- php parallel-lint --exclude vendor --exclude tests\fixtures .

phpcs.xml.dist

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<file>.</file>
1414

1515
<!-- Exclude dependencies, test fixtures. -->
16-
<exclude-pattern>*/tests/examples/*</exclude-pattern>
16+
<exclude-pattern>*/tests/fixtures/*</exclude-pattern>
1717
<exclude-pattern>*/vendor/*</exclude-pattern>
1818

1919
<!-- Only check PHP files. -->
@@ -87,17 +87,5 @@
8787
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
8888
<exclude-pattern>/tests/*\.php$</exclude-pattern>
8989
</rule>
90-
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
91-
<exclude-pattern>/tests/skip-on-5\.3/*\.php$</exclude-pattern>
92-
</rule>
93-
<rule ref="PSR12.Files.FileHeader.SpacingAfterBlock">
94-
<exclude-pattern>/tests/skip-on-5.3/trait\.php$</exclude-pattern>
95-
</rule>
96-
<rule ref="PSR12.Files.OpenTag.NotAlone">
97-
<exclude-pattern>/tests/skip-on-5.3/trait\.php$</exclude-pattern>
98-
</rule>
99-
<rule ref="PHPCompatibility.Keywords.NewKeywords.t_traitFound">
100-
<exclude-pattern>/tests/skip-on-5.3/trait\.php$</exclude-pattern>
101-
</rule>
10290

10391
</ruleset>

tests/ManagerRunTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testBadPath()
3131
public function testFilesNotFound()
3232
{
3333
$settings = $this->prepareSettings();
34-
$settings->paths = array('examples/example-01/');
34+
$settings->paths = array('fixtures/fixture-01/');
3535
$manager = $this->getManager($settings);
3636
Assert::exception(function () use ($manager, $settings) {
3737
$manager->run($settings);
@@ -41,7 +41,7 @@ public function testFilesNotFound()
4141
public function testSuccess()
4242
{
4343
$settings = $this->prepareSettings();
44-
$settings->paths = array('examples/example-02/');
44+
$settings->paths = array('fixtures/fixture-02/');
4545

4646
$manager = $this->getManager($settings);
4747
$result = $manager->run($settings);
@@ -51,7 +51,7 @@ public function testSuccess()
5151
public function testError()
5252
{
5353
$settings = $this->prepareSettings();
54-
$settings->paths = array('examples/example-03/');
54+
$settings->paths = array('fixtures/fixture-03/');
5555

5656
$manager = $this->getManager($settings);
5757
$result = $manager->run($settings);
@@ -61,13 +61,13 @@ public function testError()
6161
public function testExcludeRelativeSubdirectory()
6262
{
6363
$settings = $this->prepareSettings();
64-
$settings->paths = array('examples/example-04/');
64+
$settings->paths = array('fixtures/fixture-04/');
6565

6666
$manager = $this->getManager($settings);
6767
$result = $manager->run($settings);
6868
Assert::true($result->hasError());
6969

70-
$settings->excluded = array('examples/example-04/dir1/dir2');
70+
$settings->excluded = array('fixtures/fixture-04/dir1/dir2');
7171

7272
$manager = $this->getManager($settings);
7373
$result = $manager->run($settings);
@@ -78,14 +78,14 @@ public function testExcludeAbsoluteSubdirectory()
7878
{
7979
$settings = $this->prepareSettings();
8080
$cwd = getcwd();
81-
$settings->paths = array($cwd . '/examples/example-04/');
81+
$settings->paths = array($cwd . '/fixtures/fixture-04/');
8282
$settings->excluded = array();
8383

8484
$manager = $this->getManager($settings);
8585
$result = $manager->run($settings);
8686
Assert::true($result->hasError());
8787

88-
$settings->excluded = array($cwd . '/examples/example-04/dir1/dir2');
88+
$settings->excluded = array($cwd . '/fixtures/fixture-04/dir1/dir2');
8989

9090
$manager = $this->getManager($settings);
9191
$result = $manager->run($settings);
@@ -100,7 +100,7 @@ public function testExcludeAbsoluteSubdirectory()
100100
public function testMultiPartExtensions()
101101
{
102102
$settings = $this->prepareSettings();
103-
$settings->paths = array('examples/example-06/');
103+
$settings->paths = array('fixtures/fixture-06/');
104104

105105
$settings->extensions = array('php', 'php.dist');
106106

tests/ParallelLintLintTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testNotExistsFile()
6969
public function testEmptyFile()
7070
{
7171
$parallelLint = new ParallelLint($this->getPhpExecutable());
72-
$result = $parallelLint->lint(array(__DIR__ . '/examples/example-01/empty-file'));
72+
$result = $parallelLint->lint(array(__DIR__ . '/fixtures/fixture-01/empty-file'));
7373

7474
Assert::equal(1, $result->getCheckedFilesCount());
7575
Assert::equal(0, $result->getFilesWithSyntaxErrorCount());
@@ -80,7 +80,7 @@ public function testEmptyFile()
8080
public function testValidFile()
8181
{
8282
$parallelLint = new ParallelLint($this->getPhpExecutable());
83-
$result = $parallelLint->lint(array(__DIR__ . '/examples/example-02/example.php'));
83+
$result = $parallelLint->lint(array(__DIR__ . '/fixtures/fixture-02/example.php'));
8484

8585
Assert::equal(1, $result->getCheckedFilesCount());
8686
Assert::equal(0, $result->getFilesWithSyntaxErrorCount());
@@ -90,7 +90,7 @@ public function testValidFile()
9090
public function testInvalidFile()
9191
{
9292
$parallelLint = new ParallelLint($this->getPhpExecutable());
93-
$result = $parallelLint->lint(array(__DIR__ . '/examples/example-03/example.php'));
93+
$result = $parallelLint->lint(array(__DIR__ . '/fixtures/fixture-03/example.php'));
9494

9595
Assert::equal(1, $result->getCheckedFilesCount());
9696
Assert::equal(1, $result->getFilesWithSyntaxErrorCount());
@@ -101,7 +101,7 @@ public function testInvalidFile()
101101
public function testDeprecated()
102102
{
103103
$parallelLint = new ParallelLint($this->getPhpExecutable());
104-
$result = $parallelLint->lint(array(__DIR__ . '/examples/example-05/Foo.php'));
104+
$result = $parallelLint->lint(array(__DIR__ . '/fixtures/fixture-05/Foo.php'));
105105
Assert::equal(1, $result->getCheckedFilesCount());
106106
Assert::equal(0, $result->getFilesWithSyntaxErrorCount());
107107
Assert::false($result->hasSyntaxError());
@@ -113,7 +113,7 @@ public function testDeprecated()
113113

114114
$parallelLint = new ParallelLint($this->getPhpExecutable());
115115
$parallelLint->setShowDeprecated(true);
116-
$result = $parallelLint->lint(array(__DIR__ . '/examples/example-05/Foo.php'));
116+
$result = $parallelLint->lint(array(__DIR__ . '/fixtures/fixture-05/Foo.php'));
117117
Assert::equal(1, $result->getCheckedFilesCount());
118118
Assert::equal(1, $result->getFilesWithSyntaxErrorCount());
119119
Assert::true($result->hasSyntaxError());
@@ -124,8 +124,8 @@ public function testValidAndInvalidFiles()
124124
{
125125
$parallelLint = new ParallelLint($this->getPhpExecutable());
126126
$result = $parallelLint->lint(array(
127-
__DIR__ . '/examples/example-02/example.php',
128-
__DIR__ . '/examples/example-03/example.php',
127+
__DIR__ . '/fixtures/fixture-02/example.php',
128+
__DIR__ . '/fixtures/fixture-03/example.php',
129129
));
130130

131131
Assert::equal(2, $result->getCheckedFilesCount());

tests/SkipLintProcessTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class SkipLintProcessTest extends TestCase
1919
public function testLargeInput()
2020
{
2121
$filesToCheck = array(
22-
__DIR__ . '/skip-on-5.3/class.php',
23-
__DIR__ . '/skip-on-5.3/trait.php',
22+
__DIR__ . '/fixtures/skip-on-5.3/class.php',
23+
__DIR__ . '/fixtures/skip-on-5.3/trait.php',
2424
);
2525

2626
for ($i = 0; $i < 15; $i++) {
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)