mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge pull request #194 from creative-commoners/pulls/6/phpunit11
DEP Use PHPUnit 11
This commit is contained in:
commit
fd5f04395c
@ -29,7 +29,7 @@
|
|||||||
"silverstripe/vendor-plugin": "^2"
|
"silverstripe/vendor-plugin": "^2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9.6",
|
"phpunit/phpunit": "^11.3",
|
||||||
"squizlabs/php_codesniffer": "^3.7",
|
"squizlabs/php_codesniffer": "^3.7",
|
||||||
"silverstripe/standards": "^1",
|
"silverstripe/standards": "^1",
|
||||||
"phpstan/extension-installer": "^1.3"
|
"phpstan/extension-installer": "^1.3"
|
||||||
|
@ -10,6 +10,7 @@ use SilverStripe\Reports\ReportAdmin;
|
|||||||
use SilverStripe\Reports\Tests\ReportAdminTest\CannotViewReport;
|
use SilverStripe\Reports\Tests\ReportAdminTest\CannotViewReport;
|
||||||
use SilverStripe\Reports\Tests\ReportAdminTest\FakeReport;
|
use SilverStripe\Reports\Tests\ReportAdminTest\FakeReport;
|
||||||
use SilverStripe\Reports\Tests\ReportAdminTest\FakeReport2;
|
use SilverStripe\Reports\Tests\ReportAdminTest\FakeReport2;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
|
||||||
class ReportAdminTest extends FunctionalTest
|
class ReportAdminTest extends FunctionalTest
|
||||||
{
|
{
|
||||||
@ -46,7 +47,7 @@ class ReportAdminTest extends FunctionalTest
|
|||||||
$this->assertSame('Fake report two', $map['Title']);
|
$this->assertSame('Fake report two', $map['Title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideShowReport(): array
|
public static function provideShowReport(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'cannot view' => [
|
'cannot view' => [
|
||||||
@ -60,9 +61,7 @@ class ReportAdminTest extends FunctionalTest
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('provideShowReport')]
|
||||||
* @dataProvider provideShowReport
|
|
||||||
*/
|
|
||||||
public function testShowReport(string $reportClass, int $expected): void
|
public function testShowReport(string $reportClass, int $expected): void
|
||||||
{
|
{
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
@ -6,8 +6,8 @@ use SilverStripe\Core\Config\Config;
|
|||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Forms\GridField\GridFieldDataColumns;
|
use SilverStripe\Forms\GridField\GridFieldDataColumns;
|
||||||
use SilverStripe\Reports\Tests\ReportTest\FakeObject;
|
use SilverStripe\Reports\Tests\ReportTest\FakeObject;
|
||||||
use SilverStripe\Reports\Tests\ReportTest\FakeTest;
|
use SilverStripe\Reports\Tests\ReportTest\FakeReport;
|
||||||
use SilverStripe\Reports\Tests\ReportTest\FakeTest2;
|
use SilverStripe\Reports\Tests\ReportTest\FakeReport2;
|
||||||
use SilverStripe\Reports\Report;
|
use SilverStripe\Reports\Report;
|
||||||
|
|
||||||
class ReportTest extends SapphireTest
|
class ReportTest extends SapphireTest
|
||||||
@ -34,22 +34,22 @@ class ReportTest extends SapphireTest
|
|||||||
foreach ($reports as $report) {
|
foreach ($reports as $report) {
|
||||||
$reportNames[] = get_class($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
|
// 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();
|
$reports = Report::get_reports();
|
||||||
$reportNames = array();
|
$reportNames = array();
|
||||||
foreach ($reports as $report) {
|
foreach ($reports as $report) {
|
||||||
$reportNames[] = get_class($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
|
// Exclude two reports
|
||||||
Config::modify()->merge(Report::class, 'excluded_reports', [
|
Config::modify()->merge(Report::class, 'excluded_reports', [
|
||||||
FakeTest::class,
|
FakeReport::class,
|
||||||
FakeTest2::class
|
FakeReport2::class
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$reports = Report::get_reports();
|
$reports = Report::get_reports();
|
||||||
@ -57,8 +57,8 @@ class ReportTest extends SapphireTest
|
|||||||
foreach ($reports as $report) {
|
foreach ($reports as $report) {
|
||||||
$reportNames[] = get_class($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');
|
||||||
$this->assertNotContains(FakeTest2::class, $reportNames, 'ReportTest_FakeTest2 is NOT in reports list');
|
$this->assertNotContains(FakeReport2::class, $reportNames, 'ReportTest_FakeReport2 is NOT in reports list');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAbstractClassesAreExcluded()
|
public function testAbstractClassesAreExcluded()
|
||||||
@ -69,15 +69,15 @@ class ReportTest extends SapphireTest
|
|||||||
$reportNames[] = get_class($report);
|
$reportNames[] = get_class($report);
|
||||||
}
|
}
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
'ReportTest_FakeTest_Abstract',
|
'ReportTest_FakeReport_Abstract',
|
||||||
$reportNames,
|
$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()
|
public function testPermissions()
|
||||||
{
|
{
|
||||||
$report = new ReportTest\FakeTest2();
|
$report = new ReportTest\FakeReport2();
|
||||||
|
|
||||||
// Visitor cannot view
|
// Visitor cannot view
|
||||||
$this->logOut();
|
$this->logOut();
|
||||||
@ -98,7 +98,7 @@ class ReportTest extends SapphireTest
|
|||||||
|
|
||||||
public function testColumnLink()
|
public function testColumnLink()
|
||||||
{
|
{
|
||||||
$report = new ReportTest\FakeTest();
|
$report = new ReportTest\FakeReport();
|
||||||
/** @var GridField $gridField */
|
/** @var GridField $gridField */
|
||||||
$gridField = $report->getReportField();
|
$gridField = $report->getReportField();
|
||||||
/** @var GridFieldDataColumns $columns */
|
/** @var GridFieldDataColumns $columns */
|
||||||
@ -117,17 +117,17 @@ class ReportTest extends SapphireTest
|
|||||||
|
|
||||||
public function testCountForOverview()
|
public function testCountForOverview()
|
||||||
{
|
{
|
||||||
$report = new ReportTest\FakeTest3();
|
$report = new ReportTest\FakeReport3();
|
||||||
|
|
||||||
// Count is limited to 10000 by default
|
// Count is limited to 10000 by default
|
||||||
$this->assertEquals('10000+', $report->getCountForOverview());
|
$this->assertEquals('10000+', $report->getCountForOverview());
|
||||||
|
|
||||||
// Count is limited as per configuration
|
// 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());
|
$this->assertEquals('15+', $report->getCountForOverview());
|
||||||
|
|
||||||
// A null limit displays the full count
|
// 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());
|
$this->assertEquals('15000', $report->getCountForOverview());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ use SilverStripe\Dev\TestOnly;
|
|||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\Reports\Report;
|
use SilverStripe\Reports\Report;
|
||||||
|
|
||||||
class FakeTest extends Report implements TestOnly
|
class FakeReport extends Report implements TestOnly
|
||||||
{
|
{
|
||||||
public function title()
|
public function title()
|
||||||
{
|
{
|
@ -6,7 +6,7 @@ use SilverStripe\Dev\TestOnly;
|
|||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\Reports\Report;
|
use SilverStripe\Reports\Report;
|
||||||
|
|
||||||
class FakeTest2 extends Report implements TestOnly
|
class FakeReport2 extends Report implements TestOnly
|
||||||
{
|
{
|
||||||
public function title()
|
public function title()
|
||||||
{
|
{
|
@ -6,7 +6,7 @@ use SilverStripe\Dev\TestOnly;
|
|||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\Reports\Report;
|
use SilverStripe\Reports\Report;
|
||||||
|
|
||||||
class FakeTest3 extends Report implements TestOnly
|
class FakeReport3 extends Report implements TestOnly
|
||||||
{
|
{
|
||||||
public function sourceRecords($params, $sort, $limit)
|
public function sourceRecords($params, $sort, $limit)
|
||||||
{
|
{
|
@ -6,7 +6,7 @@ use SilverStripe\Dev\TestOnly;
|
|||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\Reports\Report;
|
use SilverStripe\Reports\Report;
|
||||||
|
|
||||||
abstract class FakeTestAbstract extends Report implements TestOnly
|
abstract class FakeReportAbstract extends Report implements TestOnly
|
||||||
{
|
{
|
||||||
public function title()
|
public function title()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user