16
16
use SilverStripe \Security \SecurityToken ;
17
17
use SilverStripe \Versioned \Versioned ;
18
18
use SilverStripe \VersionedAdmin \Forms \HistoryViewerField ;
19
+ use PHPUnit \Framework \Attributes \DataProvider ;
19
20
20
21
class HistoryViewerControllerTest extends FunctionalTest
21
22
{
@@ -63,7 +64,7 @@ public function testGetClientConfig()
63
64
public function testSchema ()
64
65
{
65
66
$ controllerMock = $ this ->getMockBuilder (HistoryViewerController::class)
66
- ->setMethods (['getVersionForm ' , 'getCompareForm ' , 'getSchemaResponse ' ])
67
+ ->onlyMethods (['getVersionForm ' , 'getCompareForm ' , 'getSchemaResponse ' ])
67
68
->getMock ();
68
69
69
70
$ controllerMock ->expects ($ this ->once ())->method ('getVersionForm ' )->with ([
@@ -84,7 +85,7 @@ public function testSchema()
84
85
85
86
$ request = $ this ->getMockBuilder (HTTPRequest::class)
86
87
->setConstructorArgs (['GET ' , '/ ' ])
87
- ->setMethods (['param ' ])
88
+ ->onlyMethods (['param ' ])
88
89
->getMock ();
89
90
$ request ->expects ($ this ->once ())->method ('param ' )->with ('FormName ' )->willReturn ('versionForm ' );
90
91
$ request ->offsetSet ('RecordClass ' , 'Page ' );
@@ -98,7 +99,7 @@ public function testSchema()
98
99
99
100
$ request = $ this ->getMockBuilder (HTTPRequest::class)
100
101
->setConstructorArgs (['GET ' , '/ ' ])
101
- ->setMethods (['param ' ])
102
+ ->onlyMethods (['param ' ])
102
103
->getMock ();
103
104
$ request ->expects ($ this ->once ())->method ('param ' )->with ('FormName ' )->willReturn ('compareForm ' );
104
105
$ request ->offsetSet ('RecordClass ' , 'Page ' );
@@ -202,7 +203,7 @@ public function testVersionFormThrowsExceptionWhenArgsAreFalsy()
202
203
public function testVersionFormReturnsVersionForm ()
203
204
{
204
205
$ controllerMock = $ this ->getMockBuilder (HistoryViewerController::class)
205
- ->setMethods (['getVersionForm ' ])
206
+ ->onlyMethods (['getVersionForm ' ])
206
207
->getMock ();
207
208
208
209
$ mockData = [
@@ -220,7 +221,7 @@ public function testVersionFormReturnsVersionForm()
220
221
$ this ->assertSame ('mocked ' , $ result );
221
222
}
222
223
223
- public function provideApiRead (): array
224
+ public static function provideApiRead (): array
224
225
{
225
226
return [
226
227
'Valid ' => [
@@ -271,9 +272,7 @@ public function provideApiRead(): array
271
272
];
272
273
}
273
274
274
- /**
275
- * @dataProvider provideApiRead
276
- */
275
+ #[DataProvider('provideApiRead ' )]
277
276
public function testApiRead (
278
277
string $ idType ,
279
278
string $ fail ,
@@ -404,7 +403,7 @@ public function testApiRead(
404
403
}
405
404
}
406
405
407
- public function provideApiRevert (): array
406
+ public static function provideApiRevert (): array
408
407
{
409
408
return [
410
409
'Valid ' => [
@@ -470,9 +469,7 @@ public function provideApiRevert(): array
470
469
];
471
470
}
472
471
473
- /**
474
- * @dataProvider provideApiRevert
475
- */
472
+ #[DataProvider('provideApiRevert ' )]
476
473
public function testApiRevert (
477
474
string $ idType ,
478
475
string $ fail ,
0 commit comments