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

Enhancement: Add support for using Phar with phpunit/phpunit:^7.5.0 #495

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ jobs:
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version11/phpunit.xml"

- name: "Download Phar"
if: "matrix.phpunit-version == '8.5.19' || matrix.phpunit-version == '9.0.0' || matrix.phpunit-version == '10.0.0'"
uses: "actions/[email protected]"
with:
name: "phpunit-slow-test-detector-phar"
Expand All @@ -607,6 +606,10 @@ jobs:
- name: "Remove autoloader for composer"
run: "composer install --ansi --no-autoloader --no-interaction"

- name: "Run phar tests with phpunit/phpunit:7.5.0"
if: "matrix.phpunit-version == '7.5.0'"
run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version07/phpunit.xml"

- name: "Run phar tests with phpunit/phpunit:8.5.19"
if: "matrix.phpunit-version == '8.5.19'"
run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version08/phpunit.xml"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For a full diff see [`2.9.0...main`][2.9.0...main].

- Added support for using `phpunit-slow-test-detector.phar` with `phpunit/phpunit:^9.0.0` ([#491]), by [@localheinz]
- Added support for using `phpunit-slow-test-detector.phar` with `phpunit/phpunit:^8.5.19` ([#494]), by [@localheinz]
- Added support for using `phpunit-slow-test-detector.phar` with `phpunit/phpunit:^7.5.0` ([#495]), by [@localheinz]

## [`2.9.0`][2.9.0]

Expand Down Expand Up @@ -270,6 +271,7 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0].
[#448]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/448
[#491]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/491
[#494]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/494
[#495]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/495

[@HypeMC]: https://github.com/HypeMC
[@localheinz]: https://github.com/localheinz
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ tests: phar ## Runs unit, end-to-end, and phar tests with phpunit/phpunit
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^9.0.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version09/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^10.0.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version10/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:11.0.x-dev --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version11/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^7.5.0 --no-interaction --quiet --update-with-all-dependencies; composer install --no-autoloader --no-interaction --quiet; vendor/bin/phpunit --configuration=test/Phar/Version07/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^8.5.19 --no-interaction --quiet --update-with-all-dependencies; composer install --no-autoloader --no-interaction --quiet; vendor/bin/phpunit --configuration=test/Phar/Version08/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^9.0.0 --no-interaction --quiet --update-with-all-dependencies; composer install --no-autoloader --no-interaction --quiet; vendor/bin/phpunit --configuration=test/Phar/Version09/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^10.0.0 --no-interaction --quiet --update-with-all-dependencies; composer install --no-autoloader --no-interaction --quiet; vendor/bin/phpunit --configuration=test/Phar/Version10/phpunit.xml; git checkout HEAD -- composer.json composer.lock
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ adjust your `phpunit.xml` configuration file and configure the

To bootstrap the extension as a PHAR when using

- `phpunit/phpunit:^7.5.0`
- `phpunit/phpunit:^8.5.19`
- `phpunit/phpunit:^9.0.0`

adjust your `phpunit.xml` configuration file and configure the

- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/7.5/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/7.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^7.5.0`](https://docs.phpunit.de/en/7.5/)
- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/8.5/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/8.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^8.5.19`](https://docs.phpunit.de/en/8.5/)
- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/9.6/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/9.6/configuration.html#the-extensions-element) on [`phpunit/phpunit:^9.0.0`](https://docs.phpunit.de/en/9.5/)

Expand Down
2 changes: 1 addition & 1 deletion manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<phar xmlns="https://phar.io/xml/manifest/1.0">
<contains name="ergebnis/phpunit-slow-test-detector" version="2.9.0" type="extension">
<extension for="phpunit/phpunit" compatible="^8.5 || ^9.0 || ^10.0"/>
<extension for="phpunit/phpunit" compatible="^7.5 || 8.5 || ^9.0 || ^10.0"/>
</contains>

<copyright>
Expand Down
45 changes: 45 additions & 0 deletions test/Phar/Version07/SleeperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2021-2024 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/phpunit-slow-test-detector
*/

namespace Ergebnis\PHPUnit\SlowTestDetector\Test\Phar\Version07;

use Ergebnis\PHPUnit\SlowTestDetector\Test;
use PHPUnit\Framework;

/**
* @covers \Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Sleeper
*/
final class SleeperTest extends Framework\TestCase
{
public function testSleeperDoesNotSleepAtAll(): void
{
$milliseconds = 0;

$sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds);

$sleeper->sleep();

self::assertSame($milliseconds, $sleeper->milliseconds());
}

public function testSleeperSleepsJustAboveDefaultMaximumDuration(): void
{
$milliseconds = 600;

$sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds);

$sleeper->sleep();

self::assertSame($milliseconds, $sleeper->milliseconds());
}
}
14 changes: 14 additions & 0 deletions test/Phar/Version07/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2021-2024 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/phpunit-slow-test-detector
*/

require_once __DIR__ . '/../../Fixture/Sleeper.php';
28 changes: 28 additions & 0 deletions test/Phar/Version07/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="bootstrap.php"
cacheResult="false"
colors="true"
columns="max"
executionOrder="random"
extensionsDirectory="../../../.build/phar/"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true"
>
<extensions>
<extension class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
</extensions>
<testsuites>
<testsuite name="Unit Tests">
<directory>.</directory>
</testsuite>
</testsuites>
</phpunit>
Loading