-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing test for
ConstantToClassConstantRector
(#7)
* Add missing test for `ConstantToClassConstantRector` * Update namespace
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
tests/Rector/ConstantToClassConstantRector/ConstantToClassConstantRectorTest.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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Contao\Rector\Tests\Rector\ConstantToClassConstantRector; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class ConstantToClassConstantRectorTest extends AbstractRectorTestCase | ||
{ | ||
#[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/config.php'; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/Rector/ConstantToClassConstantRector/config/config.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 | ||
|
||
declare(strict_types=1); | ||
|
||
use Contao\CoreBundle\Monolog\ContaoContext; | ||
use Contao\Rector\Rector\ConstantToClassConstantRector; | ||
use Contao\Rector\ValueObject\ConstantToClassConstant; | ||
use Rector\Config\RectorConfig; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->ruleWithConfiguration(ConstantToClassConstantRector::class, [ | ||
new ConstantToClassConstant('TL_ACCESS', ContaoContext::class, 'ACCESS') | ||
]); | ||
}; |
21 changes: 21 additions & 0 deletions
21
tests/Rector/ConstantToClassConstantRector/fixture/constants.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,21 @@ | ||
<?php | ||
|
||
class Foo extends Controller | ||
{ | ||
public function bar() | ||
{ | ||
$logLevel = TL_ACCESS; | ||
} | ||
} | ||
?> | ||
----- | ||
<?php | ||
|
||
class Foo extends Controller | ||
{ | ||
public function bar() | ||
{ | ||
$logLevel = \Contao\CoreBundle\Monolog\ContaoContext::ACCESS; | ||
} | ||
} | ||
?> |