-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.php
More file actions
57 lines (54 loc) · 1.79 KB
/
Test.php
File metadata and controls
57 lines (54 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace Testo;
/**
* Declares a class, method, or function as a test for the attribute-driven locator.
*
* This is the canonical way to opt into Testo's discovery. A class does not need to
* extend any base class — placing this attribute is enough to make it (or its members)
* visible to the locator.
*
* Behavior depends on the target:
*
* On a class — every public method with a {@see void} or {@see never} return type becomes a test.
* Methods with any other return type are intentionally skipped so they can act as data
* providers or helpers without an extra attribute. Abstract classes are not picked up.
*
* ```
* #[Test]
* final class OrderTest
* {
* public function createsOrder(): void { ... } // discovered
* public function calculatesTotal(): void { ... } // discovered
*
* public function orderProvider(): iterable { ... } // skipped (non-void return)
* protected function helper(): void { ... } // skipped (not public)
* }
* ```
*
* On a method — only that specific method is registered as a test. Use this when the
* containing class mixes tests with non-test public methods, or when individual methods
* need to be opted in explicitly.
*
* ```
* final class OrderTest
* {
* #[Test]
* public function createsOrder(): void { ... }
*
* public function notATest(): void { ... } // ignored, no attribute
* }
* ```
*
* On a function — registers a standalone, class-less test. All function-level tests
* declared in the same file are grouped under a single synthetic case.
*
* ```
* #[Test]
* function creates_order(): void { ... }
* ```
*
* @api
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION | \Attribute::TARGET_CLASS)]
final readonly class Test {}