mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
refactor: comments
This commit is contained in:
@ -23,10 +23,8 @@ final class Each
|
||||
|
||||
/**
|
||||
* Creates a new expectation.
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function and($value): Expectation
|
||||
public function and(mixed $value): Expectation
|
||||
{
|
||||
return $this->original->and($value);
|
||||
}
|
||||
|
||||
@ -23,31 +23,31 @@ use RuntimeException;
|
||||
final class TestCaseFactory
|
||||
{
|
||||
/**
|
||||
* Marks this test case as only.
|
||||
* Determines if the Test Case will be the "only" being run.
|
||||
*/
|
||||
public bool $only = false;
|
||||
|
||||
/**
|
||||
* Holds the test closure.
|
||||
* The Test Case closure.
|
||||
*/
|
||||
public Closure $test;
|
||||
|
||||
/**
|
||||
* Holds the dataset, if any.
|
||||
* The Test Case Dataset, if any.
|
||||
*
|
||||
* @var array<Closure|iterable<int|string, mixed>|string>
|
||||
*/
|
||||
public array $datasets = [];
|
||||
|
||||
/**
|
||||
* The FQN of the test case class.
|
||||
* The FQN of the Test Case class.
|
||||
*
|
||||
* @var class-string
|
||||
*/
|
||||
public string $class = TestCase::class;
|
||||
|
||||
/**
|
||||
* An array of FQN of the class traits.
|
||||
* An array of FQN of the Test Case traits.
|
||||
*
|
||||
* @var array <int, class-string>
|
||||
*/
|
||||
@ -57,22 +57,22 @@ final class TestCaseFactory
|
||||
];
|
||||
|
||||
/**
|
||||
* Holds the higher order messages for the factory that are proxyable.
|
||||
* The higher order messages for the factory that are proxyable.
|
||||
*/
|
||||
public HigherOrderMessageCollection $factoryProxies;
|
||||
|
||||
/**
|
||||
* Holds the higher order messages that are proxyable.
|
||||
* The higher order messages that are proxyable.
|
||||
*/
|
||||
public HigherOrderMessageCollection $proxies;
|
||||
|
||||
/**
|
||||
* Holds the higher order messages that are chainable.
|
||||
* The higher order messages that are chainable.
|
||||
*/
|
||||
public HigherOrderMessageCollection $chains;
|
||||
|
||||
/**
|
||||
* Creates a new anonymous test case pending object.
|
||||
* Creates a new Factory instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public string $filename,
|
||||
@ -87,11 +87,11 @@ final class TestCaseFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the anonymous test case.
|
||||
* Makes the Test Case classes.
|
||||
*
|
||||
* @return array<int, TestCase>
|
||||
*/
|
||||
public function build(TestSuite $testSuite): array
|
||||
public function make(): array
|
||||
{
|
||||
if ($this->description === null) {
|
||||
throw ShouldNotHappen::fromMessage('Description can not be empty.');
|
||||
@ -101,10 +101,7 @@ final class TestCaseFactory
|
||||
$proxies = $this->proxies;
|
||||
$factoryTest = $this->test;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
$test = function () use ($chains, $proxies, $factoryTest) {
|
||||
$testClosure = function () use ($chains, $proxies, $factoryTest): mixed {
|
||||
$proxies->proxy($this);
|
||||
$chains->chain($this);
|
||||
|
||||
@ -114,8 +111,8 @@ final class TestCaseFactory
|
||||
|
||||
$className = $this->makeClassFromFilename($this->filename);
|
||||
|
||||
$createTest = function ($description, $data) use ($className, $test) {
|
||||
$testCase = new $className($test, $description, $data);
|
||||
$createTest = function ($description, $data) use ($className, $testClosure) {
|
||||
$testCase = new $className($testClosure, $description, $data);
|
||||
$this->factoryProxies->proxy($testCase);
|
||||
|
||||
return $testCase;
|
||||
@ -127,7 +124,7 @@ final class TestCaseFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a fully qualified class name from the given filename.
|
||||
* Makes a Fully Qualified Class Name from the given filename.
|
||||
*/
|
||||
public function makeClassFromFilename(string $filename): string
|
||||
{
|
||||
|
||||
@ -4,10 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
use Pest\Datasets;
|
||||
use Pest\Expectation;
|
||||
use Pest\PendingObjects\AfterEachCall;
|
||||
use Pest\PendingObjects\BeforeEachCall;
|
||||
use Pest\PendingObjects\TestCall;
|
||||
use Pest\PendingObjects\UsesCall;
|
||||
use Pest\PendingCalls\AfterEachCall;
|
||||
use Pest\PendingCalls\BeforeEachCall;
|
||||
use Pest\PendingCalls\TestCall;
|
||||
use Pest\PendingCalls\UsesCall;
|
||||
use Pest\Support\Backtrace;
|
||||
use Pest\Support\Extendable;
|
||||
use Pest\Support\HigherOrderTapProxy;
|
||||
|
||||
@ -17,7 +17,7 @@ use Pest\TestSuite;
|
||||
final class PestDatasetCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
* The Console Command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
@ -25,7 +25,7 @@ final class PestDatasetCommand extends Command
|
||||
{--test-directory=tests : The name of the tests directory}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
* The Console Command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
@ -14,7 +14,7 @@ use Pest\Laravel\Commands\PestTestCommand;
|
||||
final class PestServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register artisan commands.
|
||||
* Register Artisan Commands.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\PendingObjects;
|
||||
namespace Pest\PendingCalls;
|
||||
|
||||
use Closure;
|
||||
use Pest\Support\Backtrace;
|
||||
@ -17,21 +17,22 @@ use Pest\TestSuite;
|
||||
final class AfterEachCall
|
||||
{
|
||||
/**
|
||||
* Holds the before each closure.
|
||||
* The "afterEach" closure.
|
||||
*/
|
||||
private Closure $closure;
|
||||
|
||||
/**
|
||||
* Holds calls that should be proxied.
|
||||
* The calls that should be proxied.
|
||||
*/
|
||||
private HigherOrderMessageCollection $proxies;
|
||||
|
||||
/**
|
||||
* Creates a new instance of before each call.
|
||||
* Creates a new Pending Call.
|
||||
*/
|
||||
public function __construct(
|
||||
private TestSuite $testSuite,
|
||||
private string $filename, Closure $closure = null
|
||||
private string $filename,
|
||||
Closure $closure = null
|
||||
) {
|
||||
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
||||
|
||||
@ -39,7 +40,7 @@ final class AfterEachCall
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the creation of each call.
|
||||
* Creates the Call.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\PendingObjects;
|
||||
namespace Pest\PendingCalls;
|
||||
|
||||
use Closure;
|
||||
use Pest\Support\Backtrace;
|
||||
@ -22,12 +22,12 @@ final class BeforeEachCall
|
||||
private \Closure $closure;
|
||||
|
||||
/**
|
||||
* Holds calls that should be proxied.
|
||||
* The calls that should be proxied.
|
||||
*/
|
||||
private HigherOrderMessageCollection $proxies;
|
||||
|
||||
/**
|
||||
* Creates a new instance of before each call.
|
||||
* Creates a new Pending Call.
|
||||
*/
|
||||
public function __construct(
|
||||
private TestSuite $testSuite,
|
||||
@ -40,7 +40,7 @@ final class BeforeEachCall
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the creation of each call.
|
||||
* Creates the Call.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\PendingObjects;
|
||||
namespace Pest\PendingCalls;
|
||||
|
||||
use Closure;
|
||||
use Pest\Factories\TestCaseFactory;
|
||||
@ -20,21 +20,17 @@ use SebastianBergmann\Exporter\Exporter;
|
||||
final class TestCall
|
||||
{
|
||||
/**
|
||||
* Holds the test case factory.
|
||||
*
|
||||
* @readonly
|
||||
* The Test Case Factory.
|
||||
*/
|
||||
private TestCaseFactory $testCaseFactory;
|
||||
|
||||
/**
|
||||
* If test call is descriptionLess.
|
||||
*
|
||||
* @readonly
|
||||
*/
|
||||
private bool $descriptionLess = false;
|
||||
private bool $descriptionLess;
|
||||
|
||||
/**
|
||||
* Creates a new instance of a pending test call.
|
||||
* Creates a new Pending Call.
|
||||
*/
|
||||
public function __construct(
|
||||
private TestSuite $testSuite,
|
||||
@ -207,8 +203,7 @@ final class TestCall
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the current test case factory
|
||||
* to the tests repository.
|
||||
* Creates the Call.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\PendingObjects;
|
||||
namespace Pest\PendingCalls;
|
||||
|
||||
use Closure;
|
||||
use Pest\TestSuite;
|
||||
@ -41,7 +41,7 @@ final class UsesCall
|
||||
private array $groups = [];
|
||||
|
||||
/**
|
||||
* Creates a new instance of a pending test uses.
|
||||
* Creates a new Pending Call.
|
||||
*
|
||||
* @param array<int, string> $classAndTraits
|
||||
*/
|
||||
@ -135,7 +135,7 @@ final class UsesCall
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the creation of uses.
|
||||
* Creates the Call.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
@ -13,8 +13,7 @@ final class AddsOutput
|
||||
/**
|
||||
* Executes the Plugin action.
|
||||
*
|
||||
* Provides an opportunity for any plugins that want
|
||||
* to provide additional output after test execution.
|
||||
* Provides an opportunity for any plugins that want to provide additional output after test execution.
|
||||
*/
|
||||
public function __invoke(int $exitCode): int
|
||||
{
|
||||
|
||||
@ -28,7 +28,7 @@ final class Coverage implements AddsOutput, HandlesArguments
|
||||
private const MIN_OPTION = 'min';
|
||||
|
||||
/**
|
||||
* Whether should show the coverage or not.
|
||||
* Whether it should show the coverage or not.
|
||||
*/
|
||||
public bool $coverage = false;
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ final class TestRepository
|
||||
|
||||
foreach ($state as $testFactory) {
|
||||
/** @var TestCaseFactory $testFactory */
|
||||
$tests = $testFactory->build($testSuite);
|
||||
$tests = $testFactory->make($testSuite);
|
||||
foreach ($tests as $test) {
|
||||
$each($test);
|
||||
}
|
||||
|
||||
@ -60,10 +60,9 @@ final class TestSuite
|
||||
/**
|
||||
* Creates a new instance of the test suite.
|
||||
*/
|
||||
public function __construct(string $rootPath, /**
|
||||
* Holds the test path.
|
||||
*/
|
||||
public string $testPath)
|
||||
public function __construct(
|
||||
string $rootPath,
|
||||
public string $testPath)
|
||||
{
|
||||
$this->beforeAll = new BeforeAllRepository();
|
||||
$this->beforeEach = new BeforeEachRepository();
|
||||
@ -71,7 +70,7 @@ final class TestSuite
|
||||
$this->afterEach = new AfterEachRepository();
|
||||
$this->afterAll = new AfterAllRepository();
|
||||
|
||||
$this->rootPath = (string) realpath($rootPath);
|
||||
$this->rootPath = (string) realpath($rootPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Pest\PendingObjects\TestCall;
|
||||
use Pest\PendingCalls\TestCall;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
uses(Gettable::class);
|
||||
|
||||
Reference in New Issue
Block a user