diff --git a/composer.json b/composer.json index c4e999e4..ece4f29f 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "silverstripe/vendor-plugin": "^2" }, "require-dev": { - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^11.3", "squizlabs/php_codesniffer": "^3.7", "silverstripe/standards": "^1", "phpstan/extension-installer": "^1.3" diff --git a/tests/ReportAdminTest.php b/tests/ReportAdminTest.php index 36776c6d..d29b2819 100644 --- a/tests/ReportAdminTest.php +++ b/tests/ReportAdminTest.php @@ -10,6 +10,7 @@ use SilverStripe\Reports\ReportAdmin; use SilverStripe\Reports\Tests\ReportAdminTest\CannotViewReport; use SilverStripe\Reports\Tests\ReportAdminTest\FakeReport; use SilverStripe\Reports\Tests\ReportAdminTest\FakeReport2; +use PHPUnit\Framework\Attributes\DataProvider; class ReportAdminTest extends FunctionalTest { @@ -46,7 +47,7 @@ class ReportAdminTest extends FunctionalTest $this->assertSame('Fake report two', $map['Title']); } - public function provideShowReport(): array + public static function provideShowReport(): array { return [ 'cannot view' => [ @@ -60,9 +61,7 @@ class ReportAdminTest extends FunctionalTest ]; } - /** - * @dataProvider provideShowReport - */ + #[DataProvider('provideShowReport')] public function testShowReport(string $reportClass, int $expected): void { $this->logInWithPermission('ADMIN'); diff --git a/tests/ReportTest.php b/tests/ReportTest.php index 07168461..da980ab7 100644 --- a/tests/ReportTest.php +++ b/tests/ReportTest.php @@ -6,8 +6,8 @@ use SilverStripe\Core\Config\Config; use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\GridField\GridFieldDataColumns; use SilverStripe\Reports\Tests\ReportTest\FakeObject; -use SilverStripe\Reports\Tests\ReportTest\FakeTest; -use SilverStripe\Reports\Tests\ReportTest\FakeTest2; +use SilverStripe\Reports\Tests\ReportTest\FakeReport; +use SilverStripe\Reports\Tests\ReportTest\FakeReport2; use SilverStripe\Reports\Report; class ReportTest extends SapphireTest @@ -34,22 +34,22 @@ class ReportTest extends SapphireTest foreach ($reports as $report) { $reportNames[] = get_class($report); } - $this->assertContains(FakeTest::class, $reportNames, 'ReportTest_FakeTest is in reports list'); + $this->assertContains(FakeReport::class, $reportNames, 'ReportTest_FakeReport is in reports list'); // Exclude one report - Config::modify()->merge(Report::class, 'excluded_reports', [FakeTest::class]); + Config::modify()->merge(Report::class, 'excluded_reports', [FakeReport::class]); $reports = Report::get_reports(); $reportNames = array(); foreach ($reports as $report) { $reportNames[] = get_class($report); } - $this->assertNotContains(FakeTest::class, $reportNames, 'ReportTest_FakeTest is NOT in reports list'); + $this->assertNotContains(FakeReport::class, $reportNames, 'ReportTest_FakeReport is NOT in reports list'); // Exclude two reports Config::modify()->merge(Report::class, 'excluded_reports', [ - FakeTest::class, - FakeTest2::class + FakeReport::class, + FakeReport2::class ]); $reports = Report::get_reports(); @@ -57,8 +57,8 @@ class ReportTest extends SapphireTest foreach ($reports as $report) { $reportNames[] = get_class($report); } - $this->assertNotContains(FakeTest::class, $reportNames, 'ReportTest_FakeTest is NOT in reports list'); - $this->assertNotContains(FakeTest2::class, $reportNames, 'ReportTest_FakeTest2 is NOT in reports list'); + $this->assertNotContains(FakeReport::class, $reportNames, 'ReportTest_FakeReport is NOT in reports list'); + $this->assertNotContains(FakeReport2::class, $reportNames, 'ReportTest_FakeReport2 is NOT in reports list'); } public function testAbstractClassesAreExcluded() @@ -69,15 +69,15 @@ class ReportTest extends SapphireTest $reportNames[] = get_class($report); } $this->assertNotContains( - 'ReportTest_FakeTest_Abstract', + 'ReportTest_FakeReport_Abstract', $reportNames, - 'ReportTest_FakeTest_Abstract is NOT in reports list as it is abstract' + 'ReportTest_FakeReport_Abstract is NOT in reports list as it is abstract' ); } public function testPermissions() { - $report = new ReportTest\FakeTest2(); + $report = new ReportTest\FakeReport2(); // Visitor cannot view $this->logOut(); @@ -98,7 +98,7 @@ class ReportTest extends SapphireTest public function testColumnLink() { - $report = new ReportTest\FakeTest(); + $report = new ReportTest\FakeReport(); /** @var GridField $gridField */ $gridField = $report->getReportField(); /** @var GridFieldDataColumns $columns */ @@ -117,17 +117,17 @@ class ReportTest extends SapphireTest public function testCountForOverview() { - $report = new ReportTest\FakeTest3(); + $report = new ReportTest\FakeReport3(); // Count is limited to 10000 by default $this->assertEquals('10000+', $report->getCountForOverview()); // Count is limited as per configuration - Config::modify()->set(ReportTest\FakeTest3::class, 'limit_count_in_overview', 15); + Config::modify()->set(ReportTest\FakeReport3::class, 'limit_count_in_overview', 15); $this->assertEquals('15+', $report->getCountForOverview()); // A null limit displays the full count - Config::modify()->set(ReportTest\FakeTest3::class, 'limit_count_in_overview', null); + Config::modify()->set(ReportTest\FakeReport3::class, 'limit_count_in_overview', null); $this->assertEquals('15000', $report->getCountForOverview()); } } diff --git a/tests/ReportTest/FakeTest.php b/tests/ReportTest/FakeReport.php similarity index 91% rename from tests/ReportTest/FakeTest.php rename to tests/ReportTest/FakeReport.php index 7194ba55..76774c01 100644 --- a/tests/ReportTest/FakeTest.php +++ b/tests/ReportTest/FakeReport.php @@ -6,7 +6,7 @@ use SilverStripe\Dev\TestOnly; use SilverStripe\ORM\ArrayList; use SilverStripe\Reports\Report; -class FakeTest extends Report implements TestOnly +class FakeReport extends Report implements TestOnly { public function title() { diff --git a/tests/ReportTest/FakeTest2.php b/tests/ReportTest/FakeReport2.php similarity index 91% rename from tests/ReportTest/FakeTest2.php rename to tests/ReportTest/FakeReport2.php index 736de851..145e1579 100644 --- a/tests/ReportTest/FakeTest2.php +++ b/tests/ReportTest/FakeReport2.php @@ -6,7 +6,7 @@ use SilverStripe\Dev\TestOnly; use SilverStripe\ORM\ArrayList; use SilverStripe\Reports\Report; -class FakeTest2 extends Report implements TestOnly +class FakeReport2 extends Report implements TestOnly { public function title() { diff --git a/tests/ReportTest/FakeTest3.php b/tests/ReportTest/FakeReport3.php similarity index 83% rename from tests/ReportTest/FakeTest3.php rename to tests/ReportTest/FakeReport3.php index b327303c..d84218c3 100644 --- a/tests/ReportTest/FakeTest3.php +++ b/tests/ReportTest/FakeReport3.php @@ -6,7 +6,7 @@ use SilverStripe\Dev\TestOnly; use SilverStripe\ORM\ArrayList; use SilverStripe\Reports\Report; -class FakeTest3 extends Report implements TestOnly +class FakeReport3 extends Report implements TestOnly { public function sourceRecords($params, $sort, $limit) { diff --git a/tests/ReportTest/FakeTestAbstract.php b/tests/ReportTest/FakeTestAbstract.php index 08aadb6d..00a3f4a7 100644 --- a/tests/ReportTest/FakeTestAbstract.php +++ b/tests/ReportTest/FakeTestAbstract.php @@ -6,7 +6,7 @@ use SilverStripe\Dev\TestOnly; use SilverStripe\ORM\ArrayList; use SilverStripe\Reports\Report; -abstract class FakeTestAbstract extends Report implements TestOnly +abstract class FakeReportAbstract extends Report implements TestOnly { public function title() {