-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test-cover EveryTestHasSameNamespaceAsTestedClass
- Loading branch information
Showing
10 changed files
with
139 additions
and
9 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
58 changes: 58 additions & 0 deletions
58
tests/TestCheck/EveryTestHasSameNamespaceAsTestedClassTest.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,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cdn77\TestUtils\Tests\TestCheck; | ||
|
||
use Cdn77\TestUtils\TestCheck\EveryTestHasSameNamespaceAsTestedClass; | ||
use Cdn77\TestUtils\Tests\BaseTestCase; | ||
use Generator; | ||
use PHPUnit\Framework\AssertionFailedError; | ||
|
||
final class EveryTestHasSameNamespaceAsTestedClassTest extends BaseTestCase | ||
{ | ||
/** @dataProvider providerSuccess */ | ||
public function testSuccess(string $filePath) : void | ||
{ | ||
$check = new EveryTestHasSameNamespaceAsTestedClass( | ||
[__DIR__ . '/Fixtures/EveryTestHasSameNamespaceAsTestedClass/tests/' . $filePath], | ||
'Tests' | ||
); | ||
$check->run($this); | ||
} | ||
|
||
/** @return Generator<array-key, list<string>> */ | ||
public function providerSuccess() : Generator | ||
{ | ||
yield ['SameNamespaceTest.php']; | ||
yield ['SameNamespaceLinkedTest.php']; | ||
yield ['NoLinkTest.php']; | ||
} | ||
|
||
/** @dataProvider providerFail */ | ||
public function testFail(string $filePath, string $error) : void | ||
{ | ||
$this->expectException(AssertionFailedError::class); | ||
$this->expectExceptionMessage($error); | ||
|
||
$check = new EveryTestHasSameNamespaceAsTestedClass( | ||
[__DIR__ . '/Fixtures/EveryTestHasSameNamespaceAsTestedClass/tests/' . $filePath], | ||
'Tests' | ||
); | ||
$check->run($this); | ||
} | ||
|
||
/** @return Generator<array-key, list<string>> */ | ||
public function providerFail() : Generator | ||
{ | ||
yield [ | ||
'MissingAnnotationsTest.php', | ||
'is in the wrong namespace, has name different from tested class or is missing @testedClass annotation', | ||
]; | ||
|
||
yield [ | ||
'NonexistentLinkTest.php', | ||
'is pointing to an non-existing class', | ||
]; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/TestCheck/Fixtures/EveryTestHasSameNamespaceAsTestedClass/SameNamespace.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,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cdn77\TestUtils\Tests\TestCheck\Fixtures\EveryTestHasSameNamespaceAsTestedClass; | ||
|
||
final class SameNamespace | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
...estCheck/Fixtures/EveryTestHasSameNamespaceAsTestedClass/tests/MissingAnnotationsTest.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,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cdn77\TestUtils\Tests\Tests\TestCheck\Fixtures\EveryTestHasSameNamespaceAsTestedClass; | ||
|
||
final class MissingAnnotationsTest | ||
{ | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/TestCheck/Fixtures/EveryTestHasSameNamespaceAsTestedClass/tests/NoLinkTest.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cdn77\TestUtils\Tests\Tests\TestCheck\Fixtures\EveryTestHasSameNamespaceAsTestedClass; | ||
|
||
/** @testedClass none */ | ||
final class NoLinkTest | ||
{ | ||
} |
10 changes: 10 additions & 0 deletions
10
...s/TestCheck/Fixtures/EveryTestHasSameNamespaceAsTestedClass/tests/NonexistentLinkTest.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cdn77\TestUtils\Tests\Tests\TestCheck\Fixtures\EveryTestHasSameNamespaceAsTestedClass; | ||
|
||
/** @testedClass Cdn77\TestUtils\Tests\TestCheck\Fixtures\EveryTestHasSameNamespaceAsTestedClass\Noexists */ | ||
final class NonexistentLinkTest | ||
{ | ||
} |
10 changes: 10 additions & 0 deletions
10
...stCheck/Fixtures/EveryTestHasSameNamespaceAsTestedClass/tests/SameNamespaceLinkedTest.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cdn77\TestUtils\Tests\Tests\TestCheck\Fixtures\EveryTestHasSameNamespaceAsTestedClass; | ||
|
||
/** @testedClass Cdn77\TestUtils\Tests\TestCheck\Fixtures\EveryTestHasSameNamespaceAsTestedClass\SameNamespace */ | ||
final class SameNamespaceLinkedTest | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/TestCheck/Fixtures/EveryTestHasSameNamespaceAsTestedClass/tests/SameNamespaceTest.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,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cdn77\TestUtils\Tests\Tests\TestCheck\Fixtures\EveryTestHasSameNamespaceAsTestedClass; | ||
|
||
final class SameNamespaceTest | ||
{ | ||
} |