Skip to content

Commit 33d9f9a

Browse files
committed
add e2e test for no-diffs format json
1 parent 6d8f4ad commit 33d9f9a

7 files changed

Lines changed: 57 additions & 0 deletions

File tree

.github/workflows/e2e_with_no_diffs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
php_version: ['8.3']
2626
directory:
2727
- 'e2e/applied-rule-removed-node-no-diffs'
28+
- 'e2e/applied-no-diffs-format-json'
2829

2930
name: End to end test - ${{ matrix.directory }}
3031

@@ -47,3 +48,9 @@ jobs:
4748
# run e2e test
4849
- run: php ../e2eTestRunner.php --no-diffs
4950
working-directory: ${{ matrix.directory }}
51+
if: ${{ matrix.directory == 'e2e/applied-rule-removed-node-no-diffs' }}
52+
53+
# run e2e test
54+
- run: php ../e2eTestRunner.php --no-diffs --output-format=json
55+
working-directory: ${{ matrix.directory }}
56+
if: ${{ matrix.directory == 'e2e/applied-no-diffs-format-json' }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"require": {
3+
"php": "^8.1"
4+
},
5+
"minimum-stability": "dev",
6+
"prefer-stable": true
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"totals": {
3+
"changed_files": 1,
4+
"errors": 0
5+
},
6+
"changed_files": [
7+
"src/RemoveAlwaysElse.php"
8+
],
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
$rectorConfig->paths([
10+
__DIR__ . '/src',
11+
]);
12+
13+
$rectorConfig->rules([
14+
RemoveAlwaysElseRector::class,
15+
]);
16+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
class RemoveAlwaysElse
4+
{
5+
public function run($value)
6+
{
7+
if ($value) {
8+
throw new \InvalidStateException;
9+
} else {
10+
return 10;
11+
}
12+
}
13+
}

e2e/e2eTestRunner.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
$e2eCommand .= ' --no-diffs';
3737
}
3838

39+
if (isset($argv[2]) && $argv[2] === '--output-format=json') {
40+
$e2eCommand .= ' --output-format=json';
41+
}
42+
3943
$cliOptions = 'cli-options.txt';
4044
if (file_exists($cliOptions)) {
4145
$e2eCommand .= ' ' . trim((string) file_get_contents($cliOptions));

0 commit comments

Comments
 (0)