mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
fix: test description on beforeEach failure
This commit is contained in:
@ -185,6 +185,10 @@ trait Testable
|
||||
{
|
||||
TestSuite::getInstance()->test = $this;
|
||||
|
||||
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
|
||||
|
||||
$this->__description = self::$__latestDescription = $this->dataName() ? $method->description.' with '.$this->dataName() : $method->description;
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$beforeEach = TestSuite::getInstance()->beforeEach->get(self::$__filename)[1];
|
||||
@ -234,10 +238,6 @@ trait Testable
|
||||
*/
|
||||
private function __resolveTestArguments(array $arguments): array
|
||||
{
|
||||
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
|
||||
|
||||
$this->__description = self::$__latestDescription = $this->dataName() ? $method->description.' with '.$this->dataName() : $method->description;
|
||||
|
||||
$underlyingTest = Reflection::getFunctionVariable($this->__test, 'closure');
|
||||
$testParameterTypes = array_values(Reflection::getFunctionArguments($underlyingTest));
|
||||
|
||||
|
||||
@ -1052,6 +1052,7 @@
|
||||
✓ it can return an array of all test suite filenames
|
||||
|
||||
PASS Tests\Visual\BeforeEachTestName
|
||||
✓ description
|
||||
✓ latest description
|
||||
|
||||
PASS Tests\Visual\Collision
|
||||
@ -1084,4 +1085,4 @@
|
||||
WARN Tests\Visual\Version
|
||||
- visual snapshot of help command output
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 742 passed (1787 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 743 passed (1788 assertions)
|
||||
@ -1,6 +1,13 @@
|
||||
<?php
|
||||
|
||||
beforeEach(fn () => $this->latestDescription = self::$__latestDescription);
|
||||
beforeEach(function () {
|
||||
$this->description = $this->__description;
|
||||
$this->latestDescription = self::$__latestDescription;
|
||||
});
|
||||
|
||||
test('description', function () {
|
||||
expect($this->description)->toBe('description');
|
||||
});
|
||||
|
||||
test('latest description', function () {
|
||||
expect($this->latestDescription)->toBe('latest description');
|
||||
|
||||
Reference in New Issue
Block a user