Test::test_check_bash()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the `tvi/monitor-bundle` project.
5
 *
6
 * (c) https://github.com/turnaev/monitor-bundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
11
12
namespace Tvi\MonitorBundle\Check\php\Expression;
13
14
use ZendDiagnostics\Result\Failure;
15
use ZendDiagnostics\Result\ResultInterface;
16
use ZendDiagnostics\Result\Success;
17
use ZendDiagnostics\Result\Warning;
18
use Tvi\MonitorBundle\Test\Check\CheckTestCase;
19
20
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
 * @author Vladimir Turnaev <[email protected]>
22
 *
23
 * @internal
24
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
25
class Test extends CheckTestCase
26
{
27
    public function test_plugin()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function test_plugin()
Loading history...
Coding Style introduced by
Public method name "Test::test_plugin" is not in camel caps format
Loading history...
28
    {
29
        $this->iterateConfTest(__DIR__.'/config.example.yml');
30
    }
31
32
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $warningExpression should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $criticalExpression should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $warningMessage should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $criticalMessage should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $expectedResultClass should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $expectedMessage should have a doc-comment as per coding-style.
Loading history...
33
     * @dataProvider checkResultProvider
34
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
35
    public function test_check($warningExpression, $criticalExpression, $warningMessage, $criticalMessage, $expectedResultClass, $expectedMessage)
0 ignored issues
show
Coding Style introduced by
Public method name "Test::test_check" is not in camel caps format
Loading history...
36
    {
37
        $check = new Check($warningExpression, $criticalExpression, $warningMessage, $criticalMessage);
38
39
        $result = $check->check();
40
41
        $this->assertInstanceOf(ResultInterface::class, $result);
42
        $this->assertInstanceOf($expectedResultClass, $result);
43
        $this->assertSame($expectedMessage, $result->getMessage());
44
    }
45
46
    public function test_check_bash()
0 ignored issues
show
Coding Style introduced by
Public method name "Test::test_check_bash" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function test_check_bash()
Loading history...
47
    {
48
        $this->expectException(\InvalidArgumentException::class);
49
50
        new Check();
51
    }
52
53
    public function checkResultProvider()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function checkResultProvider()
Loading history...
54
    {
55
        return [
56
            ['true', 'true', null, null, Success::class, ''],
57
            ['false', 'true', 'warning', 'fail', Warning::class, 'warning'],
58
            ['true', 'false', 'warning', 'fail', Failure::class, 'fail'],
59
            ['false', 'false', 'warning', 'fail', Failure::class, 'fail'],
60
        ];
61
    }
62
}
63