feat: deprecates only feature

This commit is contained in:
Nuno Maduro
2023-02-14 08:40:02 +00:00
parent ea6af719e0
commit a61db76c24
8 changed files with 8 additions and 88 deletions

View File

@ -13,7 +13,6 @@ use Pest\Exceptions\ShouldNotHappen;
use Pest\Exceptions\TestAlreadyExist;
use Pest\Exceptions\TestDescriptionMissing;
use Pest\Factories\Concerns\HigherOrderable;
use Pest\Plugins\Environment;
use Pest\Support\Reflection;
use Pest\Support\Str;
use Pest\TestSuite;
@ -83,36 +82,17 @@ final class TestCaseFactory
public function make(): void
{
$methodsUsingOnly = $this->methodsUsingOnly();
$methods = array_values(array_filter(
$this->methods,
fn ($method): bool => $methodsUsingOnly === [] || in_array($method, $methodsUsingOnly, true)
));
$methods = $this->methods;
if ($methods !== []) {
$this->evaluate($this->filename, $methods);
}
}
/**
* Returns all the "only" methods.
*
* @return array<int, TestCaseMethodFactory>
*/
public function methodsUsingOnly(): array
{
if (Environment::name() === Environment::CI) {
return [];
}
return array_values(array_filter($this->methods, static fn ($method): bool => $method->only));
}
/**
* Creates a Test Case class using a runtime evaluate.
*
* @param array<int, TestCaseMethodFactory> $methods
* @param array<string, TestCaseMethodFactory> $methods
*/
public function evaluate(string $filename, array $methods): void
{

View File

@ -21,11 +21,6 @@ final class TestCaseMethodFactory
{
use HigherOrderable;
/**
* Determines if the Test Case Method will be the "only" being run.
*/
public bool $only = false;
/**
* Determines if the Test Case Method is a "todo".
*/

View File

@ -121,16 +121,6 @@ final class TestCall
return $this;
}
/**
* Makes the test suite only this test case.
*/
public function only(): self
{
$this->testCaseMethod->only = true;
return $this;
}
/**
* Sets the test group(s).
*/

View File

@ -54,13 +54,7 @@ final class TestRepository
*/
public function getFilenames(): array
{
$testCases = array_filter($this->testCases, static fn (TestCaseFactory $testCase): bool => $testCase->methodsUsingOnly() !== []);
if ($testCases === []) {
$testCases = $this->testCases;
}
return array_values(array_map(static fn (TestCaseFactory $factory): string => $factory->filename, $testCases));
return array_values(array_map(static fn (TestCaseFactory $factory): string => $factory->filename, $this->testCases));
}
/**