Skip to content

Commit 6a01544

Browse files
committed
phpunit 11 updates
1 parent b90347c commit 6a01544

File tree

8 files changed

+58
-144
lines changed

8 files changed

+58
-144
lines changed

tests/Extensions/CacheKeyExtensionTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Terraformers\KeysForCache\Tests\Extensions;
44

55
use Page;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67
use SilverStripe\Dev\SapphireTest;
78
use SilverStripe\ORM\DataList;
89
use SilverStripe\Versioned\Versioned;
@@ -24,9 +25,7 @@ class CacheKeyExtensionTest extends SapphireTest
2425
CachePage::class,
2526
];
2627

27-
/**
28-
* @dataProvider readingModes
29-
*/
28+
#[DataProvider('readingModes')]
3029
public function testWriteGeneratesCacheKey(string $readingMode): void
3130
{
3231
$page = Versioned::withVersionedMode(static function () use ($readingMode): CachePage {
@@ -64,9 +63,7 @@ public function testWriteGeneratesCacheKey(string $readingMode): void
6463
});
6564
}
6665

67-
/**
68-
* @dataProvider readingModes
69-
*/
66+
#[DataProvider('readingModes')]
7067
public function testWriteDoesNotGenerateCacheKey(string $readingMode): void
7168
{
7269
Versioned::withVersionedMode(function () use ($readingMode): void {

tests/Scenarios/CaresTest.php

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Terraformers\KeysForCache\Tests\Scenarios;
44

5+
use PHPUnit\Framework\Attributes\DataProvider;
56
use SilverStripe\Core\Injector\Injector;
67
use SilverStripe\Dev\SapphireTest;
78
use SilverStripe\ORM\DataObject;
@@ -47,9 +48,7 @@ class CaresTest extends SapphireTest
4748
PolymorphicCaredHasMany::class,
4849
];
4950

50-
/**
51-
* @dataProvider readingModesWithSaveMethods
52-
*/
51+
#[DataProvider('readingModesWithSaveMethods')]
5352
public function testCaresPureHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
5453
{
5554
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -69,9 +68,7 @@ public function testCaresPureHasOne(string $readingMode, string $saveMethod, boo
6968
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
7069
}
7170

72-
/**
73-
* @dataProvider readingModesWithSaveMethods
74-
*/
71+
#[DataProvider('readingModesWithSaveMethods')]
7572
public function testCaresBelongsTo(string $readingMode, string $saveMethod, bool $expectKeyChange): void
7673
{
7774
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -91,9 +88,7 @@ public function testCaresBelongsTo(string $readingMode, string $saveMethod, bool
9188
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
9289
}
9390

94-
/**
95-
* @dataProvider readingModesWithSaveMethods
96-
*/
91+
#[DataProvider('readingModesWithSaveMethods')]
9792
public function testCaresHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
9893
{
9994
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -113,9 +108,7 @@ public function testCaresHasOne(string $readingMode, string $saveMethod, bool $e
113108
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
114109
}
115110

116-
/**
117-
* @dataProvider readingModes
118-
*/
111+
#[DataProvider('readingModes')]
119112
public function testCaresHasOneNonVersioned(string $readingMode): void
120113
{
121114
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -157,9 +150,7 @@ public function testCaresHasOneNonVersioned(string $readingMode): void
157150
});
158151
}
159152

160-
/**
161-
* @dataProvider readingModes
162-
*/
153+
#[DataProvider('readingModes')]
163154
public function testCaresHasOneVersionedNonStaged(string $readingMode): void
164155
{
165156
$page = $this->objFromFixture(CaresPage::class, 'page1');
@@ -198,9 +189,7 @@ public function testCaresHasOneVersionedNonStaged(string $readingMode): void
198189
});
199190
}
200191

201-
/**
202-
* @dataProvider readingModesWithSaveMethods
203-
*/
192+
#[DataProvider('readingModesWithSaveMethods')]
204193
public function testPolymorphicCaresHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
205194
{
206195
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -220,9 +209,7 @@ public function testPolymorphicCaresHasOne(string $readingMode, string $saveMeth
220209
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
221210
}
222211

223-
/**
224-
* @dataProvider readingModesWithSaveMethods
225-
*/
212+
#[DataProvider('readingModesWithSaveMethods')]
226213
public function testCaresHasMany(string $readingMode, string $saveMethod, bool $expectKeyChange): void
227214
{
228215
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -238,9 +225,7 @@ public function testCaresHasMany(string $readingMode, string $saveMethod, bool $
238225
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
239226
}
240227

241-
/**
242-
* @dataProvider readingModesWithSaveMethods
243-
*/
228+
#[DataProvider('readingModesWithSaveMethods')]
244229
public function testPolymorphicCaresHasMany(string $readingMode, string $saveMethod, bool $expectKeyChange): void
245230
{
246231
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -256,9 +241,7 @@ public function testPolymorphicCaresHasMany(string $readingMode, string $saveMet
256241
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
257242
}
258243

259-
/**
260-
* @dataProvider readingModesWithSaveMethods
261-
*/
244+
#[DataProvider('readingModesWithSaveMethods')]
262245
public function testManyMany(string $readingMode, string $saveMethod, bool $expectKeyChange): void
263246
{
264247
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -278,9 +261,7 @@ public function testManyMany(string $readingMode, string $saveMethod, bool $expe
278261
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
279262
}
280263

281-
/**
282-
* @dataProvider readingModesWithSaveMethods
283-
*/
264+
#[DataProvider('readingModesWithSaveMethods')]
284265
public function testManyManyThrough(string $readingMode, string $saveMethod, bool $expectKeyChange): void
285266
{
286267
// Updates are processed as part of scaffold, so we need to flush before we kick off

tests/Scenarios/DotNotationCaresTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Terraformers\KeysForCache\Tests\Scenarios;
44

5+
use PHPUnit\Framework\Attributes\DataProvider;
56
use SilverStripe\Core\Injector\Injector;
67
use SilverStripe\Dev\SapphireTest;
78
use SilverStripe\ORM\DataObject;
@@ -29,9 +30,7 @@ class DotNotationCaresTest extends SapphireTest
2930
DotNotationCaredHasOne::class,
3031
];
3132

32-
/**
33-
* @dataProvider readingModesWithSaveMethods
34-
*/
33+
#[DataProvider('readingModesWithSaveMethods')]
3534
public function testCaresPureHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
3635
{
3736
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -55,9 +54,7 @@ public function testCaresPureHasOne(string $readingMode, string $saveMethod, boo
5554
$this->assertCacheKeyChanges($page, $modelOne, $modelTwo, $readingMode, $saveMethod, $expectKeyChange);
5655
}
5756

58-
/**
59-
* @dataProvider readingModesWithSaveMethods
60-
*/
57+
#[DataProvider('readingModesWithSaveMethods')]
6158
public function testCaresBelongsTo(string $readingMode, string $saveMethod, bool $expectKeyChange): void
6259
{
6360
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -122,9 +119,7 @@ function () use ($page, $modelOne, $modelTwo, $readingMode, $saveMethod, $expect
122119
);
123120
}
124121

125-
/**
126-
* @dataProvider readingModesWithSaveMethods
127-
*/
122+
#[DataProvider('readingModesWithSaveMethods')]
128123
public function testCaresHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
129124
{
130125
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -148,9 +143,7 @@ public function testCaresHasOne(string $readingMode, string $saveMethod, bool $e
148143
$this->assertCacheKeyChanges($page, $modelOne, $modelTwo, $readingMode, $saveMethod, $expectKeyChange);
149144
}
150145

151-
/**
152-
* @dataProvider readingModesWithSaveMethods
153-
*/
146+
#[DataProvider('readingModesWithSaveMethods')]
154147
public function testCaresHasMany(string $readingMode, string $saveMethod, bool $expectKeyChange): void
155148
{
156149
// Updates are processed as part of scaffold, so we need to flush before we kick off

tests/Scenarios/DotNotationTouchesTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Terraformers\KeysForCache\Tests\Scenarios;
44

5+
use PHPUnit\Framework\Attributes\DataProvider;
56
use SilverStripe\Core\Injector\Injector;
67
use SilverStripe\Dev\SapphireTest;
78
use SilverStripe\ORM\DataObject;
@@ -33,9 +34,7 @@ class DotNotationTouchesTest extends SapphireTest
3334
DotNotationTouchesBelongsTo::class,
3435
];
3536

36-
/**
37-
* @dataProvider readingModesWithSaveMethods
38-
*/
37+
#[DataProvider('readingModesWithSaveMethods')]
3938
public function testTouchesHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
4039
{
4140
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -59,9 +58,7 @@ public function testTouchesHasOne(string $readingMode, string $saveMethod, bool
5958
$this->assertCacheKeyChanges($page, $modelOne, $modelTwo, $readingMode, $saveMethod, $expectKeyChange);
6059
}
6160

62-
/**
63-
* @dataProvider readingModesWithSaveMethods
64-
*/
61+
#[DataProvider('readingModesWithSaveMethods')]
6562
public function testTouchesPureHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
6663
{
6764
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -85,9 +82,7 @@ public function testTouchesPureHasOne(string $readingMode, string $saveMethod, b
8582
$this->assertCacheKeyChanges($page, $modelOne, $modelTwo, $readingMode, $saveMethod, $expectKeyChange);
8683
}
8784

88-
/**
89-
* @dataProvider readingModesWithSaveMethods
90-
*/
85+
#[DataProvider('readingModesWithSaveMethods')]
9186
public function testTouchesHasMany(string $readingMode, string $saveMethod, bool $expectKeyChange): void
9287
{
9388
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -111,9 +106,7 @@ public function testTouchesHasMany(string $readingMode, string $saveMethod, bool
111106
$this->assertCacheKeyChanges($page, $modelOne, $modelTwo, $readingMode, $saveMethod, $expectKeyChange);
112107
}
113108

114-
/**
115-
* @dataProvider readingModesWithSaveMethods
116-
*/
109+
#[DataProvider('readingModesWithSaveMethods')]
117110
public function testTouchesBelongsTo(string $readingMode, string $saveMethod, bool $expectKeyChange): void
118111
{
119112
// Updates are processed as part of scaffold, so we need to flush before we kick off

tests/Scenarios/ExtendedCaresTest.php

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Terraformers\KeysForCache\Tests\Scenarios;
44

5+
use PHPUnit\Framework\Attributes\DataProvider;
56
use SilverStripe\Core\Injector\Injector;
67
use SilverStripe\Dev\SapphireTest;
78
use SilverStripe\ORM\DataObject;
@@ -53,9 +54,7 @@ class ExtendedCaresTest extends SapphireTest
5354
PolymorphicCaredHasOne::class,
5455
];
5556

56-
/**
57-
* @dataProvider readingModesWithSaveMethods
58-
*/
57+
#[DataProvider('readingModesWithSaveMethods')]
5958
public function testCaresPureHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
6059
{
6160
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -75,9 +74,7 @@ public function testCaresPureHasOne(string $readingMode, string $saveMethod, boo
7574
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
7675
}
7776

78-
/**
79-
* @dataProvider readingModesWithSaveMethods
80-
*/
77+
#[DataProvider('readingModesWithSaveMethods')]
8178
public function testCaresBelongsTo(string $readingMode, string $saveMethod, bool $expectKeyChange): void
8279
{
8380
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -97,9 +94,7 @@ public function testCaresBelongsTo(string $readingMode, string $saveMethod, bool
9794
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
9895
}
9996

100-
/**
101-
* @dataProvider readingModesWithSaveMethods
102-
*/
97+
#[DataProvider('readingModesWithSaveMethods')]
10398
public function testCaresHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
10499
{
105100
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -119,9 +114,7 @@ public function testCaresHasOne(string $readingMode, string $saveMethod, bool $e
119114
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
120115
}
121116

122-
/**
123-
* @dataProvider readingModesWithSaveMethods
124-
*/
117+
#[DataProvider('readingModesWithSaveMethods')]
125118
public function testPolymorphicCaresHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
126119
{
127120
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -141,9 +134,7 @@ public function testPolymorphicCaresHasOne(string $readingMode, string $saveMeth
141134
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
142135
}
143136

144-
/**
145-
* @dataProvider readingModesWithSaveMethods
146-
*/
137+
#[DataProvider('readingModesWithSaveMethods')]
147138
public function testExtendedPolymorphicCaresHasOne(
148139
string $readingMode,
149140
string $saveMethod,
@@ -166,9 +157,7 @@ public function testExtendedPolymorphicCaresHasOne(
166157
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
167158
}
168159

169-
/**
170-
* @dataProvider readingModesWithSaveMethods
171-
*/
160+
#[DataProvider('readingModesWithSaveMethods')]
172161
public function testCaresHasMany(string $readingMode, string $saveMethod, bool $expectKeyChange): void
173162
{
174163
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -184,9 +173,7 @@ public function testCaresHasMany(string $readingMode, string $saveMethod, bool $
184173
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
185174
}
186175

187-
/**
188-
* @dataProvider readingModesWithSaveMethods
189-
*/
176+
#[DataProvider('readingModesWithSaveMethods')]
190177
public function testPolymorphicCaresHasMany(string $readingMode, string $saveMethod, bool $expectKeyChange): void
191178
{
192179
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -202,9 +189,7 @@ public function testPolymorphicCaresHasMany(string $readingMode, string $saveMet
202189
$this->assertCacheKeyChanges($page, $model, $readingMode, $saveMethod, $expectKeyChange);
203190
}
204191

205-
/**
206-
* @dataProvider readingModesWithSaveMethods
207-
*/
192+
#[DataProvider('readingModesWithSaveMethods')]
208193
public function testExtendedPolymorphicCaresHasMany(
209194
string $readingMode,
210195
string $saveMethod,
@@ -225,9 +210,8 @@ public function testExtendedPolymorphicCaresHasMany(
225210

226211
/**
227212
* Testing that Base relationships work when the explicit class is used in the relationship
228-
*
229-
* @dataProvider readingModesWithSaveMethods
230213
*/
214+
#[DataProvider('readingModesWithSaveMethods')]
231215
public function testBaseCaredHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
232216
{
233217
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -245,9 +229,8 @@ public function testBaseCaredHasOne(string $readingMode, string $saveMethod, boo
245229

246230
/**
247231
* Testing that Base relationships work when the explicit class is used in the relationship
248-
*
249-
* @dataProvider readingModesWithSaveMethods
250232
*/
233+
#[DataProvider('readingModesWithSaveMethods')]
251234
public function testBaseCaredHasMany(string $readingMode, string $saveMethod, bool $expectKeyChange): void
252235
{
253236
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -265,9 +248,8 @@ public function testBaseCaredHasMany(string $readingMode, string $saveMethod, bo
265248

266249
/**
267250
* Now testing that a relationship to a Base class still works when the related object is an extended class
268-
*
269-
* @dataProvider readingModesWithSaveMethods
270251
*/
252+
#[DataProvider('readingModesWithSaveMethods')]
271253
public function testExtendedCaredHasOne(string $readingMode, string $saveMethod, bool $expectKeyChange): void
272254
{
273255
// Updates are processed as part of scaffold, so we need to flush before we kick off
@@ -287,9 +269,8 @@ public function testExtendedCaredHasOne(string $readingMode, string $saveMethod,
287269

288270
/**
289271
* Now testing that a relationship to a Base class still works when the related object is an extended class
290-
*
291-
* @dataProvider readingModesWithSaveMethods
292272
*/
273+
#[DataProvider('readingModesWithSaveMethods')]
293274
public function testExtendedCaredHasMany(string $readingMode, string $saveMethod, bool $expectKeyChange): void
294275
{
295276
// Updates are processed as part of scaffold, so we need to flush before we kick off

0 commit comments

Comments
 (0)