-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
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,73 @@ | ||
|
||
name: functional_test_single | ||
|
||
# This test will run on every pull request, and on every commit on any branch | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
schedule: | ||
# Run tests every week (to check for rector changes) | ||
- cron: '0 0 * * 0' | ||
|
||
jobs: | ||
run_functional_test_single: | ||
name: Functional Test | single rectors" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: "${{ matrix.php-version }}" | ||
coverage: none | ||
tools: composer:v2 | ||
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, gd | ||
- name: Setup Drupal | ||
uses: bluehorndigital/[email protected] | ||
with: | ||
version: '^11.0' | ||
path: ~/drupal | ||
- name: Install Drupal Rector | ||
run: | | ||
cd ~/drupal | ||
composer require palantirnet/drupal-rector:@dev --no-progress | ||
- name: Prepare rector_examples folder in the drupal modules directory | ||
run: | | ||
cd ~/drupal | ||
mkdir -p web/modules/custom | ||
cp -R vendor/palantirnet/drupal-rector/tests/functional/* web/modules/custom | ||
# dry-run is expected to return exit code 2 if there are changes, which we are expecting to happen, here. | ||
# an error code of 1 represents other errors. | ||
# @see \Rector\Core\Console\ExitCode::CHANGED_CODE | ||
- name: Run rector against Drupal (dry-run) | ||
run: | | ||
cd ~/drupal | ||
for d in web/modules/custom/*; do | ||
if [ -d "$d" ]; then | ||
cp ${d}/rector.php . | ||
vendor/bin/rector process $d/fixture/module --dry-run --debug || if (($? == 2)); then true; else exit 1; fi | ||
fi | ||
done | ||
- name: Run rector against Drupal | ||
run: | | ||
cd ~/drupal | ||
for d in web/modules/custom/*; do | ||
if [ -d "$d" ]; then | ||
cp ${d}/rector.php . | ||
vendor/bin/rector process $d/fixture/module --debug | ||
fi | ||
done | ||
# diff options: | ||
# -r: recursive | ||
# -u: show the joined context, like git diff | ||
# -b: ignore whitespace | ||
# -B: ignore lines that are only whitespace | ||
- name: Check that the updated examples match expectations | ||
run: | | ||
cd ~/drupal | ||
for d in web/modules/custom/*; do | ||
if [ -d "$d" ]; then | ||
diff -rubB "$d/fixture/module" "$d/fixture/module_updated" | ||
fi | ||
done |
7 changes: 7 additions & 0 deletions
7
tests/functional/HookConverRector/fixture/module/module.module
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,7 @@ | ||
<?php | ||
|
||
function node_user_cancel($edit, UserInterface $account, $method) { | ||
$red = 'red'; | ||
} | ||
|
||
?> |
9 changes: 9 additions & 0 deletions
9
tests/functional/HookConverRector/fixture/module_updated/module.module
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,9 @@ | ||
<?php | ||
|
||
function node_user_cancel($edit, UserInterface $account, $method) { | ||
$red = 'red'; | ||
|
||
// should have been updated | ||
} | ||
|
||
?> |
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); | ||
|
||
use DrupalFinder\DrupalFinder; | ||
use DrupalRector\Set\Drupal10SetList; | ||
use DrupalRector\Set\Drupal8SetList; | ||
use DrupalRector\Set\Drupal9SetList; | ||
use Rector\Config\RectorConfig; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(\DrupalRector\Rector\Convert\HookConvertRector::class); | ||
|
||
$drupalFinder = new DrupalFinder(); | ||
$drupalFinder->locateRoot(__DIR__); | ||
$drupalRoot = $drupalFinder->getDrupalRoot(); | ||
$rectorConfig->autoloadPaths([ | ||
$drupalRoot . '/core', | ||
$drupalRoot . '/modules', | ||
$drupalRoot . '/profiles', | ||
$drupalRoot . '/themes' | ||
]); | ||
|
||
$rectorConfig->skip(['*/upgrade_status/tests/modules/*']); | ||
$rectorConfig->fileExtensions(['php', 'module', 'theme', 'install', 'profile', 'inc', 'engine']); | ||
$rectorConfig->importNames(true, false); | ||
$rectorConfig->importShortClasses(false); | ||
}; |