| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace BringYourOwnIdeas\SecurityChecker\Tests\Extensions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use BringYourOwnIdeas\Maintenance\Model\Package; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use BringYourOwnIdeas\Maintenance\Reports\SiteSummary; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |     protected function setUp() | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |         if (!class_exists(Package::class)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |             static::$fixture_file = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |             static::$required_extensions = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |             $this->markTestSkipped( | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |                 'Module bringyourownideas/silverstripe-maintenance is required for this test, but is not present.' | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         QueuedJobService::config()->set('use_shutdown_function', false); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         // The themes should not affect test results. | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |         // Ensure we use the default templates supplied with this module. | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         Config::modify()->set(SSViewer::class, 'theme_enabled', false); | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     public function testDisplayColumnsDoesNotIncludePrintingColumns() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $report = Injector::inst()->create(SiteSummary::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         // screen output should not include this summary field added by the extension | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $this->assertArrayNotHasKey('listSecurityAlertIdentifiers', $report->columns()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         // default summary fields are still used for print output (e.g. CSV export) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $this->assertArrayHasKey('listSecurityAlertIdentifiers', Package::create()->summaryFields()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     public function testUpdateAlerts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         /** @var SiteSummary $report */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $report = Injector::inst()->create(SiteSummary::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $fields = $report->getCMSFields(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         /** @var LiteralField $alertSummary */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $alertSummary = $fields->fieldByName('AlertSummary'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $this->assertInstanceOf(LiteralField::class, $alertSummary); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $content = $alertSummary->getContent(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->assertContains( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             'Sound the alarm!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             $content, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             'ensure our extension doesn\'t override all others' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->assertContains( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             'site-summary__security-alerts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             $content, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             'ensure content from our extension is present' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $this->assertContains( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             '<strong>2</strong>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             $content, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             'ensure we are counting modules with alerts, not the total number of alerts' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 79 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 80 |  |  |  | 
            
                        
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