-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #642 from PHPCSStandards/feature/utilitymethodtest…
…case-add-safeguard-against-duplicate-markers UtilityMethodTestCase: safeguard against duplicate test markers
- Loading branch information
Showing
15 changed files
with
286 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
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
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
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
13 changes: 13 additions & 0 deletions
13
Tests/TestUtils/UtilityMethodTestCase/TestMarkersAreUniqueFailsTest.inc
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,13 @@ | ||
<?php | ||
|
||
/* testMarkerA */ | ||
echo 'hello'; | ||
|
||
/* testMarkerB */ | ||
echo 'hello'; | ||
|
||
/* testMarkerA */ | ||
echo 'hello'; | ||
|
||
/* testMarkerB */ | ||
echo 'hello'; |
45 changes: 45 additions & 0 deletions
45
Tests/TestUtils/UtilityMethodTestCase/TestMarkersAreUniqueFailsTest.php
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,45 @@ | ||
<?php | ||
/** | ||
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. | ||
* | ||
* @package PHPCSUtils | ||
* @copyright 2019-2020 PHPCSUtils Contributors | ||
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3 | ||
* @link https://github.com/PHPCSStandards/PHPCSUtils | ||
*/ | ||
|
||
namespace PHPCSUtils\Tests\TestUtils\UtilityMethodTestCase; | ||
|
||
use PHPCSUtils\Tests\PolyfilledTestCase; | ||
|
||
/** | ||
* Tests for the \PHPCSUtils\TestUtils\UtilityMethodTestCase class. | ||
* | ||
* @covers \PHPCSUtils\TestUtils\UtilityMethodTestCase::testTestMarkersAreUnique | ||
* @covers \PHPCSUtils\TestUtils\UtilityMethodTestCase::assertTestMarkersAreUnique | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
final class TestMarkersAreUniqueFailsTest extends PolyfilledTestCase | ||
{ | ||
|
||
/** | ||
* Overload the "normal" test marker QA check - this test class does not have a valid File object. | ||
* | ||
* @return void | ||
*/ | ||
public function testTestMarkersAreUnique() | ||
{ | ||
$msg = "Duplicate test markers found.\nFailed asserting that "; | ||
$exception = 'PHPUnit\Framework\AssertionFailedError'; | ||
if (\class_exists('PHPUnit_Framework_AssertionFailedError')) { | ||
// PHPUnit < 6. | ||
$exception = 'PHPUnit_Framework_AssertionFailedError'; | ||
} | ||
|
||
$this->expectException($exception); | ||
$this->expectExceptionMessage($msg); | ||
|
||
parent::testTestMarkersAreUnique(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
Tests/TestUtils/UtilityMethodTestCase/TestMarkersAreUniqueNoMarkersTest.inc
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,4 @@ | ||
<?php | ||
|
||
echo 'hello'; | ||
echo 'hello'; |
35 changes: 35 additions & 0 deletions
35
Tests/TestUtils/UtilityMethodTestCase/TestMarkersAreUniqueNoMarkersTest.php
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,35 @@ | ||
<?php | ||
/** | ||
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. | ||
* | ||
* @package PHPCSUtils | ||
* @copyright 2019-2020 PHPCSUtils Contributors | ||
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3 | ||
* @link https://github.com/PHPCSStandards/PHPCSUtils | ||
*/ | ||
|
||
namespace PHPCSUtils\Tests\TestUtils\UtilityMethodTestCase; | ||
|
||
use PHPCSUtils\Tests\PolyfilledTestCase; | ||
|
||
/** | ||
* Tests for the \PHPCSUtils\TestUtils\UtilityMethodTestCase class. | ||
* | ||
* @covers \PHPCSUtils\TestUtils\UtilityMethodTestCase::testTestMarkersAreUnique | ||
* @covers \PHPCSUtils\TestUtils\UtilityMethodTestCase::assertTestMarkersAreUnique | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
final class TestMarkersAreUniqueNoMarkersTest extends PolyfilledTestCase | ||
{ | ||
|
||
/** | ||
* Overload the "normal" test marker QA check, but only to overload the `@covers` tags. | ||
* | ||
* @return void | ||
*/ | ||
public function testTestMarkersAreUnique() | ||
{ | ||
parent::testTestMarkersAreUnique(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Tests/TestUtils/UtilityMethodTestCase/TestMarkersAreUniqueTest.inc
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,13 @@ | ||
<?php | ||
|
||
/* testMarkerA */ | ||
echo 'hello'; | ||
|
||
/* testMarkerB */ | ||
echo 'hello'; | ||
|
||
/* notAMarker */ | ||
echo 'hello'; | ||
|
||
/* testMarkerD */ | ||
echo 'hello'; |
35 changes: 35 additions & 0 deletions
35
Tests/TestUtils/UtilityMethodTestCase/TestMarkersAreUniqueTest.php
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,35 @@ | ||
<?php | ||
/** | ||
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. | ||
* | ||
* @package PHPCSUtils | ||
* @copyright 2019-2020 PHPCSUtils Contributors | ||
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3 | ||
* @link https://github.com/PHPCSStandards/PHPCSUtils | ||
*/ | ||
|
||
namespace PHPCSUtils\Tests\TestUtils\UtilityMethodTestCase; | ||
|
||
use PHPCSUtils\Tests\PolyfilledTestCase; | ||
|
||
/** | ||
* Tests for the \PHPCSUtils\TestUtils\UtilityMethodTestCase class. | ||
* | ||
* @covers \PHPCSUtils\TestUtils\UtilityMethodTestCase::testTestMarkersAreUnique | ||
* @covers \PHPCSUtils\TestUtils\UtilityMethodTestCase::assertTestMarkersAreUnique | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
final class TestMarkersAreUniqueTest extends PolyfilledTestCase | ||
{ | ||
|
||
/** | ||
* Overload the "normal" test marker QA check, but only to overload the `@covers` tags. | ||
* | ||
* @return void | ||
*/ | ||
public function testTestMarkersAreUnique() | ||
{ | ||
parent::testTestMarkersAreUnique(); | ||
} | ||
} |