File tree 2 files changed +44
-1
lines changed 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ responses in the given cassette.
61
61
```
62
62
63
63
* When declared on a test method, only requests in that methods will be intercepted and stored in the given cassette.
64
- Note that it can applied on multiple test methods with different cassettes.
64
+ Note that it can be declared on multiple test methods with different cassettes.
65
65
66
66
```php
67
67
use Angelov\PHPUnitPHPVcr\UseCassette;
@@ -82,3 +82,24 @@ Note that it can applied on multiple test methods with different cassettes.
82
82
public function recorded(): void { ... }
83
83
}
84
84
```
85
+
86
+ * When declared both on the class and on a specific method, the name from the attribute declared on the method will be
87
+ used for that method. In this example, the responses from the requests made in the ` example() ` method will be stored in
88
+ ` example.yml ` and the ones from ` recorded() ` in ` example_2.yml ` .
89
+
90
+ ```php
91
+ use Angelov\PHPUnitPHPVcr\UseCassette;
92
+ use PHPUnit\Framework\Attributes\Test;
93
+ use PHPUnit\Framework\TestCase;
94
+
95
+ #[UseCassette("example.yml")]
96
+ class ExampleTest extends TestCase
97
+ {
98
+ #[Test]
99
+ public function example(): void { ... }
100
+
101
+ #[Test]
102
+ #[UseCassette("example_2.yml")]
103
+ public function recorded(): void { ... }
104
+ }
105
+ ```
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Angelov \PHPUnitPHPVcr \Tests ;
6
+
7
+ use Angelov \PHPUnitPHPVcr \UseCassette ;
8
+ use PHPUnit \Framework \Attributes \Test ;
9
+ use PHPUnit \Framework \TestCase ;
10
+
11
+ #[UseCassette("combined_on_class.yml " )]
12
+ class AttributeDeclaredBothOnClassAndMethodTest extends TestCase
13
+ {
14
+ #[Test]
15
+ #[UseCassette("on_methods.yml " )]
16
+ public function it_uses_cassette_from_method_when_declared_on_both_places (): void
17
+ {
18
+ $ content = file_get_contents ("https://example.com " );
19
+
20
+ $ this ->assertSame ("Example body. " , $ content );
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments