Completed
Push — 2.0-dev ( 69bb11...1c6990 )
by Takehiro
02:55
created

OptionParserTest::testReadme2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 23
rs 9.0856
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
namespace Kwkm\MkLiveStatusClient\Tests;
3
4
use Kwkm\MkLiveStatusClient\LqlBuilder;
5
use Kwkm\MkLiveStatusClient\Table;
6
7
require_once __DIR__ . '/../../bootstrap.php';
8
9
class OptionParserTest extends \PHPUnit_Framework_TestCase
10
{
11
12
    public function testReadme1()
13
    {
14
        $lql = <<<EOF
15
GET contacts
16
OutputFormat: json
17
ResponseHeader: fixed16
18
19
20
EOF;
21
22
        $mock = \TestMock::on(
23
            new LqlBuilder(Table::CONTACTS)
24
        );
25
26
        $this->assertEquals(
27
            $lql,
28
            $mock->build(),
0 ignored issues
show
Documentation Bug introduced by
The method build does not exist on object<TestMock>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
29
            'Retrieve all contacts.'
30
        );
31
    }
32
33
34
    public function testReadme2()
35
    {
36
        $lql = <<<EOF
37
GET contacts
38
Columns: name alias
39
ColumnHeaders: on
40
OutputFormat: json
41
ResponseHeader: fixed16
42
43
44
EOF;
45
46
        $mock = \TestMock::on(
47
            new LqlBuilder(Table::CONTACTS)
48
        );
49
        $mock->columns(array('name', 'alias'));
0 ignored issues
show
Documentation Bug introduced by
The method columns does not exist on object<TestMock>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
50
51
        $this->assertEquals(
52
            $lql,
53
            $mock->build(),
0 ignored issues
show
Documentation Bug introduced by
The method build does not exist on object<TestMock>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
54
            'Retrieves just the columns name and alias.'
55
        );
56
    }
57
58 View Code Duplication
    public function testReadme3()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        $lql = <<<EOF
61
GET services
62
Columns: host_name description state
63
ColumnHeaders: on
64
Filter: state = 2
65
OutputFormat: json
66
ResponseHeader: fixed16
67
68
69
EOF;
70
71
        $mock = \TestMock::on(
72
            new LqlBuilder(Table::SERVICES)
73
        );
74
        $mock->columns(array('host_name', 'description', 'state'))
0 ignored issues
show
Documentation Bug introduced by
The method columns does not exist on object<TestMock>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
75
            ->filterEqual('state', '2');
76
77
        $this->assertEquals(
78
            $lql,
79
            $mock->build(),
0 ignored issues
show
Documentation Bug introduced by
The method build does not exist on object<TestMock>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
80
            'Gets all services with the current state 2 (critical).'
81
        );
82
    }
83
84 View Code Duplication
    public function testReadme4()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
85
    {
86
        $lql = <<<EOF
87
GET services
88
Columns: host_name description state
89
ColumnHeaders: on
90
Filter: state = 2
91
Filter: in_notification_period = 1
92
OutputFormat: json
93
ResponseHeader: fixed16
94
95
96
EOF;
97
98
        $mock = \TestMock::on(
99
            new LqlBuilder(Table::SERVICES)
100
        );
101
        $mock->columns(array('host_name', 'description', 'state'))
0 ignored issues
show
Documentation Bug introduced by
The method columns does not exist on object<TestMock>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
102
            ->filterEqual('state', '2')
103
            ->filterEqual('in_notification_period', '1');
104
105
        $this->assertEquals(
106
            $lql,
107
            $mock->build(),
0 ignored issues
show
Documentation Bug introduced by
The method build does not exist on object<TestMock>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
108
            'Gets all critical services which are currently within their notification period.'
109
        );
110
    }
111
}
112