Skip to content

Commit 2fd7d43

Browse files
Merge branch '10.5' into 11.5
* 10.5: Exclude src/autoload.php Revert "Load Xdebug for end-to-end tests" Load Xdebug for end-to-end tests Add test
2 parents 5cb2ad4 + d70d186 commit 2fd7d43

File tree

6 files changed

+139
-0
lines changed

6 files changed

+139
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd"
4+
bootstrap="src/autoload.php"
5+
beStrictAboutCoverageMetadata="true">
6+
<testsuites>
7+
<testsuite name="default">
8+
<directory>tests</directory>
9+
</testsuite>
10+
</testsuites>
11+
12+
<source>
13+
<include>
14+
<directory>src</directory>
15+
</include>
16+
17+
<exclude>
18+
<file>src/autoload.php</file>
19+
</exclude>
20+
</source>
21+
</phpunit>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\Event\RiskyCodeCoverage;
11+
12+
final class Bar
13+
{
14+
public function doSomethingElse(): bool
15+
{
16+
return true;
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\Event\RiskyCodeCoverage;
11+
12+
final class Foo
13+
{
14+
public function doSomething(): bool
15+
{
16+
return (new Bar)->doSomethingElse();
17+
}
18+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\Event\RiskyCodeCoverage;
11+
12+
require __DIR__ . '/Foo.php';
13+
14+
require __DIR__ . '/Bar.php';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\Event\RiskyCodeCoverage;
11+
12+
use PHPUnit\Framework\Attributes\CoversClass;
13+
use PHPUnit\Framework\TestCase;
14+
15+
#[CoversClass(Foo::class)]
16+
final class FooTest extends TestCase
17+
{
18+
public function testSomething(): void
19+
{
20+
$this->assertTrue((new Foo)->doSomething());
21+
}
22+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--TEST--
2+
The right events are emitted in the right order for a test that is considered risky because it executed code that is not listed as code to be covered or used
3+
--SKIPIF--
4+
<?php declare(strict_types=1);
5+
if (!extension_loaded('xdebug')) {
6+
print 'skip: Extension Xdebug must be loaded.';
7+
}
8+
--INI--
9+
xdebug.mode=coverage
10+
--FILE--
11+
<?php declare(strict_types=1);
12+
$_SERVER['argv'][] = '--do-not-cache-result';
13+
$_SERVER['argv'][] = '--debug';
14+
$_SERVER['argv'][] = '--coverage-text';
15+
$_SERVER['argv'][] = '--configuration';
16+
$_SERVER['argv'][] = __DIR__ . '/_files/test-risky-code-coverage';
17+
18+
require __DIR__ . '/../../bootstrap.php';
19+
20+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
21+
--EXPECTF--
22+
PHPUnit Started (PHPUnit %s using %s)
23+
Test Runner Configured
24+
Bootstrap Finished (%sautoload.php)
25+
Event Facade Sealed
26+
Test Suite Loaded (1 test)
27+
Test Runner Started
28+
Test Suite Sorted
29+
Test Runner Execution Started (1 test)
30+
Test Suite Started (%sphpunit.xml, 1 test)
31+
Test Suite Started (default, 1 test)
32+
Test Suite Started (PHPUnit\TestFixture\Event\RiskyCodeCoverage\FooTest, 1 test)
33+
Test Preparation Started (PHPUnit\TestFixture\Event\RiskyCodeCoverage\FooTest::testSomething)
34+
Test Prepared (PHPUnit\TestFixture\Event\RiskyCodeCoverage\FooTest::testSomething)
35+
Test Passed (PHPUnit\TestFixture\Event\RiskyCodeCoverage\FooTest::testSomething)
36+
Test Considered Risky (PHPUnit\TestFixture\Event\RiskyCodeCoverage\FooTest::testSomething)
37+
This test executed code that is not listed as code to be covered or used:
38+
- PHPUnit\TestFixture\Event\RiskyCodeCoverage\Bar
39+
40+
Test Finished (PHPUnit\TestFixture\Event\RiskyCodeCoverage\FooTest::testSomething)
41+
Test Suite Finished (PHPUnit\TestFixture\Event\RiskyCodeCoverage\FooTest, 1 test)
42+
Test Suite Finished (default, 1 test)
43+
Test Suite Finished (%sphpunit.xml, 1 test)
44+
Test Runner Execution Finished
45+
Test Runner Finished
46+
PHPUnit Finished (Shell Exit Code: 0)

0 commit comments

Comments
 (0)