Completed
Pull Request — master (#912)
by
unknown
07:49
created

StringTest::trimExplodeEmpty()   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 3
1
<?php
2
3
namespace N98\Util;
4
5
class StringTest extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     * @test
9
     * @param string $string
10
     * @param string $delimiter
11
     * @param array  $expected
12
     * @dataProvider trimExplodeEmptyProvider
13
     */
14
    public function trimExplodeEmpty($delimiter, $string, $expected)
15
    {
16
        $this->assertEquals($expected, BinaryString::trimExplodeEmpty($delimiter, $string), '', 0.0, 10, true);
17
    }
18
19
    /**
20
     * @return array
21
     */
22
    public static function trimExplodeEmptyProvider()
23
    {
24
        return array(
25
            array(
26
                ',',
27
                'Foo,Bar',
28
                array('Foo', 'Bar'),
29
            ),
30
            array(
31
                '#',
32
                ' Foo# Bar',
33
                array('Foo', 'Bar'),
34
            ),
35
            array(
36
                ',',
37
                ',,Foo, Bar,,',
38
                array('Foo', 'Bar'),
39
            ),
40
        );
41
    }
42
43
    /**
44
     * @test
45
     */
46
    public function startsWith()
47
    {
48
        $this->assertTrue(BinaryString::startsWith('Foo', 'Foo'));
49
        $this->assertTrue(BinaryString::startsWith('Foo123', 'Foo'));
50
        $this->assertFalse(BinaryString::startsWith(' Foo123', 'Foo'));
51
    }
52
53
    /**
54
     * @test
55
     */
56
    public function endsWith()
57
    {
58
        $this->assertTrue(BinaryString::endsWith('Foo', 'Foo'));
59
        $this->assertTrue(BinaryString::endsWith('Foo123', '123'));
60
        $this->assertFalse(BinaryString::endsWith(' Foo123 ', '123'));
61
    }
62
}
63