Skip to content

Commit c905c40

Browse files
sirbrilligjrfnl
andcommitted
Move test directory out of package path (#168)
* Move tests directory to top level * Modify tests directory path in other files * Move fixtures back adjacent to tests * Exclude vendor from phpcs * Tests: fix composer autoload 1. Make the namespace of the `VariableAnalysisTest` file reflect the path the file. 2. Add an `autoload-dev` section to the `composer.json` * The unit tests are not shipped in the distribution package, so they are only available in a `dev` environment, which is exactly what `autoload-dev` is targetting. * Setting the `tests` directory as a secondary path for PSR4 autoload should fix compatibility with Composer 2. * Rename tests/Sniffs to tests/VariableAnalysisSniff * Rename tests to Tests * Rename Tests directory paths in files * Rename test namespace to match new path * Update .gitattributes from tests to Tests Co-Authored-By: Juliette <[email protected]> Co-authored-by: jrfnl <[email protected]> Co-authored-by: Juliette <[email protected]>
1 parent 144e1f2 commit c905c40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+25
-20
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/phpunit.xml.dist export-ignore
1414
/phpunit.circleci.xml export-ignore
1515
/.circleci/ export-ignore
16-
/VariableAnalysis/Tests/ export-ignore
16+
/Tests/ export-ignore
1717

1818
#
1919
# Auto detect text files and perform LF normalization

VariableAnalysis/Tests/BaseTestCase.php renamed to Tests/BaseTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class BaseTestCase extends TestCase {
1010
const STANDARD_NAME = 'VariableAnalysis';
11-
const SNIFF_FILE = __DIR__ . '/../Sniffs/CodeAnalysis/VariableAnalysisSniff.php';
11+
const SNIFF_FILE = __DIR__ . '/../VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php';
1212

1313
public function prepareLocalFileForSniffs($fixtureFile) {
1414
$config = new Config();
@@ -41,6 +41,6 @@ public function getErrorLineNumbersFromFile(LocalFile $phpcsFile) {
4141
}
4242

4343
public function getFixture($fixtureFilename) {
44-
return realpath(__DIR__ . '/CodeAnalysis/fixtures/' . $fixtureFilename);
44+
return realpath(__DIR__ . '/VariableAnalysisSniff/fixtures/' . $fixtureFilename);
4545
}
4646
}

VariableAnalysis/Tests/CodeAnalysis/VariableAnalysisTest.php renamed to Tests/VariableAnalysisSniff/VariableAnalysisTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace VariableAnalysis\Tests\CodeAnalysis;
2+
namespace VariableAnalysis\Tests\VariableAnalysisSniff;
33

44
use VariableAnalysis\Tests\BaseTestCase;
55

Tests/bootstrap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
require_once(__DIR__ . '/../vendor/squizlabs/php_codesniffer/tests/bootstrap.php');
3+
require_once(__DIR__ . '/BaseTestCase.php');

VariableAnalysis/Tests/bootstrap.php

Lines changed: 0 additions & 3 deletions
This file was deleted.

composer.circleci.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
"VariableAnalysis\\": "VariableAnalysis/"
2727
}
2828
},
29+
"autoload-dev": {
30+
"psr-4": {
31+
"VariableAnalysis\\Tests\\": "Tests/"
32+
}
33+
},
2934
"minimum-stability": "dev",
3035
"prefer-stable": true,
3136
"scripts": {

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
"VariableAnalysis\\": "VariableAnalysis/"
2727
}
2828
},
29+
"autoload-dev": {
30+
"psr-4": {
31+
"VariableAnalysis\\Tests\\": "Tests/"
32+
}
33+
},
2934
"minimum-stability": "dev",
3035
"prefer-stable": true,
3136
"scripts": {

phpcs.xml.dist

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<?xml version="1.0"?>
22
<ruleset name="PaytonsStandard">
3-
<description>
4-
Originally from https://gist.github.com/Ovsyanka/e2ab2ff76e7c0d7e75a1e4213a03ff95
5-
PSR2 with changes:
6-
- bracers on end of line instead new line
7-
- two space indentation
8-
</description>
9-
103
<file>./VariableAnalysis/</file>
11-
<exclude-pattern>./VariableAnalysis/Tests/CodeAnalysis/fixtures/</exclude-pattern>
4+
<file>./Tests/</file>
5+
<exclude-pattern>./Tests/VariableAnalysisSniff/fixtures/</exclude-pattern>
6+
<exclude-pattern>./vendor/</exclude-pattern>
127

138
<!-- Only check PHP files. -->
149
<arg name="extensions" value="php"/>

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ parameters:
66
paths:
77
- %currentWorkingDirectory%/VariableAnalysis/
88
excludes_analyse:
9-
- %currentWorkingDirectory%/VariableAnalysis/Tests/
9+
- %currentWorkingDirectory%/Tests/
1010
ignoreErrors:
1111
- '~^Constant T_\w+ not found.$~'

phpunit.circleci.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<phpunit
2-
bootstrap="VariableAnalysis/Tests/bootstrap.php"
2+
bootstrap="Tests/bootstrap.php"
33
>
44
<testsuites>
55
<testsuite name="VariableAnalysis">
6-
<directory>VariableAnalysis/Tests</directory>
6+
<directory>Tests</directory>
77
</testsuite>
88
</testsuites>
99
</phpunit>

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<phpunit
2-
bootstrap="VariableAnalysis/Tests/bootstrap.php"
2+
bootstrap="Tests/bootstrap.php"
33
printerClass="LimeDeck\Testing\Printer"
44
>
55
<testsuites>
66
<testsuite name="VariableAnalysis">
7-
<directory>VariableAnalysis/Tests</directory>
7+
<directory>Tests</directory>
88
</testsuite>
99
</testsuites>
1010
</phpunit>

0 commit comments

Comments
 (0)