feat: note()

This commit is contained in:
Nuno Maduro
2024-06-27 01:26:54 +01:00
parent d9252e85d6
commit 5c3bf469d5
10 changed files with 118 additions and 3 deletions

View File

@ -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;
}
}