Test Failed
Branch master (9acec7)
by Agel_Nash
02:58
created

ModxAbstract   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A mockMODX() 0 60 1
A mockDBAPI() 0 19 1
A setUp() 0 5 1
1
<?php namespace DocLister\Tests;
2
3
abstract class ModxAbstract extends TestAbstract
4
{
5
    protected $modx = null;
6
7
    public function setUp()
8
    {
9
        $this->modx = $this->mockMODX();
10
        $this->assertTrue($this->modx instanceof \DocumentParser);
11
        $this->assertTrue($this->modx->db instanceof \DBAPI);
0 ignored issues
show
Bug introduced by
Accessing db on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
Bug introduced by
The type DBAPI 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...
12
    }
13
14
    protected function mockDBAPI()
15
    {
16
        $DBAPI = $this->getMockBuilder('DBAPI')
17
            ->setMethods(array('query', 'makeArray', 'escape', 'getValue'))
18
            ->getMock();
19
20
        $DBAPI->expects($this->any())
21
            ->method('makeArray')
22
            ->will($this->returnValue(array()));
23
24
        $DBAPI->expects($this->any())
25
            ->method('escape')
26
            ->will($this->returnArgument(0));
27
28
        $DBAPI->expects($this->any())
29
            ->method('getValue')
30
            ->will($this->returnValue('db_value'));
31
32
        return $DBAPI;
33
    }
34
35
    protected function mockMODX(array $config = array())
36
    {
37
        $modx = $this->getMockBuilder('DocumentParser')
38
            ->setMethods(array('getFullTableName'))
39
            ->getMock();
40
41
        $modx->expects($this->any())
42
            ->method('getFullTableName')
43
            ->will($this->returnArgument(0));
44
45
        $modx->db = $this->mockDBAPI();
0 ignored issues
show
Bug introduced by
Accessing db on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
46
47
        $modx->documentObject = array(
0 ignored issues
show
Bug introduced by
Accessing documentObject on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
48
            'id'              => 1,
49
            'type'            => 'document',
50
            'contentType'     => 'text/html',
51
            'pagetitle'       => 'New document',
52
            'longtitle'       => '',
53
            'description'     => '',
54
            'alias'           => '',
55
            'link_attributes' => '',
56
            'published'       => 1,
57
            'pub_date'        => 0,
58
            'unpub_date'      => 0,
59
            'parent'          => 0,
60
            'isfolder'        => 0,
61
            'introtext'       => '',
62
            'content'         => '',
63
            'richtext'        => 1,
64
            'template'        => 0,
65
            'menuindex'       => 0,
66
            'searchable'      => 1,
67
            'cacheable'       => 1,
68
            'createdon'       => 0,
69
            'createdby'       => 0,
70
            'editedon'        => 0,
71
            'editedby'        => 0,
72
            'deleted'         => 0,
73
            'deletedon'       => 0,
74
            'deletedby'       => 0,
75
            'publishedon'     => 0,
76
            'publishedby'     => 0,
77
            'menutitle'       => '',
78
            'donthit'         => 0,
79
            'haskeywords'     => 0,
80
            'hasmetatags'     => 0,
81
            'privateweb'      => 0,
82
            'privatemgr'      => 0,
83
            'content_dispo'   => 0,
84
            'hidemenu'        => 0,
85
            'alias_visible'   => 1
86
        );
87
        $modx->documentIdentifier = 1;
0 ignored issues
show
Bug introduced by
Accessing documentIdentifier on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
88
        $modx->config = array_merge(array(
0 ignored issues
show
Bug introduced by
Accessing config on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
89
            'manager_language' => 'russian-UTF8',
90
            'site_start'       => 1,
91
            'site_url'         => 'http://example.com/',
92
        ), $config);
93
94
        return $modx;
95
96
    }
97
}