generated from ibexa/bundle-template
-
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.
[Tests] Added coverage for the rule to remove class aliases
- Loading branch information
Showing
6 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
tests/lib/Rule/Internal/RemoveLegacyClassAliasRector/Fixture/another_class.php.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,27 @@ | ||
<?php /** @noinspection ALL */ | ||
|
||
namespace Ibexa\Rector\Tests\Rule\Internal\RemoveLegacyClassAliasRector\Fixture; | ||
|
||
class MyAnotherLegacyClass | ||
{ | ||
public function foo(): void | ||
{ | ||
} | ||
} | ||
|
||
class_alias(MyAnotherLegacyClass::class, 'eZ\Some\Namespace\MyAnotherLegacyClass'); | ||
|
||
?> | ||
----- | ||
<?php /** @noinspection ALL */ | ||
|
||
namespace Ibexa\Rector\Tests\Rule\Internal\RemoveLegacyClassAliasRector\Fixture; | ||
|
||
class MyAnotherLegacyClass | ||
{ | ||
public function foo(): void | ||
{ | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
tests/lib/Rule/Internal/RemoveLegacyClassAliasRector/Fixture/bc_ibexa_class.php.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,27 @@ | ||
<?php /** @noinspection ALL */ | ||
|
||
namespace Ibexa\Rector\Tests\Rule\Internal\RemoveLegacyClassAliasRector\Fixture; | ||
|
||
class MyIbexaClass | ||
{ | ||
public function foo(): void | ||
{ | ||
} | ||
} | ||
|
||
class_alias(MyIbexaClass::class, 'Ibexa\Platform\MyAnotherLegacyClass'); | ||
|
||
?> | ||
----- | ||
<?php /** @noinspection ALL */ | ||
|
||
namespace Ibexa\Rector\Tests\Rule\Internal\RemoveLegacyClassAliasRector\Fixture; | ||
|
||
class MyIbexaClass | ||
{ | ||
public function foo(): void | ||
{ | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
tests/lib/Rule/Internal/RemoveLegacyClassAliasRector/Fixture/some_class.php.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,27 @@ | ||
<?php /** @noinspection ALL */ | ||
|
||
namespace Ibexa\Rector\Tests\Rule\Internal\RemoveLegacyClassAliasRector\Fixture; | ||
|
||
class MyLegacyClass | ||
{ | ||
public function foo(): void | ||
{ | ||
} | ||
} | ||
|
||
class_alias(MyLegacyClass::class, 'EzSystems\Some\Namespace\MyLegacyClass'); | ||
|
||
?> | ||
----- | ||
<?php /** @noinspection ALL */ | ||
|
||
namespace Ibexa\Rector\Tests\Rule\Internal\RemoveLegacyClassAliasRector\Fixture; | ||
|
||
class MyLegacyClass | ||
{ | ||
public function foo(): void | ||
{ | ||
} | ||
} | ||
|
||
?> |
31 changes: 31 additions & 0 deletions
31
tests/lib/Rule/Internal/RemoveLegacyClassAliasRector/Fixture/third_party_class.php.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,31 @@ | ||
<?php /** @noinspection ALL */ | ||
|
||
namespace Ibexa\Rector\Tests\Rule\Internal\RemoveLegacyClassAliasRector\Fixture; | ||
|
||
class ThirdPartyClass | ||
{ | ||
public function foo(): void | ||
{ | ||
} | ||
} | ||
|
||
// this is not ours, should remain | ||
class_alias(ThirdPartyClass::class, 'ThirdPartyVendor\Accidental\Ibexa\Collsion'); | ||
|
||
?> | ||
----- | ||
<?php /** @noinspection ALL */ | ||
|
||
namespace Ibexa\Rector\Tests\Rule\Internal\RemoveLegacyClassAliasRector\Fixture; | ||
|
||
class ThirdPartyClass | ||
{ | ||
public function foo(): void | ||
{ | ||
} | ||
} | ||
|
||
// this is not ours, should remain | ||
class_alias(ThirdPartyClass::class, 'ThirdPartyVendor\Accidental\Ibexa\Collsion'); | ||
|
||
?> |
37 changes: 37 additions & 0 deletions
37
tests/lib/Rule/Internal/RemoveLegacyClassAliasRector/RemoveLegacyClassAliasRectorTest.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,37 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Rector\Tests\Rule\Internal\RemoveLegacyClassAliasRector; | ||
|
||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
/** | ||
* @covers \Ibexa\Rector\Rule\Internal\RemoveLegacyClassAliasRector | ||
*/ | ||
final class RemoveLegacyClassAliasRectorTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @throws \Rector\Exception\ShouldNotHappenException | ||
*/ | ||
#[DataProvider('provideData')] | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public static function provideData(): \Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/lib/Rule/Internal/RemoveLegacyClassAliasRector/config/configured_rule.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,14 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
use Ibexa\Rector\Rule\Internal\RemoveLegacyClassAliasRector; | ||
use Rector\Config\RectorConfig; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(RemoveLegacyClassAliasRector::class); | ||
}; |