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\Dev\SapphireTest; |
9
|
|
|
use SilverStripe\Forms\LiteralField; |
10
|
|
|
|
11
|
|
|
class SiteSummaryTest extends SapphireTest |
12
|
|
|
{ |
13
|
|
|
protected static $fixture_file = 'Package.yml'; |
14
|
|
|
|
15
|
|
|
protected static $required_extensions = [ |
16
|
|
|
SiteSummary::class => [ |
17
|
|
|
SiteSummaryExtensionStub::class, |
18
|
|
|
], |
19
|
|
|
]; |
20
|
|
|
|
21
|
|
|
public function testSourceRecords() |
22
|
|
|
{ |
23
|
|
|
$summaryReport = new SiteSummary; |
24
|
|
|
$records = $summaryReport->sourceRecords(); |
25
|
|
|
$firstRecord = $records->first(); |
26
|
|
|
$this->assertInstanceOf(Package::class, $firstRecord); |
27
|
|
|
$this->assertStringStartsWith('pretend/', $firstRecord->Name); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testOnlySilverStripeModulesAreShown() |
31
|
|
|
{ |
32
|
|
|
$summaryReport = new SiteSummary; |
33
|
|
|
$records = $summaryReport->sourceRecords(); |
34
|
|
|
$this->assertCount(3, $records); |
35
|
|
|
foreach ($records as $record) { |
36
|
|
|
$this->assertEquals('silverstripe-module', $record->Type); |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testAlertsRenderAtopTheReportField() |
41
|
|
|
{ |
42
|
|
|
$summaryReport = new SiteSummary; |
43
|
|
|
$fields = $summaryReport->getCMSFields(); |
44
|
|
|
$alertSummary = $fields->fieldByName('AlertSummary'); |
45
|
|
|
$this->assertInstanceOf(LiteralField::class, $alertSummary); |
46
|
|
|
$this->assertContains('Sound the alarm!', $alertSummary->getContent()); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|