Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first "system level" (full-scale integration) tests #5784

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/php_linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
actions:
-
php_version: 7.3
run: vendor/bin/parallel-lint src bin/rector config tests packages rules --colors --exclude packages/rector-generator/templates --exclude rules/psr4/tests/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector/Source --exclude rules/autodiscovery/tests/Rector/FileNode/MoveInterfacesToContractNamespaceDirectoryRector/Expected --exclude packages/node-type-resolver/tests/PerNodeTypeResolver/PropertyFetchTypeResolver/Source/ClassWithNativeProps.php --exclude packages/node-type-resolver/tests/PerNodeTypeResolver/PropertyFetchTypeResolver/Source/ClassWithNativePropsPhp80.php --exclude packages/node-type-resolver/tests/PerNodeTypeResolver/PropertyFetchTypeResolver/Source/ClassWithTypedPropertyTypes.php --exclude rules/nette-kdyby/tests/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector/Source/ExpectedSomeClassCopyEvent.php --exclude rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Source/ExpectedFileManagerUploadEvent.php --exclude rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Source/ExpectedDuplicatedEventParamsUploadEvent.php --exclude rules/type-declaration/tests/Rector/ClassMethod/ParamTypeFromStrictTypedPropertyRector/Source/OutOfControlExternalClass.php
run: vendor/bin/parallel-lint src bin/rector config tests packages rules --colors --exclude tests/system-tests --exclude packages/rector-generator/templates --exclude rules/psr4/tests/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector/Source --exclude rules/autodiscovery/tests/Rector/FileNode/MoveInterfacesToContractNamespaceDirectoryRector/Expected --exclude packages/node-type-resolver/tests/PerNodeTypeResolver/PropertyFetchTypeResolver/Source/ClassWithNativeProps.php --exclude packages/node-type-resolver/tests/PerNodeTypeResolver/PropertyFetchTypeResolver/Source/ClassWithNativePropsPhp80.php --exclude packages/node-type-resolver/tests/PerNodeTypeResolver/PropertyFetchTypeResolver/Source/ClassWithTypedPropertyTypes.php --exclude rules/nette-kdyby/tests/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector/Source/ExpectedSomeClassCopyEvent.php --exclude rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Source/ExpectedFileManagerUploadEvent.php --exclude rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Source/ExpectedDuplicatedEventParamsUploadEvent.php --exclude rules/type-declaration/tests/Rector/ClassMethod/ParamTypeFromStrictTypedPropertyRector/Source/OutOfControlExternalClass.php

-
php_version: 8.0
run: vendor/bin/parallel-lint src bin/rector config tests packages rules --colors --exclude packages/rector-generator/templates
run: vendor/bin/parallel-lint src bin/rector config tests packages rules --colors --exclude tests/system-tests --exclude packages/rector-generator/templates

runs-on: ubuntu-latest

Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/system_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: System Tests

on:
pull_request: null

jobs:
system_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0' ]

name: PHP ${{ matrix.php }} system tests
steps:
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none # disable xdebug, pcov

- name: Install dependencies for Rector
run: composer install --no-progress --ansi

# This workflow runs system tests: Use the Rector application from the source
# checkout to process "fixture" projects in tests/system-tests
# to see if those can be processed successfully

- name: Generate Composer autoloaders in fixture directories
run: |
for FIXTURE in `find tests/system-tests -mindepth 1 -maxdepth 1 -type d`; do
(cd $FIXTURE; composer install --no-progress --ansi)
done

- name: Run system tests
run: |
HAS_FAILURES=0

for FIXTURE in `find tests/system-tests -mindepth 1 -maxdepth 1 -type d`; do
echo "-----> Running $FIXTURE <-----"
if (cd $FIXTURE; ../../../bin/rector process --dry-run --clear-cache); then
echo "-----> Result: OK <-----"
else
echo "-----> Result: FAILED <-----"
HAS_FAILURES=1
fi
done

exit $HAS_FAILURES
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ parameters:
# tests
- tests/DependencyInjection/config

# system-level tests
- tests/system-tests

ignoreErrors:
- '#Parameter \#1 \$children of class PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocNode constructor expects array<PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocChildNode\>, array<int, PHPStan\\PhpDocParser\\Ast\\Node\> given#'

Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<directory>packages-tests</directory>
<directory>utils/*/tests</directory>
<exclude>rules-tests/NetteTesterToPHPUnit/Rector/RenameTesterTestToPHPUnitToTestFileRector/Source/*</exclude>
<exclude>tests/system-tests</exclude>
</testsuite>
</testsuites>

Expand Down
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
'*/Fixture/*',
'*/Source/*',
'*/Expected/*',
__DIR__ . '/tests/system-tests/**',

__DIR__ . '/packages/DoctrineAnnotationGenerated',
]);
Expand Down
7 changes: 7 additions & 0 deletions tests/system-tests/dont-execute-code/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"autoload": {
"psr-4": {
"Symfony\\Component\\Console\\Output\\": "src"
}
}
}
17 changes: 17 additions & 0 deletions tests/system-tests/dont-execute-code/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [__DIR__.'/src']);
$parameters->set(Option::SKIP, [__DIR__.'/vendor']);

$parameters->set(Option::SETS, [SetList::PHP_53]);
};

7 changes: 7 additions & 0 deletions tests/system-tests/dont-execute-code/src/OutputInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\Console\Output;

use Exception;

throw new Exception('Running code from ' . __FILE__);
7 changes: 7 additions & 0 deletions tests/system-tests/parse-php7-code/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"autoload": {
"psr-4": {
"Foo\\": "src"
}
}
}
17 changes: 17 additions & 0 deletions tests/system-tests/parse-php7-code/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [__DIR__.'/src']);
$parameters->set(Option::SKIP, [__DIR__.'/vendor']);

$parameters->set(Option::SETS, [SetList::PHP_53]);
};

12 changes: 12 additions & 0 deletions tests/system-tests/parse-php7-code/src/Foo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Foo;

class Foo
{
public function __construct()
{
$bar = 'baz';
print $bar{2};
}
}
7 changes: 7 additions & 0 deletions tests/system-tests/parse-php8-code/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"autoload": {
"psr-4": {
"Foo\\": "src"
}
}
}
17 changes: 17 additions & 0 deletions tests/system-tests/parse-php8-code/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [__DIR__.'/src']);
$parameters->set(Option::SKIP, [__DIR__.'/vendor']);

$parameters->set(Option::SETS, [SetList::PHP_53]);
};

10 changes: 10 additions & 0 deletions tests/system-tests/parse-php8-code/src/Foo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Foo;

class Foo
{
public function __construct(
public string $property = 'value',
) {}
}