Completed
Pull Request — master (#202)
by Sam
01:51
created

StitchDataSenderTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testAddonToJson() 0 24 1
1
<?php
2
3
4
use SilverStripe\Elastica\Searchable;
5
6
/**
7
 * Tests for StitchDataSender
8
 */
9
class StitchDataSenderTest extends SapphireTest
10
{
11
12
    protected static $fixture_file = 'mysite/tests/services/testAddon.yml';
13
14
    protected $illegalExtensions = [
15
        'Addon' => [
16
            Searchable::class,
17
        ]
18
    ];
19
20
    public function testAddonToJson()
21
    {
22
        $s = new StitchDataSender();
23
        $result = ($s->addonToJson($this->objFromFixture('Addon', 'addon_a')));
0 ignored issues
show
Documentation introduced by
$this->objFromFixture('Addon', 'addon_a') is of type object<DataObject>|null, but the function expects a object<Addon>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
24
25
26
        $this->assertEquals('sminnee/test-package', $result['Name']);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<StitchDataSenderTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        $this->assertInstanceof('Datetime', $result['Released']);
0 ignored issues
show
Bug introduced by
The method assertInstanceof() does not seem to exist on object<StitchDataSenderTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
        $this->assertEquals([ 'Name' => 'good_code_coverage', 'Value' => 0 ], $result['RatingDetails'][0]);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<StitchDataSenderTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
        $this->assertEquals(2, sizeof($result['Versions']));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<StitchDataSenderTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
        $this->assertEquals('1.4.2.0', $result['Versions'][0]['Version']);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<StitchDataSenderTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<StitchDataSenderTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
            [[ 'Version' => '3.6', 'Major' => 3, 'Minor' => 6 ]],
33
            $result['Versions'][0]['CompatibleVersions']
34
        );
35
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<StitchDataSenderTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
            [[
37
                'Name' => 'Uncle Cheese',
38
                'Email' => '[email protected]',
39
                'Homepage' => 'http://leftandmain.com',
40
            ]],
41
            $result['Versions'][0]['Authors']
42
        );
43
    }
44
}
45