bringyourownideas /
silverstripe-composer-security-checker
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace BringYourOwnIdeas\SecurityChecker\Tests\Extensions; |
||||||
| 4 | |||||||
| 5 | use BringYourOwnIdeas\Maintenance\Model\Package; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 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); |
||||||
|
0 ignored issues
–
show
The method
first() does not exist on Traversable. It seems like you code against a sub-type of Traversable such as IntlCodePointBreakIterator or IntlRuleBasedBreakIterator or SilverStripe\ORM\SS_List or SilverStripe\View\ViewableData or IntlBreakIterator or Ds\Map or Ds\Set or Ds\Sequence or SilverStripe\ORM\Connect\Query or Cassandra\Rows.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
The method
first() does not exist on Countable. It seems like you code against a sub-type of Countable such as SilverStripe\ORM\SS_List or Ds\Map or Ds\Set or Ds\Sequence.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 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