Skip to content

Extension bootstrapped by Composer package seems undetected #6334

@llaville

Description

@llaville
Q A
PHPUnit version 11.5.34
PHP version 8.3.6
Installation Method Composer 2.8.9

Related to my comment #6333 (comment)

Summary

Extension bootstapped by Composer package seems undetected

Current behavior

PHPUnit 11.5.34 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.6
Configuration: /home/devilbox/data/sarif-php-sdk/phpunit.xml.dist

NB: no Extension : line printed !

How to reproduce

  1. Clone the repository source code https://github.com/llaville/sarif-php-sdk/tree/2.2 (even if source code seems unrevelant)

  2. Add a PHP sleep function to make test very slow; For example

diff --git a/tests/unit/Builder/BuilderFactoryTest.php b/tests/unit/Builder/BuilderFactoryTest.php
index dd00819..6b7bf01 100644
--- a/tests/unit/Builder/BuilderFactoryTest.php
+++ b/tests/unit/Builder/BuilderFactoryTest.php
@@ -77,7 +77,7 @@ final class BuilderFactoryTest extends TestCase
         $serializer = $factory->createSerializer();

         $jsonString = $serializer->serialize($sarifLog, 'json');
-
+sleep(1);
         $this->assertJsonStringEqualsJsonFile(
             dirname(__DIR__, 2) . '/results/' . $example . '.json',
             $jsonString
  1. Edit the PHPUnit config file to add extension (bootstrapped with Composer package, NO PHAR version used here)
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index e93ef33..7d3bef0 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -3,7 +3,7 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
     backupGlobals="false"
-    bootstrap="vendor/autoload.php"
+    bootstrap="bootstrap.php"
     colors="true"
     stopOnError="false"
     stopOnFailure="false"
@@ -13,6 +13,11 @@
     cacheDirectory=".phpunit.cache"
     backupStaticProperties="false"
 >
+    <extensions>
+        <bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
+            <parameter name="maximum-count" value="50"/>
+        </bootstrap>
+    </extensions>
     <coverage/>
     <testsuites>
         <testsuite name="Unit-Tests">
  1. Add bootstrap.php file with contents
<?php

require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/vendor-bin/phpunit/vendor/autoload.php';
  1. Update PHPUnit and Extension installation
diff --git a/vendor-bin/phpunit/composer.json b/vendor-bin/phpunit/composer.json
index 7e62adf..cd1c45f 100644
--- a/vendor-bin/phpunit/composer.json
+++ b/vendor-bin/phpunit/composer.json
@@ -1,5 +1,6 @@
 {
     "require-dev": {
-        "phpunit/phpunit": "^11.5"
+        "phpunit/phpunit": "^11.5",
+        "ergebnis/phpunit-slow-test-detector": "^2.0"
     }
 }
  1. Install PHPUnit and extension with following command
composer bin phpunit update

Expected behavior

At least display header informations

PHPUnit 11.5.34 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.6
Configuration: /home/devilbox/data/sarif-php-sdk/phpunit.xml.dist
Extension:     ergebnis/phpunit-slow-test-detector 2.20.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions