Skip to content

Commit 7aaeac2

Browse files
committed
Revert "Merge pull request #9 from pestphp/feat/rework-api"
This reverts commit eb899f8, reversing changes made to f1df814.
1 parent eb899f8 commit 7aaeac2

110 files changed

Lines changed: 820 additions & 368 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup PHP
1919
uses: shivammathur/setup-php@v2
2020
with:
21-
php-version: 8.2
21+
php-version: 8.1
2222
tools: composer:v2
2323
coverage: none
2424

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [ubuntu-latest] # (macos-latest, windows-latest) 2.x-dev is under development
11-
php: ['8.2', '8.3']
11+
php: ['8.1', '8.2', '8.3']
1212
dependency-version: [prefer-lowest, prefer-stable]
1313
parallel: ['', '--parallel']
1414

@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
php-version: ${{ matrix.php }}
2525
tools: composer:v2
26-
coverage: xdebug
26+
coverage: none
2727

2828
- name: Setup Problem Matches
2929
run: |

composer.json

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,31 @@
1919
"email": "sandrogehri@gmail.com"
2020
}
2121
],
22+
"repositories": {
23+
"pest": {
24+
"type": "vcs",
25+
"url": "https://github.com/gehrisandro/pest"
26+
}
27+
},
2228
"require": {
23-
"php": "^8.2",
24-
"nikic/php-parser": "^5.1.0",
25-
"pestphp/pest-plugin": "^v3.0.0",
26-
"psr/simple-cache": "^3.0.0"
29+
"php": "^8.1",
30+
"nikic/php-parser": "^4.19.1|^v5.0.2",
31+
"pestphp/pest-plugin": "^v2.1.1",
32+
"psr/simple-cache": "^3.0"
2733
},
2834
"require-dev": {
29-
"pestphp/pest": "^v3.0.0",
30-
"pestphp/pest-dev-tools": "^3.0.0",
31-
"pestphp/pest-plugin-type-coverage": "^3.0.0"
35+
"pestphp/pest": "^v2.34.8",
36+
"pestphp/pest-dev-tools": "^2.16",
37+
"pestphp/pest-plugin-type-coverage": "^2.8.1",
38+
"rector/rector": "1.1.0 as 0.16.0"
3239
},
3340
"autoload": {
3441
"psr-4": {
3542
"Pest\\Mutate\\": "src/"
36-
}
43+
},
44+
"files": [
45+
"src/Functions.php"
46+
]
3747
},
3848
"autoload-dev": {
3949
"psr-4": {

phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
</testsuites>
2929
<source>
3030
<include>
31-
<directory suffix=".php">./tests</directory>
3231
<directory suffix=".php">./src</directory>
3332
</include>
3433
</source>

rector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@
2727
SetList::TYPE_DECLARATION,
2828
]);
2929

30+
$rectorConfig->skip([
31+
\Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector::class => [
32+
__DIR__.'/src/Mutators',
33+
],
34+
]);
3035
};

src/Boostrappers/BootPhpUnitSubscribers.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Pest\Mutate\Subscribers\DisablePhpCodeCoverageIfNotRequired;
99
use Pest\Mutate\Subscribers\DisplayInitialTestRunMessage;
1010
use Pest\Mutate\Subscribers\EnsureInitialTestRunWasSuccessful;
11+
use Pest\Mutate\Subscribers\EnsurePrinterIsRegistered;
12+
use Pest\Mutate\Subscribers\EnsureToRunMutationTestingIfRequired;
1113
use Pest\Mutate\Subscribers\PrepareForInitialTestRun;
1214
use Pest\Subscribers;
1315
use Pest\Support\Container;
@@ -29,6 +31,8 @@ final class BootPhpUnitSubscribers implements Bootstrapper
2931
DisplayInitialTestRunMessage::class,
3032
PrepareForInitialTestRun::class,
3133
EnsureInitialTestRunWasSuccessful::class,
34+
EnsureToRunMutationTestingIfRequired::class,
35+
EnsurePrinterIsRegistered::class,
3236
];
3337

3438
/**

src/Cache/FileStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private function filePathFromKey(string $key): string
119119
private function expiration(DateInterval|int|null $seconds): int
120120
{
121121
if ($seconds instanceof DateInterval) {
122-
return (new DateTime)->add($seconds)->getTimestamp();
122+
return (new DateTime())->add($seconds)->getTimestamp();
123123
}
124124

125125
$seconds ??= 0;

src/Contracts/MutationTestRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ public function setOriginalArguments(array $arguments): void;
1717

1818
public function isCodeCoverageRequested(): bool;
1919

20-
public function run(): int;
20+
public function run(): void;
2121
}

src/Decorators/TestCallDecorator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function mutate(string $profile = 'default'): self
4343
$this->configuration = Container::getInstance()->get(ConfigurationRepository::class) // @phpstan-ignore-line
4444
->testConfiguration;
4545
} else {
46-
$this->testRunner = new MutationTestRunnerFake;
46+
$this->testRunner = new MutationTestRunnerFake();
4747

4848
$this->configuration = Container::getInstance()->get(ConfigurationRepository::class) // @phpstan-ignore-line
4949
->fakeTestConfiguration($profile);

src/Functions.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
use Pest\Mutate\Contracts\MutationTestRunner;
5+
use Pest\Mutate\Repositories\ConfigurationRepository;
6+
use Pest\Mutate\Support\Configuration\GlobalConfiguration;
7+
use Pest\PendingCalls\BeforeEachCall;
8+
use Pest\Support\Backtrace;
9+
use Pest\Support\Container;
10+
use Pest\TestSuite;
11+
12+
// @codeCoverageIgnoreStart
13+
if (! function_exists('mutate')) {
14+
// @codeCoverageIgnoreEnd
15+
16+
/**
17+
* Returns a factory to configure the mutation testing profile.
18+
*/
19+
function mutate(string $profile = 'default'): GlobalConfiguration
20+
{
21+
try {
22+
if (! str_ends_with(Backtrace::testFile(), 'Pest.php')) {
23+
Container::getInstance()->get(MutationTestRunner::class)->enable(); // @phpstan-ignore-line
24+
25+
(new BeforeEachCall(TestSuite::getInstance(), Backtrace::testFile(), fn () => null))->only(); // @phpstan-ignore-line
26+
}
27+
} catch (Throwable) { // @phpstan-ignore-line
28+
// @ignoreException
29+
}
30+
31+
return Container::getInstance()->get(ConfigurationRepository::class)->globalConfiguration($profile); // @phpstan-ignore-line
32+
}
33+
}

0 commit comments

Comments
 (0)