add tests to split repository

This commit is contained in:
TomasVotruba 2021-04-23 00:01:56 +02:00
parent 159acc8512
commit 8217d924ff
8 changed files with 121 additions and 0 deletions

View 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

View File

@ -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"

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<phpunit
bootstrap="tests/bootstrap.php"
colors="true"
verbose="true"
>
</phpunit>

View File

@ -0,0 +1,11 @@
<?php
$value = 1000;
?>
-----
<?php
$newValue = 1000;
?>

View 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
{
// ...
}
}

View File

@ -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';
}
}

View File

@ -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);
};

View File

@ -0,0 +1,4 @@
<?php
require_once __DIR__ . '/Rector/RenameSimpleRector.php';
require_once __DIR__ . '/Rector/RenameSimpleRectorTest.php';