Skip to content

Commit

Permalink
refactor: drop deprecated EveryTestHasSameNamespaceAsTestedClass check (
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Mar 13, 2023
1 parent 08b34e1 commit fc78501
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 262 deletions.
50 changes: 1 addition & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ use PHPUnit\Framework\TestCase;

/**
* @group integration
* @testedClass none
* @coversNothing
*/
final class SuiteComplianceTest extends TestCaseBase
{
Expand Down Expand Up @@ -191,54 +191,6 @@ yield 'Every test has same namespace as tested class' => [
];
```

### Every test has same namespace as tested class

Asserts that all test share same namespace with class they're testing.
Consider src namespace `Ns` and test namespace `Ns/Tests` then for test `Ns/Tests/UnitTest` must exist class `Ns/Unit`.

You can use `@testedClass` annotation to link test with tested class

```php
namespace Ns;

final class Unit {}
```

:x:
```php
namespace Ns\Tests;

final class NonexistentUnitTest extends TestCase {}
```

```php
namespace Ns\Tests\Sub;

final class UnitTest extends TestCase {}
```

:heavy_check_mark:
```php
namespace Ns\Tests;

final class UnitTest extends TestCase {}
```

```php
namespace Ns\Tests\Sub;

/** @testedClass \Ns\Unit */
final class UnitTest extends TestCase {}
```

Configured in test provider as

```php
yield 'Every test has same namespace as tested class' => [
new EveryTestHasSameNamespaceAsTestedClass($testFiles),
];
```

### Every test inherits from testcase base class

Consider you have a base for all tests and want each of them extend it.
Expand Down
98 changes: 0 additions & 98 deletions src/TestCheck/EveryTestHasSameNamespaceAsTestedClass.php

This file was deleted.

58 changes: 0 additions & 58 deletions tests/TestCheck/EveryTestHasSameNamespaceAsTestedClassTest.php

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit fc78501

Please sign in to comment.