Completed
Pull Request — master (#75)
by
unknown
01:26
created

BooleansTest::filterInvalidString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace TraderInteractive\Filter;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * @coversDefaultClass \TraderInteractive\Filter\Booleans
9
 */
10
final class BooleansTest extends TestCase
11
{
12
    /**
13
     * @test
14
     * @covers ::filter
15
     */
16
    public function filterBasic()
17
    {
18
        $this->assertTrue(Booleans::filter(true));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filter\Booleans::filter(true) targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertTrue() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
19
        $this->assertTrue(Booleans::filter('   true'));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filte...eans::filter(' true') targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertTrue() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
20
        $this->assertTrue(Booleans::filter(' TRUE '));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filte...leans::filter(' TRUE ') targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertTrue() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
21
        $this->assertTrue(Booleans::filter('True '));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filte...oleans::filter('True ') targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertTrue() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
22
23
        $this->assertFalse(Booleans::filter('false   '));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filte...ans::filter('false ') targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertFalse() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
24
        $this->assertFalse(Booleans::filter('FALSE  '));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filte...eans::filter('FALSE ') targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertFalse() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
25
        $this->assertFalse(Booleans::filter(' False '));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filte...eans::filter(' False ') targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertFalse() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
26
        $this->assertFalse(Booleans::filter(false));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filter\Booleans::filter(false) targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertFalse() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
27
    }
28
29
    /**
30
     * @test
31
     * @covers ::filter
32
     */
33
    public function filterAllowNullIsTrueAndNullValue()
34
    {
35
        $this->assertNull(Booleans::filter(null, true));
36
    }
37
38
    /**
39
     * @test
40
     * @covers ::filter
41
     * @expectedException \TraderInteractive\Filter\Exception
42
     * @expectedExceptionMessage "1" $value is not a string
43
     */
44
    public function filterNonStringAndNonBoolValue()
45
    {
46
        Booleans::filter(1);
47
    }
48
49
    /**
50
     * @test
51
     * @covers ::filter
52
     * @expectedException \TraderInteractive\Filter\Exception
53
     * @expectedExceptionMessage invalid is not 'true' or 'false' disregarding case and whitespace
54
     */
55
    public function filterInvalidString()
56
    {
57
        Booleans::filter('invalid');
58
    }
59
60
    /**
61
     * @test
62
     * @covers ::filter
63
     */
64
    public function filterCustomTrueValues()
65
    {
66
        $this->assertTrue(Booleans::filter('Y', false, ['y']));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filte...'Y', false, array('y')) targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertTrue() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
67
    }
68
69
    /**
70
     * @test
71
     * @covers ::filter
72
     */
73
    public function filterCustomFalseValues()
74
    {
75
        $this->assertFalse(Booleans::filter('0', false, ['true'], ['0']));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filte...ay('true'), array('0')) targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertFalse() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
76
    }
77
78
    /**
79
     * @test
80
     * @covers ::filter
81
     * @expectedException \TraderInteractive\Filter\Exception
82
     * @expectedExceptionMessage true is not 'y' or '1' or 'n' or '0' disregarding case and whitespace
83
     */
84
    public function filterCustomBoolValuesInvalidString()
85
    {
86
        $this->assertFalse(Booleans::filter('true', false, ['y', '1'], ['n', '0']));
0 ignored issues
show
Bug introduced by
It seems like \TraderInteractive\Filte... '1'), array('n', '0')) targeting TraderInteractive\Filter\Booleans::filter() can also be of type null; however, PHPUnit\Framework\Assert::assertFalse() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
87
    }
88
89
    /**
90
     * Verify basic behavior of convert().
91
     *
92
     * @test
93
     * @covers ::convert
94
     *
95
     * @return void
96
     */
97
    public function convert()
98
    {
99
        $this->assertSame('yes', Booleans::convert(true, 'yes', 'no'));
100
        $this->assertSame('bar', Booleans::convert(false, 'foo', 'bar'));
101
    }
102
}
103