| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace BringYourOwnIdeas\SecurityChecker\Tests\Extensions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use BringYourOwnIdeas\Maintenance\Model\Package; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SilverStripe\Dev\SapphireTest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Symbiote\QueuedJobs\Services\QueuedJobService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | class PackageSecurityExtensionTest extends SapphireTest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     protected static $fixture_file = 'PackageSecurityExtensionTest.yml'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |         if (!class_exists(Package::class)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |             static::$fixture_file = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |             parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |             $this->markTestSkipped('This test class requires the maintenance module to be installed'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         QueuedJobService::config()->set('use_shutdown_function', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     public function testAlertsAreIncludedInDataSchema() | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         /** @var Package $package */ | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |         $package = $this->objFromFixture(Package::class, 'package_a'); | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |         $dataSchema = $package->getDataSchema(); | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         $this->assertArrayHasKey('securityAlerts', $dataSchema); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         $this->assertNotEmpty($dataSchema['securityAlerts']); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         $firstAlert = $dataSchema['securityAlerts'][0]; | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |         $this->assertEquals('SS-123-456', $firstAlert['Identifier']); | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         $this->assertEquals('silverstripe.org', $firstAlert['ExternalLink']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     public function testListSecurityAlertIdentifiers() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         /** @var Package $package */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $package = $this->objFromFixture(Package::class, 'otheralerts'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $identifiers = $package->listSecurityAlertIdentifiers(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $this->assertContains('ABC-001', $identifiers); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $this->assertContains('SPY-007', $identifiers); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     public function testGetBadgesHook() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         /** @var Package $package */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $package = $this->objFromFixture(Package::class, 'otheralerts'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $badges = $package->getBadges(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $this->assertCount(1, $badges); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->assertEquals('warning security-alerts__toggler', $badges->first()->Type); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 58 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |  | 
            
                        
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