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

ModxAbstract::mockMODX()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 60
Code Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 60
rs 9.5555
cc 1
eloc 53
nc 1
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
}