Completed
Push — master ( 745336...aadd5d )
by Matthew
06:17
created

UtilTest::testValidateIntNull()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 29
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 22
nc 8
nop 0
1
<?php
2
3
namespace Dtc\QueueBundle\Tests\Run;
4
5
use Dtc\QueueBundle\Util\Util;
6
use PHPUnit\Framework\TestCase;
7
8
class UtilTest extends TestCase
9
{
10
    /**
11
     * @param string $varName
0 ignored issues
show
Bug introduced by
There is no parameter named $varName. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
12
     * @param int    $pow
0 ignored issues
show
Bug introduced by
There is no parameter named $pow. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
13
     */
14
    public function testValidateIntNull()
15
    {
16
        self::assertNull(Util::validateIntNull('something', null, 2));
17
        self::assertEquals(1, Util::validateIntNull('asdf', 1, 2));
18
        try {
19
            Util::validateIntNull('something', 'asdf', 2);
20
        } catch (\Exception $exception) {
21
            self::assertTrue(true);
22
        }
23
24
        $failed = false;
25
        try {
26
            Util::validateIntNull('test', '5', 2);
27
            $failed = true;
28
        } catch (\Exception $exception) {
29
            self::assertTrue(true);
30
        }
31
        self::assertFalse($failed);
32
        self::assertEquals(5, Util::validateIntNull('test', '5', 3));
33
        self::assertEquals(PHP_INT_MAX, Util::validateIntNull('test', PHP_INT_MAX, 64));
34
35
        try {
36
            Util::validateIntNull('test', PHP_INT_MAX, 31);
37
            $failed = true;
38
        } catch (\Exception $exception) {
39
            self::assertTrue(true);
40
        }
41
        self::assertFalse($failed);
42
    }
43
}
44