Skip to content

Commit

Permalink
Merge pull request #1494 from creative-commoners/pulls/3/phpunit11
Browse files Browse the repository at this point in the history
DEP Use PHPUnit 11
  • Loading branch information
GuySartorelli authored Sep 18, 2024
2 parents fe97893 + 21b53cd commit 0d4fa27
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 45 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"silverstripe/admin": "^3"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^11.3",
"silverstripe/frameworktest": "^2",
"squizlabs/php_codesniffer": "^3.7",
"silverstripe/cms": "^6",
Expand Down
7 changes: 3 additions & 4 deletions tests/php/Controller/AssetAdminOpenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use SilverStripe\Assets\Folder;
use SilverStripe\Assets\File;
use SilverStripe\Versioned\Versioned;
use PHPUnit\Framework\Attributes\DataProvider;

class AssetAdminOpenTest extends FunctionalTest
{
Expand Down Expand Up @@ -44,7 +45,7 @@ protected function tearDown(): void
parent::tearDown();
}

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

/**
* @dataProvider provideApiRead
*/
#[DataProvider('provideApiRead')]
public function testApiRead(
string $idType,
string $fail,
Expand Down
43 changes: 15 additions & 28 deletions tests/php/Controller/AssetAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use SilverStripe\Security\SecurityToken;
use SilverStripe\Core\Config\Config;
use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FilesInUseFileExtension;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* Tests {@see AssetAdmin}
Expand Down Expand Up @@ -473,7 +474,7 @@ public function testGetClientConfigExtensions()
});
}

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

/**
* @dataProvider provideApiReadDescendantCounts
*/
#[DataProvider('provideApiReadDescendantCounts')]
public function testApiReadDescendantCounts(
string $idsType,
string $fail,
Expand Down Expand Up @@ -556,7 +555,7 @@ public function testApiReadDescendantCounts(
}
}

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

/**
* @dataProvider provideApiReadLiveOwnerCounts
*/
#[DataProvider('provideApiReadLiveOwnerCounts')]
public function testApiReadLiveOwnerCounts(
string $idsType,
string $fail,
Expand Down Expand Up @@ -651,7 +648,7 @@ public function testApiReadLiveOwnerCounts(
}
}

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

/**
* @dataProvider provideApiReadUsage
*/
#[DataProvider('provideApiReadUsage')]
public function testApiReadUsage(
string $idType,
string $fail,
Expand All @@ -708,7 +703,7 @@ public function testApiReadUsage(
}
}

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

/**
* @dataProvider provideApiDelete
*/
#[DataProvider('provideApiDelete')]
public function testApiDelete(
string $idsType,
string $fail,
Expand Down Expand Up @@ -797,7 +790,7 @@ public function testApiDelete(
}
}

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

/**
* @dataProvider provideApiMove
*/
#[DataProvider('provideApiMove')]
public function testApiMove(
string $idsType,
string $fail,
Expand Down Expand Up @@ -910,7 +901,7 @@ public function testApiMove(
}
}

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

/**
* @dataProvider provideApiPublish
*/
#[DataProvider('provideApiPublish')]
public function testApiPublish(
string $idsType,
string $fail,
Expand Down Expand Up @@ -1013,7 +1002,7 @@ public function testApiPublish(
}
}

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

/**
* @dataProvider provideApiUnpublish
*/
#[DataProvider('provideApiUnpublish')]
public function testApiUnpublish(
string $idsType,
string $fail,
Expand Down
9 changes: 5 additions & 4 deletions tests/php/Forms/RemoteFileFormFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Forms\Form;
use SilverStripe\View\Embed\Embeddable;
use PHPUnit\Framework\Attributes\DataProvider;

class RemoteFileFormFactoryTest extends SapphireTest
{
Expand All @@ -33,7 +34,7 @@ protected function setUp(): void
]);
}

public function providerTestAcceptedURLs()
public static function providerTestAcceptedURLs()
{
return [
[
Expand Down Expand Up @@ -74,10 +75,10 @@ public function providerTestAcceptedURLs()
}

/**
* @dataProvider providerTestAcceptedURLs
* @param array $config Config to merge
* @param string $acceptedURL OK url
*/
#[DataProvider('providerTestAcceptedURLs')]
public function testAcceptedURLs($config, $acceptedURL)
{
foreach ($config as $key => $value) {
Expand All @@ -93,7 +94,7 @@ public function testAcceptedURLs($config, $acceptedURL)
$this->assertInstanceOf(Form::class, $fields);
}

public function providerTestRejectedURLs()
public static function providerTestRejectedURLs()
{
return [
[
Expand Down Expand Up @@ -140,11 +141,11 @@ public function providerTestRejectedURLs()
}

/**
* @dataProvider providerTestRejectedURLs
* @param array $config Config to merge
* @param string $rejectedURL rejected url
* @param string $rejectedMessage
*/
#[DataProvider('providerTestRejectedURLs')]
public function testRejectedURLS($config, $rejectedURL)
{
$this->expectException(InvalidRemoteUrlException::class);
Expand Down
7 changes: 3 additions & 4 deletions tests/php/Forms/UploadFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\ORM\ArrayList;
use PHPUnit\Framework\Attributes\DataProvider;

class UploadFieldTest extends SapphireTest
{
Expand Down Expand Up @@ -47,7 +48,7 @@ protected function tearDown(): void
parent::tearDown();
}

public function provideGetUploadMaxFileSize(): array
public static function provideGetUploadMaxFileSize(): array
{
return [
[
Expand All @@ -61,9 +62,7 @@ public function provideGetUploadMaxFileSize(): array
];
}

/**
* @dataProvider provideGetUploadMaxFileSize
*/
#[DataProvider('provideGetUploadMaxFileSize')]
public function testGetUploadMaxFileSize(?int $adminMaxFileSize, int $expected): void
{
Upload_Validator::config()->set('default_max_file_size', ['*' => 100]);
Expand Down
7 changes: 3 additions & 4 deletions tests/php/Model/ThumbnailGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Silverstripe\Assets\Dev\TestAssetStore;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\SapphireTest;
use PHPUnit\Framework\Attributes\DataProvider;

class ThumbnailGeneratorTest extends SapphireTest
{
Expand Down Expand Up @@ -117,17 +118,15 @@ public function testGenerateLink()
$this->assertEquals('/assets/906835357d/TestImage__FitMaxWzEwMCwyMDBd.png', $thumbnail);
}

public function provideAnimatedThumbnail(): array
public static function provideAnimatedThumbnail(): array
{
return [
[true],
[false],
];
}

/**
* @dataProvider provideAnimatedThumbnail
*/
#[DataProvider('provideAnimatedThumbnail')]
public function testAnimatedThumbnail(bool $allowAnimation): void
{
$image = new Image();
Expand Down

0 comments on commit 0d4fa27

Please sign in to comment.