Skip to content

Commit 7725c4e

Browse files
committed
DEP Use PHPUnit 11
1 parent 45cb904 commit 7725c4e

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"silverstripe/vendor-plugin": "^2"
2828
},
2929
"require-dev": {
30-
"phpunit/phpunit": "^9.6",
30+
"phpunit/phpunit": "^11.3",
3131
"squizlabs/php_codesniffer": "^3.7",
3232
"silverstripe/cms": "^6",
3333
"silverstripe/frameworktest": "^2",

tests/Controllers/HistoryViewerControllerTest.php

+9-12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use SilverStripe\Security\SecurityToken;
1717
use SilverStripe\Versioned\Versioned;
1818
use SilverStripe\VersionedAdmin\Forms\HistoryViewerField;
19+
use PHPUnit\Framework\Attributes\DataProvider;
1920

2021
class HistoryViewerControllerTest extends FunctionalTest
2122
{
@@ -63,7 +64,7 @@ public function testGetClientConfig()
6364
public function testSchema()
6465
{
6566
$controllerMock = $this->getMockBuilder(HistoryViewerController::class)
66-
->setMethods(['getVersionForm', 'getCompareForm', 'getSchemaResponse'])
67+
->onlyMethods(['getVersionForm', 'getCompareForm', 'getSchemaResponse'])
6768
->getMock();
6869

6970
$controllerMock->expects($this->once())->method('getVersionForm')->with([
@@ -84,7 +85,7 @@ public function testSchema()
8485

8586
$request = $this->getMockBuilder(HTTPRequest::class)
8687
->setConstructorArgs(['GET', '/'])
87-
->setMethods(['param'])
88+
->onlyMethods(['param'])
8889
->getMock();
8990
$request->expects($this->once())->method('param')->with('FormName')->willReturn('versionForm');
9091
$request->offsetSet('RecordClass', 'Page');
@@ -98,7 +99,7 @@ public function testSchema()
9899

99100
$request = $this->getMockBuilder(HTTPRequest::class)
100101
->setConstructorArgs(['GET', '/'])
101-
->setMethods(['param'])
102+
->onlyMethods(['param'])
102103
->getMock();
103104
$request->expects($this->once())->method('param')->with('FormName')->willReturn('compareForm');
104105
$request->offsetSet('RecordClass', 'Page');
@@ -202,7 +203,7 @@ public function testVersionFormThrowsExceptionWhenArgsAreFalsy()
202203
public function testVersionFormReturnsVersionForm()
203204
{
204205
$controllerMock = $this->getMockBuilder(HistoryViewerController::class)
205-
->setMethods(['getVersionForm'])
206+
->onlyMethods(['getVersionForm'])
206207
->getMock();
207208

208209
$mockData = [
@@ -220,7 +221,7 @@ public function testVersionFormReturnsVersionForm()
220221
$this->assertSame('mocked', $result);
221222
}
222223

223-
public function provideApiRead(): array
224+
public static function provideApiRead(): array
224225
{
225226
return [
226227
'Valid' => [
@@ -271,9 +272,7 @@ public function provideApiRead(): array
271272
];
272273
}
273274

274-
/**
275-
* @dataProvider provideApiRead
276-
*/
275+
#[DataProvider('provideApiRead')]
277276
public function testApiRead(
278277
string $idType,
279278
string $fail,
@@ -404,7 +403,7 @@ public function testApiRead(
404403
}
405404
}
406405

407-
public function provideApiRevert(): array
406+
public static function provideApiRevert(): array
408407
{
409408
return [
410409
'Valid' => [
@@ -470,9 +469,7 @@ public function provideApiRevert(): array
470469
];
471470
}
472471

473-
/**
474-
* @dataProvider provideApiRevert
475-
*/
472+
#[DataProvider('provideApiRevert')]
476473
public function testApiRevert(
477474
string $idType,
478475
string $fail,

tests/Extensions/FileArchiveExtensionTest.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
use SilverStripe\Assets\AssetControlExtension;
77
use SilverStripe\Core\Config\Config;
88
use SilverStripe\Assets\File;
9+
use PHPUnit\Framework\Attributes\DataProvider;
910

1011
class FileArchiveExtensionTest extends SapphireTest
1112
{
12-
/**
13-
* @dataProvider provideIsArchiveFieldEnabled
14-
*/
13+
#[DataProvider('provideIsArchiveFieldEnabled')]
1514
public function testIsArchiveFieldEnabled(
1615
bool $assetControlExtension,
1716
bool $file,
@@ -23,7 +22,7 @@ public function testIsArchiveFieldEnabled(
2322
$this->assertSame($expected, $actual);
2423
}
2524

26-
public function provideIsArchiveFieldEnabled(): array
25+
public static function provideIsArchiveFieldEnabled(): array
2726
{
2827
return [
2928
[

tests/Forms/DiffFieldTest.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use SilverStripe\ORM\ManyManyList;
1111
use SilverStripe\Security\Group;
1212
use SilverStripe\VersionedAdmin\Forms\DiffField;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314

1415
class DiffFieldTest extends SapphireTest
1516
{
@@ -38,9 +39,7 @@ public function testObjectValuesAreNotDiffed()
3839
$this->assertEquals('(No diff available)', $diffField->Value());
3940
}
4041

41-
/**
42-
* @dataProvider provideEscaping
43-
*/
42+
#[DataProvider('provideEscaping')]
4443
public function testEscaping(
4544
string $className,
4645
string $oldValue,
@@ -62,7 +61,7 @@ public function testEscaping(
6261
$this->assertSame($expected, $diffField->Value(), $message);
6362
}
6463

65-
public function provideEscaping()
64+
public static function provideEscaping()
6665
{
6766
return [
6867
[

tests/Forms/GridField/GridFieldFileRestoreActionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testGetRestoreAction()
2323
$this->assertNull($action->getRestoreAction($gridField, new File(), 'Test'));
2424

2525
$file = $this->getMockBuilder(File::class)
26-
->setMethods(['exists'])
26+
->onlyMethods(['exists'])
2727
->getMock();
2828
$file->method('exists')
2929
->willReturn(true);

0 commit comments

Comments
 (0)