Skip to content

Commit

Permalink
Merge pull request #41 from ergebnis/fix/clone
Browse files Browse the repository at this point in the history
Fix: Clone tests
  • Loading branch information
ergebnis-bot committed Jan 26, 2021
2 parents 0de9485 + 28b8115 commit 490963d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 45 deletions.
12 changes: 2 additions & 10 deletions test/Unit/Collector/DefaultCollectorTest.php
Expand Up @@ -142,11 +142,7 @@ public function testCollectDoesNotReplaceSlowTestWhenDurationIsLessThanPreviousS
);

$thirdForSameTest = SlowTest::fromTestDurationAndMaximumDuration(
new Event\Code\Test(
$first->test()->className(),
$first->test()->methodName(),
$first->test()->methodNameWithDataSet(),
),
clone $first->test(),
Event\Telemetry\Duration::fromSecondsAndNanoseconds(
$faker->numberBetween(0, $first->duration()->seconds() - 1),
$faker->numberBetween(0, 999_999_999)
Expand Down Expand Up @@ -207,11 +203,7 @@ public function testCollectReplacesSlowTestWhenDurationIsGreaterThanPreviousSlow
);

$thirdForSameTest = SlowTest::fromTestDurationAndMaximumDuration(
new Event\Code\Test(
$first->test()->className(),
$first->test()->methodName(),
$first->test()->methodNameWithDataSet(),
),
clone $first->test(),
Event\Telemetry\Duration::fromSecondsAndNanoseconds(
$faker->numberBetween($first->duration()->seconds() + 1),
$faker->numberBetween(0, 999_999_999)
Expand Down
12 changes: 2 additions & 10 deletions test/Unit/Subscriber/TestPassedSubscriberTest.php
Expand Up @@ -125,11 +125,7 @@ public function testNotifyDoesNotCollectSlowTestWhenDurationIsEqualToMaximumDura
$preparedTime->nanoseconds()
);

$passedTest = new Event\Code\Test(
Example\SleeperTest::class,
'foo',
'foo with data set #123'
);
$passedTest = clone $preparedTest;

$passedTestEvent = new Event\Test\Passed(
new Event\Telemetry\Info(
Expand Down Expand Up @@ -191,11 +187,7 @@ public function testNotifyCollectsSlowTestWhenDurationIsGreaterThanMaximumDurati
$preparedTime->nanoseconds() + 1
);

$passedTest = new Event\Code\Test(
Example\SleeperTest::class,
'foo',
'foo with data set #123'
);
$passedTest = clone $preparedTest;

$passedTestEvent = new Event\Test\Passed(
new Event\Telemetry\Info(
Expand Down
30 changes: 5 additions & 25 deletions test/Unit/TimeKeeperTest.php
Expand Up @@ -68,11 +68,7 @@ public function testStopReturnsDurationWhenTestHasBeenStartedAndStopped(): void
$faker->numberBetween(0, 999_999_999),
);

$stoppedTest = new Event\Code\Test(
$startedTest->className(),
$startedTest->methodName(),
$startedTest->methodNameWithDataSet(),
);
$stoppedTest = clone $startedTest;

$stoppedTime = Event\Telemetry\HRTime::fromSecondsAndNanoseconds(
$faker->numberBetween($startedTime->seconds() + 1),
Expand Down Expand Up @@ -109,22 +105,14 @@ public function testStopReturnsZeroDurationWhenTestHasBeenStartedAndStoppedAndSt
$faker->numberBetween(0, 999_999_999),
);

$firstStoppedTest = new Event\Code\Test(
$startedTest->className(),
$startedTest->methodName(),
$startedTest->methodNameWithDataSet(),
);
$firstStoppedTest = clone $startedTest;

$firstStoppedTime = Event\Telemetry\HRTime::fromSecondsAndNanoseconds(
$faker->numberBetween($startedTime->seconds() + 1),
$faker->numberBetween(0, 999_999_999),
);

$secondStoppedTest = new Event\Code\Test(
$startedTest->className(),
$startedTest->methodName(),
$startedTest->methodNameWithDataSet(),
);
$secondStoppedTest = clone $startedTest;

$secondStoppedTime = Event\Telemetry\HRTime::fromSecondsAndNanoseconds(
$faker->numberBetween($startedTime->seconds() + 1),
Expand Down Expand Up @@ -166,11 +154,7 @@ public function testCanStartAndStopMultipleTests(): void
$faker->numberBetween(0, 999_999_999),
);

$firstStoppedTest = new Event\Code\Test(
$firstStartedTest->className(),
$firstStartedTest->methodName(),
$firstStartedTest->methodNameWithDataSet(),
);
$firstStoppedTest = clone $firstStartedTest;

$firstStoppedTime = Event\Telemetry\HRTime::fromSecondsAndNanoseconds(
$faker->numberBetween($firstStartedTime->seconds() + 1),
Expand All @@ -188,11 +172,7 @@ public function testCanStartAndStopMultipleTests(): void
$faker->numberBetween(0, 999_999_999),
);

$secondStoppedTest = new Event\Code\Test(
$secondStartedTest->className(),
$secondStartedTest->methodName(),
$secondStartedTest->methodNameWithDataSet(),
);
$secondStoppedTest = clone $secondStartedTest;

$secondStoppedTime = Event\Telemetry\HRTime::fromSecondsAndNanoseconds(
$faker->numberBetween($secondStartedTime->seconds() + 1),
Expand Down

0 comments on commit 490963d

Please sign in to comment.