This repository has been archived by the owner on Oct 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
# .gitattributes | ||
tests/ export-ignore | ||
.coveralls.yml export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.travis.yml export-ignore | ||
phpunit.xml.dist export-ignore | ||
|
||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"paths": [ | ||
"sniff" | ||
"sniff", | ||
"tests/sniff.spec.php" | ||
], | ||
"rules": { | ||
"@PSR2": true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ before_script: | |
|
||
script: | ||
- ./sniff validate | ||
- vendor/bin/peridot tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"paths": [ | ||
".." | ||
], | ||
"rules": { | ||
"@PSR2": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"paths": [ | ||
"/tmp" | ||
], | ||
"rules": { | ||
"@PSR2": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"paths": [ | ||
"./.." | ||
], | ||
"rules": { | ||
"@PSR2": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"paths": [ | ||
"." | ||
], | ||
"rules": { | ||
"@PSR2": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
class foo {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"paths": [ | ||
"test1.php", | ||
"test2.php" | ||
], | ||
"rules": { | ||
"@PSR2": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
class foo {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
class foo {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
use Webmozart\Assert\Assert; | ||
|
||
const CODE_INVALID_SYNTAX = 8; | ||
|
||
describe('the validate command', function () { | ||
it('should exit with the exit code 0 when there are no errors', function () { | ||
list($code) = sniff('valid'); | ||
Assert::eq($code, 0); | ||
}); | ||
it('should exit with an exit code greater than 0 when there are errors', function () { | ||
list($code, $output) = sniff('invalid'); | ||
Assert::eq($code, CODE_INVALID_SYNTAX); | ||
Assert::contains($output, 'test.php'); | ||
}); | ||
}); | ||
|
||
describe('the configuration', function () { | ||
it('should allow to analyze multiple paths', function () { | ||
list($code, $output) = sniff('multiple-paths'); | ||
Assert::eq($code, CODE_INVALID_SYNTAX, $output); | ||
Assert::contains($output, 'test1.php'); | ||
Assert::contains($output, 'test2.php'); | ||
}); | ||
it('should not accept paths outside the project directory', function () { | ||
$testCases = [ | ||
'invalid-path-1', | ||
'invalid-path-2', | ||
'invalid-path-3', | ||
]; | ||
foreach ($testCases as $testCase) { | ||
list($code, $output) = sniff($testCase); | ||
Assert::greaterThan($code, 0); | ||
Assert::contains($output, 'The .sniff.json configuration file contains an invalid path.'); | ||
} | ||
}); | ||
}); | ||
|
||
it('should ignore php-cs-fixer config files', function () { | ||
// TODO | ||
}); | ||
|
||
function sniff($directory, $command = 'validate') | ||
{ | ||
chdir(__DIR__ . '/' . $directory); | ||
exec("../../sniff $command 2>&1", $output, $code); | ||
$output = implode(PHP_EOL, (array) $output); | ||
return [$code, $output]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"paths": [ | ||
"." | ||
], | ||
"rules": { | ||
"@PSR2": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
echo 'test'; |