Passed
Pull Request — master (#39)
by Robbie
01:44
created

PackageSecurityExtensionTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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 BringYourOwnIdeas\SecurityChecker\Extensions\PackageSecurityExtension;
7
use SilverStripe\Dev\SapphireTest;
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
            $this->markTestSkipped('This test class requires the maintenance module to be installed');
18
        }
19
        parent::setUp();
20
    }
21
22
    public function testAlertsAreIncludedInDataSchema()
23
    {
24
        /** @var Package $package */
25
        $package = $this->objFromFixture(Package::class, 'package_a');
26
27
        $dataSchema = $package->getDataSchema();
28
        $this->assertArrayHasKey('securityAlerts', $dataSchema);
29
        $this->assertNotEmpty($dataSchema['securityAlerts']);
30
31
        $firstAlert = $dataSchema['securityAlerts'][0];
32
        $this->assertEquals('SS-123-456', $firstAlert['Identifier']);
33
        $this->assertEquals('silverstripe.org', $firstAlert['ExternalLink']);
34
    }
35
}
36