diff --git a/test/Unit/Collector/DefaultCollectorTest.php b/test/Unit/Collector/DefaultCollectorTest.php index 459532a9..f95efba4 100644 --- a/test/Unit/Collector/DefaultCollectorTest.php +++ b/test/Unit/Collector/DefaultCollectorTest.php @@ -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) @@ -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) diff --git a/test/Unit/Subscriber/TestPassedSubscriberTest.php b/test/Unit/Subscriber/TestPassedSubscriberTest.php index 858d0b45..94e91676 100644 --- a/test/Unit/Subscriber/TestPassedSubscriberTest.php +++ b/test/Unit/Subscriber/TestPassedSubscriberTest.php @@ -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( @@ -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( diff --git a/test/Unit/TimeKeeperTest.php b/test/Unit/TimeKeeperTest.php index 4926f920..1d824f40 100644 --- a/test/Unit/TimeKeeperTest.php +++ b/test/Unit/TimeKeeperTest.php @@ -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), @@ -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), @@ -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), @@ -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),