Skip to content

Commit 25ea8cf

Browse files
committed
build: add test for t rector.
1 parent fff1efa commit 25ea8cf

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DrupalRector\Rector\BestPractive\UseThisTInsteadOfTRector;
6+
7+
use Iterator;
8+
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
9+
10+
class UseThisTInsteadOfTRectorTest extends AbstractRectorTestCase
11+
{
12+
/**
13+
* @covers ::refactor
14+
*
15+
* @dataProvider provideData
16+
*/
17+
public function test(string $filePath): void
18+
{
19+
$this->doTestFile($filePath);
20+
}
21+
22+
/**
23+
* @return Iterator<<string>>
24+
*/
25+
public static function provideData(): \Iterator
26+
{
27+
return self::yieldFilesFromDirectory(__DIR__.'/fixture');
28+
}
29+
30+
public function provideConfigFilePath(): string
31+
{
32+
// must be implemented
33+
return __DIR__.'/config/configured_rule.php';
34+
}
35+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use DrupalRector\Tests\Rector\Deprecation\DeprecationBase;
6+
use Rector\Config\RectorConfig;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
DeprecationBase::addClass(DrupalRector\Rector\BestPractice\UseThisTInsteadOfTRector::class, $rectorConfig, false);
10+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
class TestT {
3+
public function t($string) {
4+
return $string;
5+
}
6+
}
7+
8+
class NoT extends TestT {
9+
10+
public function doThings() {
11+
return t('Hello world');
12+
}
13+
14+
}
15+
16+
?>
17+
-----
18+
<?php
19+
class TestT {
20+
public function t($string) {
21+
return $string;
22+
}
23+
}
24+
25+
class NoT extends TestT {
26+
27+
public function doThings() {
28+
return $this->t('Hello world');
29+
}
30+
31+
}
32+
33+
?>

0 commit comments

Comments
 (0)