Skip to content

Commit dd50e74

Browse files
Also update mismatching fixtures
1 parent 3ba11e3 commit dd50e74

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

build.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@
171171
<arg value="--filter"/>
172172
<arg value="testAdd"/>
173173
</exec>
174+
175+
<exec executable="php" taskname="php">
176+
<arg path="${basedir}/tests/fixture/generate-mismatching-fixtures.php"/>
177+
</exec>
174178
</target>
175179

176180
<target name="publish-phar" description="Publish PHAR on phar.phpunit.de">
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php declare(strict_types=1);
2+
3+
/*
4+
* This file is part of phpcov.
5+
*
6+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
require __DIR__ . '/../../vendor/autoload.php';
12+
13+
use SebastianBergmann\CodeCoverage\Serialization\Unserializer;
14+
use SebastianBergmann\CodeCoverage\Util\Filesystem;
15+
use SebastianBergmann\CodeCoverage\Version;
16+
17+
$unserializer = new Unserializer;
18+
19+
$world = $unserializer->unserialize(__DIR__ . '/example/coverage/testGreetsWorld.cov');
20+
$name = $unserializer->unserialize(__DIR__ . '/example/coverage/testGreetsWithName.cov');
21+
22+
$write = static function (string $path, array $data): void
23+
{
24+
Filesystem::write(
25+
$path,
26+
'<?php // phpunit/php-code-coverage version ' . Version::id() . PHP_EOL .
27+
"return \unserialize(<<<'END_OF_COVERAGE_SERIALIZATION'" . PHP_EOL .
28+
\serialize($data) . PHP_EOL .
29+
'END_OF_COVERAGE_SERIALIZATION' . PHP_EOL .
30+
');',
31+
);
32+
};
33+
34+
// Mismatching driver: testGreetsWorld keeps original, testGreetsWithName gets different driver
35+
$driverName = $name;
36+
$driverName['buildInformation']['phpCodeCoverage']['driverInformation'] = [
37+
'name' => 'PCOV',
38+
'version' => '1.0.0',
39+
];
40+
$write(__DIR__ . '/mismatching-driver/coverage/testGreetsWorld.cov', $world);
41+
$write(__DIR__ . '/mismatching-driver/coverage/testGreetsWithName.cov', $driverName);
42+
43+
// Mismatching git: both get git info but with different commits
44+
$gitWorld = $world;
45+
$gitWorld['buildInformation']['git'] = [
46+
'originUrl' => 'https://example.com/repo.git',
47+
'branch' => 'main',
48+
'commit' => 'abc123',
49+
'status' => '',
50+
'isClean' => true,
51+
];
52+
$gitName = $name;
53+
$gitName['buildInformation']['git'] = [
54+
'originUrl' => 'https://example.com/repo.git',
55+
'branch' => 'feature',
56+
'commit' => 'def456',
57+
'status' => '',
58+
'isClean' => true,
59+
];
60+
$write(__DIR__ . '/mismatching-git/coverage/testGreetsWorld.cov', $gitWorld);
61+
$write(__DIR__ . '/mismatching-git/coverage/testGreetsWithName.cov', $gitName);
62+
63+
// Mismatching PHP version: testGreetsWorld keeps original, testGreetsWithName gets different version
64+
$phpName = $name;
65+
$phpName['buildInformation']['runtime']['version'] = '8.4.0';
66+
$write(__DIR__ . '/mismatching-php-version/coverage/testGreetsWorld.cov', $world);
67+
$write(__DIR__ . '/mismatching-php-version/coverage/testGreetsWithName.cov', $phpName);
68+
69+
print 'Generated mismatching fixtures' . PHP_EOL;

0 commit comments

Comments
 (0)