Skip to content

Commit

Permalink
Enhancement: Implement SlowTest
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 23, 2021
1 parent 09cdee3 commit 3480e15
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 74 deletions.
5 changes: 4 additions & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ $license = License\Type\MIT::markdown(

$license->save();

$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php74($license->header()));
$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php74($license->header()), [
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
]);

$config->getFinder()
->exclude([
Expand Down
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

For a full diff see [`1902cc2...main`][1902cc2...main].
For a full diff see [`7afa59c...main`][7afa59c...main].

[1902cc2...main]: https://github.com/ergebnis/phpunit-slow-test-collector/compare/1902cc2...main
### Added

* Added `SlowTest` ([#6]), by [@localheinz]

[7afa59c...main]: https://github.com/ergebnis/phpunit-slow-test-collector/compare/7afa59c...main

[#6]: https://github.com/ergebnis/phpunit-slow-test-collector/pull/6

[@localheinz]: https://github.com/localheinz
34 changes: 0 additions & 34 deletions src/Example.php

This file was deleted.

51 changes: 51 additions & 0 deletions src/SlowTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2021 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-collector
*/

namespace Ergebnis\PHPUnit\SlowTestCollector;

use PHPUnit\Event;

final class SlowTest
{
private Event\Code\Test $test;

private Event\Telemetry\Duration $duration;

private function __construct(
Event\Code\Test $test,
Event\Telemetry\Duration $duration
) {
$this->test = $test;
$this->duration = $duration;
}

public static function fromTestAndDuration(
Event\Code\Test $test,
Event\Telemetry\Duration $duration
): self {
return new self(
$test,
$duration
);
}

public function test(): Event\Code\Test
{
return $this->test;
}

public function duration(): Event\Telemetry\Duration
{
return $this->duration;
}
}
37 changes: 0 additions & 37 deletions test/Unit/ExampleTest.php

This file was deleted.

50 changes: 50 additions & 0 deletions test/Unit/SlowTestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2021 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-collector
*/

namespace Ergebnis\PHPUnit\SlowTestCollector\Test\Unit;

use Ergebnis\PHPUnit\SlowTestCollector\SlowTest;
use Ergebnis\Test\Util;
use PHPUnit\Event;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\PHPUnit\SlowTestCollector\SlowTest
*/
final class SlowTestTest extends Framework\TestCase
{
use Util\Helper;

public function testFromTestAndDurationReturnsSlowTest(): void
{
$faker = self::faker();

$test = new Event\Code\Test(
self::class,
$faker->word,
$faker->word
);

$duration = Event\Telemetry\Duration::fromSeconds($faker->numberBetween());

$slowTest = SlowTest::fromTestAndDuration(
$test,
$duration
);

self::assertSame($test, $slowTest->test());
self::assertSame($duration, $slowTest->duration());
}
}

0 comments on commit 3480e15

Please sign in to comment.