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

Replace PHPUnitConvecutiveReplacement with WithConsecutive #1937

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
79a4208
Upgrade PHPUnit from 9.6 to 10.5+
maks-rafalko Mar 18, 2024
4d1958f
Remove paratest as 7.0 version doesn't support Symfony 5, for which w…
maks-rafalko Mar 18, 2024
15f75d5
Run `vendor/bin/phpunit`
maks-rafalko Mar 18, 2024
c3cd66c
Try `./vendor/bin/phpunit` because of `'vendor' is not recognized as …
maks-rafalko Mar 18, 2024
7eb20ad
Revert to `vendor/phpunit/phpunit/phpunit`. Try to remove symfony bri…
maks-rafalko Mar 18, 2024
9f84090
Remove symfony helper mentions
maks-rafalko Mar 18, 2024
1607a85
Fix order of `.gitignore` lines
maks-rafalko Mar 18, 2024
eabbb36
Try to force disabling `SYMFONY_DEPRECATIONS_HELPER`
maks-rafalko Mar 18, 2024
bd14acc
Force `SYMFONY_DEPRECATIONS_HELPER=disabled`
maks-rafalko Mar 18, 2024
bdf2659
Force `SYMFONY_DEPRECATIONS_HELPER=disabled` for integration tests
maks-rafalko Mar 18, 2024
99a082c
Merge branch 'master' into feature/new-phpunit
sanmai Mar 19, 2024
8e5b6fa
Merge branch 'master' into feature/new-phpunit
maks-rafalko Mar 19, 2024
56f5bde
Apply suggestion regarding to .gitignore - ignore by * all phpunit files
maks-rafalko Mar 19, 2024
4e4acaf
Remove `SYMFONY_DEPRECATIONS_HELPER=disabled` to demonstrate failing …
maks-rafalko Mar 19, 2024
da444dd
Remove any mentions of `1SYMFONY_DEPRECATION_*` and temporarily disab…
maks-rafalko Mar 19, 2024
683a53b
Revert "Remove any mentions of `1SYMFONY_DEPRECATION_*` and temporari…
maks-rafalko Mar 19, 2024
f8d46bd
Upgrade `fidry/makefile` to 1.0.1
maks-rafalko Mar 19, 2024
021c0af
Merge branch 'master' into feature/new-phpunit
maks-rafalko Mar 19, 2024
43d3aa7
Introduce `WithConsecutive.php` and simplify previously rewritten exa…
maks-rafalko Mar 19, 2024
e426b54
Merge branch 'master' into feature/new-phpunit
maks-rafalko Mar 19, 2024
bf684cc
Revert these
sanmai Mar 20, 2024
4e61c8b
revert these
sanmai Mar 20, 2024
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
47 changes: 23 additions & 24 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,30 @@
'@PHPUnit75Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
// TODO: enable
'array_indentation' => false,
'array_indentation' => true,
'blank_line_before_statement' => false,
// TODO: enable back
// 'blank_line_before_statement' => [
// 'statements' => [
// 'break',
// 'continue',
// 'declare',
// 'do',
// 'for',
// 'foreach',
// 'if',
// 'include',
// 'include_once',
// 'require',
// 'require_once',
// 'return',
// 'switch',
// 'throw',
// 'try',
// 'while',
// 'yield',
// ],
// ],
// TODO: enable back
// 'blank_line_before_statement' => [
// 'statements' => [
// 'break',
// 'continue',
// 'declare',
// 'do',
// 'for',
// 'foreach',
// 'if',
// 'include',
// 'include_once',
// 'require',
// 'require_once',
// 'return',
// 'switch',
// 'throw',
// 'try',
// 'while',
// 'yield',
// ],
// ],
'blank_line_between_import_groups' => false,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
Expand Down
2 changes: 1 addition & 1 deletion src/Differ/DiffSourceCodeMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
final class DiffSourceCodeMatcher
{
private const POSSIBLE_DELIMITERS = [
'#', '%', ':', ';', '=', '?', '@', '^', '~',
'#', '%', ':', ';', '=', '?', '@', '^', '~',
];

public function matches(string $diff, string $sourceCodeRegex): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/GitHubAnnotationsLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getLogLines(): array

{$escapedExecutionResult->getMutantDiff()}
TEXT
,
,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should not be here.

];

$lines[] = $this->buildAnnotation(
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/GitLabCodeQualityLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getLogLines(): array
'location' => [
'path' => Path::makeRelative($escapedExecutionResult->getOriginalFilePath(), $projectRootDirectory),
'lines' => [
'begin' => $escapedExecutionResult->getOriginalStartingLine(),
'begin' => $escapedExecutionResult->getOriginalStartingLine(),
],
],
'severity' => 'major',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public static function codeProvider(): iterable
echo basename('/etc/sudoers.d', '.d');
PHP
,
false, // Cannot detect this one since the call is not fully-qualified and there is no
// use statements - too tricky to detect
false, // Cannot detect this one since the call is not fully-qualified and there is no use statements - too tricky to detect
];

yield 'core function - use statement' => [
Expand Down
30 changes: 11 additions & 19 deletions tests/phpunit/Differ/DiffSourceCodeMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public static function diffRegexProvider(): Generator
return 'string';
}
}
DIFF
,
DIFF,
true,
];

Expand All @@ -95,8 +94,7 @@ public function hello() : string
return 'hello';
}
public function getString()
DIFF
,
DIFF,
true,
];

Expand All @@ -114,8 +112,7 @@ class SourceClass
{
Assert::numeric('1');
$this->getString();
DIFF
,
DIFF,
false,
];

Expand All @@ -133,8 +130,7 @@ public function hello() : string
return 'hello';
}
public function getString()
DIFF
,
DIFF,
true,
];

Expand All @@ -152,8 +148,7 @@ public function hello() : string
$this->getString();
return 'hello';
}
DIFF
,
DIFF,
true,
];

Expand All @@ -165,8 +160,7 @@ public function hello() : string
@@ @@

+ $a - 2 + $this->getString();
DIFF
,
DIFF,
false,
];

Expand All @@ -179,23 +173,21 @@ public function hello() : string

- $a - 2 + $this->getString() / 2; # comment
+ $a - 2 + $this->getString(); # comment
DIFF
,
true,
DIFF,
true,
];

yield 'Regex containing less common delimiters should not lead to syntax error' => [
'.*%.*',
<<<'DIFF'
<<<'DIFF'
--- Original
+++ New
@@ @@

- $a % 2;
+ $a % 3;
DIFF
,
true,
DIFF,
true,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public function test_it_sets_test_framework_version_as_unknown_in_case_of_except
$output->expects($this->once())
->method('writeln')
->with([
'',
'Running initial test suite...',
'',
'PHPUnit version: unknown',
'',
]);
'',
'Running initial test suite...',
'',
'PHPUnit version: unknown',
'',
]);
$output->method('getVerbosity')
->willReturn(OutputInterface::VERBOSITY_QUIET);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
use Infection\Tests\Fixtures\Logger\DummyLineMutationTestingResultsLogger;
use Infection\Tests\Fixtures\Logger\FakeLogger;
use Infection\Tests\Logger\FakeMutationTestingResultsLogger;
use Infection\Tests\WithConsecutive;
use const PHP_EOL;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -176,7 +177,7 @@ public function test_it_outputs_escaped_mutants_when_mutation_testing_is_finishe
$this->output
->expects($this->atLeastOnce())
->method('writeln')
->withConsecutive(
->with(...WithConsecutive::create(
[
[
'',
Expand All @@ -191,7 +192,7 @@ public function test_it_outputs_escaped_mutants_when_mutation_testing_is_finishe
'1) /original/filePath:10 [M] Plus',
],
],
);
));

$executionResult = $this->createMock(MutantExecutionResult::class);
$executionResult->expects($this->once())
Expand Down Expand Up @@ -229,7 +230,7 @@ public function test_it_does_not_output_escaped_mutants_when_mutation_testing_is
$this->output
->expects($this->atLeastOnce())
->method('writeln')
->withConsecutive(
->with(...WithConsecutive::create(
[
[
'',
Expand All @@ -239,7 +240,7 @@ public function test_it_does_not_output_escaped_mutants_when_mutation_testing_is
[
'<options=bold>0</options=bold> mutations were generated:',
],
);
));

$this->resultsCollector->expects($this->once())
->method('getEscapedExecutionResults')
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/Logger/GitLabCodeQualityLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static function metricsProvider(): iterable
'location' => [
'path' => 'foo/bar',
'lines' => [
'begin' => 9,
'begin' => 9,
],
],
'severity' => 'major',
Expand All @@ -100,7 +100,7 @@ public static function metricsProvider(): iterable
'location' => [
'path' => 'foo/bar',
'lines' => [
'begin' => 10,
'begin' => 10,
],
],
'severity' => 'major',
Expand All @@ -121,7 +121,7 @@ public static function metricsProvider(): iterable
'location' => [
'path' => 'foo/bar',
'lines' => [
'begin' => 10,
'begin' => 10,
],
],
'severity' => 'major',
Expand Down
6 changes: 4 additions & 2 deletions tests/phpunit/Metrics/TargetDetectionStatusesProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public function test_it_ignores_some_statuses_when_debugging_is_not_enabled_for_

$provider = new TargetDetectionStatusesProvider($logs, LogVerbosity::NORMAL, false, false);

$this->assertProvidesExcluding([
$this->assertProvidesExcluding(
[
DetectionStatus::KILLED,
DetectionStatus::ERROR,
],
Expand All @@ -119,7 +120,8 @@ public function test_it_ignores_more_statuses_when_running_in_only_covered_mode_

$provider = new TargetDetectionStatusesProvider($logs, LogVerbosity::NORMAL, true, false);

$this->assertProvidesExcluding([
$this->assertProvidesExcluding(
[
DetectionStatus::KILLED,
DetectionStatus::ERROR,
DetectionStatus::NOT_COVERED,
Expand Down
9 changes: 5 additions & 4 deletions tests/phpunit/Mutation/MutationGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
use Infection\Tests\Fixtures\Finder\MockSplFileInfo;
use Infection\Tests\Fixtures\Mutator\FakeMutator;
use Infection\Tests\Fixtures\PhpParser\FakeIgnorer;
use Infection\Tests\WithConsecutive;
use function Later\now;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
Expand Down Expand Up @@ -138,12 +139,12 @@ public function test_it_dispatches_events(): void
$eventDispatcherMock
->expects($this->exactly(4))
->method('dispatch')
->withConsecutive(
->with(...WithConsecutive::create(
[new MutationGenerationWasStarted(2)],
[new MutableFileWasProcessed()],
[new MutableFileWasProcessed()],
[new MutationGenerationWasFinished()],
)
))
;

$fileMutationGeneratorMock = $this->createMock(FileMutationGenerator::class);
Expand Down Expand Up @@ -197,12 +198,12 @@ public function test_it_does_not_count_files_in_concurrent_mode(): void
$eventDispatcherMock
->expects($this->exactly(4))
->method('dispatch')
->withConsecutive(
->with(...WithConsecutive::create(
[new MutationGenerationWasStarted(0)],
[new MutableFileWasProcessed()],
[new MutableFileWasProcessed()],
[new MutationGenerationWasFinished()],
)
))
;

$fileMutationGeneratorMock = $this->createMock(FileMutationGenerator::class);
Expand Down
9 changes: 4 additions & 5 deletions tests/phpunit/Mutator/Arithmetic/DivisionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,20 @@ public function test_it_can_mutate(string $input, $expected = []): void
public static function mutationsProvider(): iterable
{
yield 'It changes regular divison' => [
<<<'PHP'
<<<'PHP'
<?php

$a = 10 / 2;
PHP
,
<<<'PHP'
PHP,
<<<'PHP'
<?php

$a = 10 * 2;
PHP,
];

yield 'It does not change division equals' => [
<<<'PHP'
<<<'PHP'
<?php

$a = 10;
Expand Down
9 changes: 4 additions & 5 deletions tests/phpunit/Mutator/Arithmetic/MultiplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,20 @@ public function test_it_can_mutate(string $input, $expected = []): void
public static function mutationsProvider(): iterable
{
yield 'It mutates normal multiplication' => [
<<<'PHP'
<<<'PHP'
<?php

$a = 10 * 3;
PHP
,
<<<'PHP'
PHP,
<<<'PHP'
<?php

$a = 10 / 3;
PHP,
];

yield 'It does not mutate multiplication equals' => [
<<<'PHP'
<<<'PHP'
<?php

$a = 1;
Expand Down