mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-29 11:33:33 +01:00
add tests to split repository
This commit is contained in:
parent
159acc8512
commit
8217d924ff
22
build/target-repository/.github/workflows/simple_test.yaml
vendored
Normal file
22
build/target-repository/.github/workflows/simple_test.yaml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
name: Simple Test
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
simple_test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none
|
||||
|
||||
- run: composer require phpunit/phpunit --dev
|
||||
- run: vendor/bin/phpunit tests/Rector/RenameSimpleRectorTest.php
|
@ -9,6 +9,11 @@
|
||||
"php": "^7.0|^8.0",
|
||||
"phpstan/phpstan": "^0.12.83"
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"build/target-repository/tests/Rector"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "0.10-dev"
|
||||
|
7
build/target-repository/phpunit.xml
Normal file
7
build/target-repository/phpunit.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<phpunit
|
||||
bootstrap="tests/bootstrap.php"
|
||||
colors="true"
|
||||
verbose="true"
|
||||
>
|
||||
</phpunit>
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$value = 1000;
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
$newValue = 1000;
|
||||
|
||||
?>
|
34
build/target-repository/tests/Rector/RenameSimpleRector.php
Normal file
34
build/target-repository/tests/Rector/RenameSimpleRector.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
||||
/**
|
||||
* @see \RenameSimpleRectorTest
|
||||
*/
|
||||
final class RenameSimpleRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @return array<class-string<\PhpParser\Node>>
|
||||
*/
|
||||
public function getNodeTypes(): array
|
||||
{
|
||||
return [Variable::class];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Variable $node
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
$node->name = 'newValue';
|
||||
return $node;
|
||||
}
|
||||
|
||||
public function getRuleDefinition(): RuleDefinition
|
||||
{
|
||||
// ...
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class RenameSimpleRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test(SmartFileInfo $fileInfo): void
|
||||
{
|
||||
$this->doTestFileInfo($fileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Iterator<SmartFileInfo>
|
||||
*/
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureWithPolyfill');
|
||||
}
|
||||
|
||||
public function provideConfigFilePath(): string
|
||||
{
|
||||
return __DIR__ . '/config/configured_rule.php';
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RenameSimpleRector::class);
|
||||
};
|
4
build/target-repository/tests/bootstrap.php
Normal file
4
build/target-repository/tests/bootstrap.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/Rector/RenameSimpleRector.php';
|
||||
require_once __DIR__ . '/Rector/RenameSimpleRectorTest.php';
|
Loading…
x
Reference in New Issue
Block a user