Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEP Use PHPUnit 11 #362

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"silverstripe/vendor-plugin": "^2"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^11.3",
"squizlabs/php_codesniffer": "^3.7",
"silverstripe/cms": "^6",
"silverstripe/frameworktest": "^2",
Expand Down
21 changes: 9 additions & 12 deletions tests/Controllers/HistoryViewerControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use SilverStripe\Security\SecurityToken;
use SilverStripe\Versioned\Versioned;
use SilverStripe\VersionedAdmin\Forms\HistoryViewerField;
use PHPUnit\Framework\Attributes\DataProvider;

class HistoryViewerControllerTest extends FunctionalTest
{
Expand Down Expand Up @@ -63,7 +64,7 @@ public function testGetClientConfig()
public function testSchema()
{
$controllerMock = $this->getMockBuilder(HistoryViewerController::class)
->setMethods(['getVersionForm', 'getCompareForm', 'getSchemaResponse'])
->onlyMethods(['getVersionForm', 'getCompareForm', 'getSchemaResponse'])
->getMock();

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

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

$request = $this->getMockBuilder(HTTPRequest::class)
->setConstructorArgs(['GET', '/'])
->setMethods(['param'])
->onlyMethods(['param'])
->getMock();
$request->expects($this->once())->method('param')->with('FormName')->willReturn('compareForm');
$request->offsetSet('RecordClass', 'Page');
Expand Down Expand Up @@ -202,7 +203,7 @@ public function testVersionFormThrowsExceptionWhenArgsAreFalsy()
public function testVersionFormReturnsVersionForm()
{
$controllerMock = $this->getMockBuilder(HistoryViewerController::class)
->setMethods(['getVersionForm'])
->onlyMethods(['getVersionForm'])
->getMock();

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

public function provideApiRead(): array
public static function provideApiRead(): array
{
return [
'Valid' => [
Expand Down Expand Up @@ -271,9 +272,7 @@ public function provideApiRead(): array
];
}

/**
* @dataProvider provideApiRead
*/
#[DataProvider('provideApiRead')]
public function testApiRead(
string $idType,
string $fail,
Expand Down Expand Up @@ -404,7 +403,7 @@ public function testApiRead(
}
}

public function provideApiRevert(): array
public static function provideApiRevert(): array
{
return [
'Valid' => [
Expand Down Expand Up @@ -470,9 +469,7 @@ public function provideApiRevert(): array
];
}

/**
* @dataProvider provideApiRevert
*/
#[DataProvider('provideApiRevert')]
public function testApiRevert(
string $idType,
string $fail,
Expand Down
7 changes: 3 additions & 4 deletions tests/Extensions/FileArchiveExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
use SilverStripe\Assets\AssetControlExtension;
use SilverStripe\Core\Config\Config;
use SilverStripe\Assets\File;
use PHPUnit\Framework\Attributes\DataProvider;

class FileArchiveExtensionTest extends SapphireTest
{
/**
* @dataProvider provideIsArchiveFieldEnabled
*/
#[DataProvider('provideIsArchiveFieldEnabled')]
public function testIsArchiveFieldEnabled(
bool $assetControlExtension,
bool $file,
Expand All @@ -23,7 +22,7 @@ public function testIsArchiveFieldEnabled(
$this->assertSame($expected, $actual);
}

public function provideIsArchiveFieldEnabled(): array
public static function provideIsArchiveFieldEnabled(): array
{
return [
[
Expand Down
7 changes: 3 additions & 4 deletions tests/Forms/DiffFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use SilverStripe\ORM\ManyManyList;
use SilverStripe\Security\Group;
use SilverStripe\VersionedAdmin\Forms\DiffField;
use PHPUnit\Framework\Attributes\DataProvider;

class DiffFieldTest extends SapphireTest
{
Expand Down Expand Up @@ -38,9 +39,7 @@ public function testObjectValuesAreNotDiffed()
$this->assertEquals('(No diff available)', $diffField->Value());
}

/**
* @dataProvider provideEscaping
*/
#[DataProvider('provideEscaping')]
public function testEscaping(
string $className,
string $oldValue,
Expand All @@ -62,7 +61,7 @@ public function testEscaping(
$this->assertSame($expected, $diffField->Value(), $message);
}

public function provideEscaping()
public static function provideEscaping()
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/GridField/GridFieldFileRestoreActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testGetRestoreAction()
$this->assertNull($action->getRestoreAction($gridField, new File(), 'Test'));

$file = $this->getMockBuilder(File::class)
->setMethods(['exists'])
->onlyMethods(['exists'])
->getMock();
$file->method('exists')
->willReturn(true);
Expand Down
Loading