1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BringYourOwnIdeas\Maintenance\Tests\Reports; |
4
|
|
|
|
5
|
|
|
use BringYourOwnIdeas\Maintenance\Model\Package; |
6
|
|
|
use BringYourOwnIdeas\Maintenance\Reports\SiteSummary; |
7
|
|
|
use BringYourOwnIdeas\Maintenance\Tests\Reports\Stubs\SiteSummaryExtensionStub; |
8
|
|
|
use SilverStripe\Core\Config\Config; |
9
|
|
|
use SilverStripe\Dev\SapphireTest; |
10
|
|
|
use SilverStripe\Forms\LiteralField; |
11
|
|
|
use Symbiote\QueuedJobs\Services\QueuedJobService; |
12
|
|
|
|
13
|
|
|
class SiteSummaryTest extends SapphireTest |
14
|
|
|
{ |
15
|
|
|
protected static $fixture_file = 'Package.yml'; |
16
|
|
|
|
17
|
|
|
protected static $required_extensions = [ |
18
|
|
|
SiteSummary::class => [ |
19
|
|
|
SiteSummaryExtensionStub::class, |
20
|
|
|
], |
21
|
|
|
]; |
22
|
|
|
|
23
|
|
|
protected function setUp(): void |
24
|
|
|
{ |
25
|
|
|
parent::setUp(); |
26
|
|
|
|
27
|
|
|
Config::modify()->set(QueuedJobService::class, 'use_shutdown_function', false); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testSourceRecords() |
31
|
|
|
{ |
32
|
|
|
$summaryReport = new SiteSummary; |
33
|
|
|
$records = $summaryReport->sourceRecords(); |
34
|
|
|
$firstRecord = $records->first(); |
35
|
|
|
$this->assertInstanceOf(Package::class, $firstRecord); |
36
|
|
|
$this->assertStringStartsWith('pretend/', $firstRecord->Name); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testOnlySilverStripeModulesAreShown() |
40
|
|
|
{ |
41
|
|
|
$summaryReport = new SiteSummary; |
42
|
|
|
$records = $summaryReport->sourceRecords(); |
43
|
|
|
$this->assertCount(3, $records); |
44
|
|
|
foreach ($records as $record) { |
45
|
|
|
$this->assertEquals('silverstripe-module', $record->Type); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testAlertsRenderAtopTheReportField() |
50
|
|
|
{ |
51
|
|
|
$summaryReport = new SiteSummary; |
52
|
|
|
$fields = $summaryReport->getCMSFields(); |
53
|
|
|
$alertSummary = $fields->fieldByName('AlertSummary'); |
|
|
|
|
54
|
|
|
$this->assertInstanceOf(LiteralField::class, $alertSummary); |
55
|
|
|
$this->assertStringContainsString('Sound the alarm!', $alertSummary->getContent()); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.