Passed
Push — master ( 676382...b6f9c0 )
by Robbie
02:21
created

PackageSecurityExtensionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 2
A testAlertsAreIncludedInDataSchema() 0 12 1
1
<?php
2
3
namespace BringYourOwnIdeas\SecurityChecker\Tests\Extensions;
4
5
use BringYourOwnIdeas\Maintenance\Model\Package;
0 ignored issues
show
Bug introduced by
The type BringYourOwnIdeas\Maintenance\Model\Package 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SilverStripe\Dev\SapphireTest;
7
8
class PackageSecurityExtensionTest extends SapphireTest
9
{
10
    protected static $fixture_file = 'PackageSecurityExtensionTest.yml';
11
12
    protected function setUp()
13
    {
14
        if (!class_exists(Package::class)) {
15
            static::$fixture_file = null;
16
            $this->markTestSkipped('This test class requires the maintenance module to be installed');
17
        }
18
        parent::setUp();
19
    }
20
21
    public function testAlertsAreIncludedInDataSchema()
22
    {
23
        /** @var Package $package */
24
        $package = $this->objFromFixture(Package::class, 'package_a');
25
26
        $dataSchema = $package->getDataSchema();
27
        $this->assertArrayHasKey('securityAlerts', $dataSchema);
28
        $this->assertNotEmpty($dataSchema['securityAlerts']);
29
30
        $firstAlert = $dataSchema['securityAlerts'][0];
31
        $this->assertEquals('SS-123-456', $firstAlert['Identifier']);
32
        $this->assertEquals('silverstripe.org', $firstAlert['ExternalLink']);
33
    }
34
}
35