From df22ea467e6ffde21c1cf8430664c370f7c82e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Fri, 19 Jan 2018 15:08:14 +0100 Subject: [PATCH 1/2] Add @test and @uses as useful annotations These are relevant for PHPUnit test cases and if we remove them we will definitely break some test suites. --- lib/Doctrine/ruleset.xml | 4 +++- tests/expected_report.txt | 5 +++-- tests/fixed/test-case.php | 39 +++++++++++++++++++++++++++++++++++++ tests/input/test-case.php | 41 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 tests/fixed/test-case.php create mode 100644 tests/input/test-case.php diff --git a/lib/Doctrine/ruleset.xml b/lib/Doctrine/ruleset.xml index ca9e6c88..4f5d46f9 100644 --- a/lib/Doctrine/ruleset.xml +++ b/lib/Doctrine/ruleset.xml @@ -202,7 +202,9 @@ @runTestsInSeparateProcesses, @see, @Target, - @throws + @test, + @throws, + @uses " /> diff --git a/tests/expected_report.txt b/tests/expected_report.txt index 9f7a757f..3f759586 100644 --- a/tests/expected_report.txt +++ b/tests/expected_report.txt @@ -8,10 +8,11 @@ tests/input/example-class.php 18 0 tests/input/not_spacing.php 7 0 tests/input/return_type_on_closures.php 21 0 tests/input/return_type_on_methods.php 17 0 +tests/input/test-case.php 6 0 ---------------------------------------------------------------------- -A TOTAL OF 87 ERRORS AND 0 WARNINGS WERE FOUND IN 5 FILES +A TOTAL OF 93 ERRORS AND 0 WARNINGS WERE FOUND IN 6 FILES ---------------------------------------------------------------------- -PHPCBF CAN FIX 77 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 82 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/fixed/test-case.php b/tests/fixed/test-case.php new file mode 100644 index 00000000..fb9a3354 --- /dev/null +++ b/tests/fixed/test-case.php @@ -0,0 +1,39 @@ + Date: Fri, 19 Jan 2018 15:12:31 +0100 Subject: [PATCH 2/2] Add tests to cover use statements order --- tests/expected_report.txt | 6 +++--- tests/fixed/example-class.php | 6 ++++++ tests/input/example-class.php | 10 ++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/expected_report.txt b/tests/expected_report.txt index 3f759586..3d031c41 100644 --- a/tests/expected_report.txt +++ b/tests/expected_report.txt @@ -4,15 +4,15 @@ PHP CODE SNIFFER REPORT SUMMARY FILE ERRORS WARNINGS ---------------------------------------------------------------------- tests/input/concatenation_spacing.php 24 0 -tests/input/example-class.php 18 0 +tests/input/example-class.php 19 0 tests/input/not_spacing.php 7 0 tests/input/return_type_on_closures.php 21 0 tests/input/return_type_on_methods.php 17 0 tests/input/test-case.php 6 0 ---------------------------------------------------------------------- -A TOTAL OF 93 ERRORS AND 0 WARNINGS WERE FOUND IN 6 FILES +A TOTAL OF 94 ERRORS AND 0 WARNINGS WERE FOUND IN 6 FILES ---------------------------------------------------------------------- -PHPCBF CAN FIX 82 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 83 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php index 64932bfa..b320be9d 100644 --- a/tests/fixed/example-class.php +++ b/tests/fixed/example-class.php @@ -5,6 +5,7 @@ namespace Example; use Doctrine\Sniffs\Spacing\ControlStructureSniff; +use Fancy\TestCase; use const PHP_MINOR_VERSION; use const PHP_RELEASE_VERSION as PHP_PATCH_VERSION; use const PHP_VERSION; @@ -74,4 +75,9 @@ public static function getMinorVersion() : int { return self::VERSION; } + + public static function getTestCase() : TestCase + { + return new TestCase(); + } } diff --git a/tests/input/example-class.php b/tests/input/example-class.php index 88146f7a..0dc831b1 100644 --- a/tests/input/example-class.php +++ b/tests/input/example-class.php @@ -4,9 +4,10 @@ namespace Example; -use Doctrine\Sniffs\Spacing\ControlStructureSniff; -use const PHP_RELEASE_VERSION as PHP_PATCH_VERSION; use function strlen as stringLength; +use Fancy\TestCase; +use const PHP_RELEASE_VERSION as PHP_PATCH_VERSION; +use Doctrine\Sniffs\Spacing\ControlStructureSniff; /** * Description @@ -73,4 +74,9 @@ public static function getMinorVersion() : int { return self::VERSION; } + + public static function getTestCase() : TestCase + { + return new TestCase(); + } }