From dc75b34deb3b969831888abc4bf450fef6106c69 Mon Sep 17 00:00:00 2001 From: Jordan Brauer Date: Wed, 30 Jun 2021 09:51:49 -0500 Subject: [PATCH] refactor: move logic into boolean method in TestCaseFactory --- src/Factories/TestCaseFactory.php | 8 ++++++++ src/Repositories/TestRepository.php | 2 +- tests/.snapshots/success.txt | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index 63eafaff..e849f95e 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -235,4 +235,12 @@ final class TestCaseFactory return $classFQN; } + + /** + * Determine if the test case will receive argument input from Pest, or not. + */ + public function receivesArguments(): bool + { + return $this->dependent === true || count($this->datasets) > 0; + } } diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index 305dc127..47684548 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -142,7 +142,7 @@ final class TestRepository throw new TestAlreadyExist($test->filename, $test->description); } - if ($test->dependent === false && count($test->datasets) === 0) { + if (!$test->receivesArguments()) { $arguments = Reflection::getFunctionArguments($test->test); if (count($arguments) > 0) { diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 0a79e4e9..aa5966c7 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -580,5 +580,5 @@ ✓ it is a test ✓ it uses correct parent class - Tests: 4 incompleted, 7 skipped, 363 passed + Tests: 4 incompleted, 7 skipped, 364 passed \ No newline at end of file