1 | <?php |
||
2 | |||
3 | namespace BringYourOwnIdeas\SecurityChecker\Tests\Extensions; |
||
4 | |||
5 | use BringYourOwnIdeas\Maintenance\Model\Package; |
||
0 ignored issues
–
show
|
|||
6 | use BringYourOwnIdeas\Maintenance\Reports\SiteSummary; |
||
0 ignored issues
–
show
The type
BringYourOwnIdeas\Maintenance\Reports\SiteSummary was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
7 | use BringYourOwnIdeas\SecurityChecker\Tests\Stubs\SiteSummaryAlertStub; |
||
8 | use SilverStripe\Core\Config\Config; |
||
9 | use SilverStripe\Core\Injector\Injector; |
||
10 | use SilverStripe\Dev\SapphireTest; |
||
11 | use SilverStripe\Forms\LiteralField; |
||
12 | use SilverStripe\View\SSViewer; |
||
13 | use Symbiote\QueuedJobs\Services\QueuedJobService; |
||
14 | |||
15 | class SiteSummaryExtensionTest extends SapphireTest |
||
16 | { |
||
17 | protected static $fixture_file = 'PackageSecurityExtensionTest.yml'; |
||
18 | |||
19 | protected static $required_extensions = [ |
||
20 | SiteSummary::class => [SiteSummaryAlertStub::class] |
||
21 | ]; |
||
22 | |||
23 | public static function setUpBeforeClass() |
||
24 | { |
||
25 | if (!class_exists(Package::class)) { |
||
26 | static::$required_extensions = []; |
||
27 | } |
||
28 | return parent::setUpBeforeClass(); |
||
0 ignored issues
–
show
Are you sure the usage of
parent::setUpBeforeClass() targeting SilverStripe\Dev\SapphireTest::setUpBeforeClass() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
29 | } |
||
30 | |||
31 | protected function setUp() |
||
32 | { |
||
33 | if (!class_exists(Package::class)) { |
||
34 | static::$fixture_file = null; |
||
35 | parent::setUp(); |
||
36 | $this->markTestSkipped( |
||
37 | 'Module bringyourownideas/silverstripe-maintenance is required for this test, but is not present.' |
||
38 | ); |
||
39 | } |
||
40 | |||
41 | QueuedJobService::config()->set('use_shutdown_function', false); |
||
42 | |||
43 | // The themes should not affect test results. |
||
44 | // Ensure we use the default templates supplied with this module. |
||
45 | Config::modify()->set(SSViewer::class, 'theme_enabled', false); |
||
46 | |||
47 | parent::setUp(); |
||
48 | } |
||
49 | |||
50 | public function testDisplayColumnsDoesNotIncludePrintingColumns() |
||
51 | { |
||
52 | $report = Injector::inst()->create(SiteSummary::class); |
||
53 | // screen output should not include this summary field added by the extension |
||
54 | $this->assertArrayNotHasKey('listSecurityAlertIdentifiers', $report->columns()); |
||
55 | // default summary fields are still used for print output (e.g. CSV export) |
||
56 | $this->assertArrayHasKey('listSecurityAlertIdentifiers', Package::create()->summaryFields()); |
||
57 | } |
||
58 | |||
59 | public function testUpdateAlerts() |
||
60 | { |
||
61 | /** @var SiteSummary $report */ |
||
62 | $report = Injector::inst()->create(SiteSummary::class); |
||
63 | $fields = $report->getCMSFields(); |
||
64 | |||
65 | /** @var LiteralField $alertSummary */ |
||
66 | $alertSummary = $fields->fieldByName('AlertSummary'); |
||
67 | $this->assertInstanceOf(LiteralField::class, $alertSummary); |
||
68 | |||
69 | $content = $alertSummary->getContent(); |
||
70 | $this->assertContains( |
||
71 | 'Sound the alarm!', |
||
72 | $content, |
||
73 | 'ensure our extension doesn\'t override all others' |
||
74 | ); |
||
75 | $this->assertContains( |
||
76 | 'site-summary__security-alerts', |
||
77 | $content, |
||
78 | 'ensure content from our extension is present' |
||
79 | ); |
||
80 | $this->assertContains( |
||
81 | '<strong>2</strong>', |
||
82 | $content, |
||
83 | 'ensure we are counting modules with alerts, not the total number of alerts' |
||
84 | ); |
||
85 | } |
||
86 | } |
||
87 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths