mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
feat(describe): improves logic around hooks
This commit is contained in:
@ -10,6 +10,8 @@ use Pest\Factories\Covers\CoversClass;
|
||||
use Pest\Factories\Covers\CoversFunction;
|
||||
use Pest\Factories\Covers\CoversNothing;
|
||||
use Pest\Factories\TestCaseMethodFactory;
|
||||
use Pest\PendingCalls;
|
||||
use Pest\PendingCalls\Concerns\Describable;
|
||||
use Pest\Plugins\Only;
|
||||
use Pest\Support\Backtrace;
|
||||
use Pest\Support\Exporter;
|
||||
@ -25,10 +27,12 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
final class TestCall
|
||||
{
|
||||
use Describable;
|
||||
|
||||
/**
|
||||
* The Test Case Factory.
|
||||
*/
|
||||
private readonly TestCaseMethodFactory $testCaseMethod;
|
||||
public readonly TestCaseMethodFactory $testCaseMethod;
|
||||
|
||||
/**
|
||||
* If test call is descriptionLess.
|
||||
@ -48,7 +52,7 @@ final class TestCall
|
||||
|
||||
$this->descriptionLess = $description === null;
|
||||
|
||||
$this->testSuite->beforeEach->get($filename)[0]($this);
|
||||
$this->testSuite->beforeEach->get($this->filename)[0]($this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,12 +320,14 @@ final class TestCall
|
||||
private function addChain(string $file, int $line, string $name, array $arguments = null): self
|
||||
{
|
||||
$exporter = Exporter::default();
|
||||
|
||||
$this->testCaseMethod
|
||||
->chains
|
||||
->add($file, $line, $name, $arguments);
|
||||
|
||||
if ($this->descriptionLess) {
|
||||
Exporter::default();
|
||||
|
||||
if ($this->testCaseMethod->description !== null) {
|
||||
$this->testCaseMethod->description .= ' → ';
|
||||
}
|
||||
@ -338,6 +344,10 @@ final class TestCall
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->testSuite->tests->set($this->testCaseMethod);
|
||||
PendingCalls::test($this, function () {
|
||||
$this->testCaseMethod->describing = $this->describing;
|
||||
|
||||
$this->testSuite->tests->set($this->testCaseMethod);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user