mirror of
https://github.com/pestphp/pest.git
synced 2026-03-09 17:27:22 +01:00
feat: note()
This commit is contained in:
@ -29,6 +29,11 @@ trait Testable
|
||||
*/
|
||||
private string $__description;
|
||||
|
||||
/**
|
||||
* The test's notes.
|
||||
*/
|
||||
private static array $__latestNotes = [];
|
||||
|
||||
/**
|
||||
* The test's latest description.
|
||||
*/
|
||||
@ -74,6 +79,18 @@ trait Testable
|
||||
*/
|
||||
private array $__snapshotChanges = [];
|
||||
|
||||
/**
|
||||
* Adds a new "note" to the Test Case.
|
||||
*/
|
||||
public function note(array|string $note): self
|
||||
{
|
||||
$note = is_array($note) ? $note : [$note];
|
||||
|
||||
self::$__latestNotes = array_merge(self::$__latestNotes, $note);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the test case static properties.
|
||||
*/
|
||||
@ -95,6 +112,7 @@ trait Testable
|
||||
if ($test->hasMethod($name)) {
|
||||
$method = $test->getMethod($name);
|
||||
$this->__description = self::$__latestDescription = $method->description;
|
||||
self::$__latestNotes = $method->notes;
|
||||
$this->__describing = $method->describing;
|
||||
$this->__test = $method->getClosure($this);
|
||||
}
|
||||
@ -224,6 +242,7 @@ trait Testable
|
||||
}
|
||||
|
||||
$this->__description = self::$__latestDescription = $description;
|
||||
self::$__latestNotes = $method->notes;
|
||||
|
||||
parent::setUp();
|
||||
|
||||
@ -405,4 +424,12 @@ trait Testable
|
||||
{
|
||||
return self::$__latestDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* The latest printable test case notes.
|
||||
*/
|
||||
public static function getPrintableTestCaseMethodNotes(): array
|
||||
{
|
||||
return self::$__latestNotes;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user