Completed
Branch feature/scrutinizer (5874ea)
by X
03:07
created

StringParserTest::provideInvalidData()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 22

Duplication

Lines 35
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 0
dl 35
loc 35
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace xKerman\Restricted\Test;
4
5
use PHPUnit\Framework\TestCase;
6
7
use xKerman\Restricted\Source;
8
use xKerman\Restricted\StringParser;
9
10
/**
11
 * @coversDefaultClass \xKerman\Restricted\StringParser
12
 */
13 View Code Duplication
class StringParserTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
14
{
15
    public function provideInvalidData()
16
    {
17
        return [
18
            'empty string' => [
19
                'input' => '',
20
            ],
21
            'non string tag' => [
22
                'input' => 'a:0:"";',
23
            ],
24
            'length is missing' => [
25
                'input' => 's::"";',
26
            ],
27
            'length is not number' => [
28
                'input' => 's:a:"";',
29
            ],
30
            'length is not integer' => [
31
                'input' => 's:1.0:"a";',
32
            ],
33
            'length is negative' => [
34
                'input' => 's:-1:"";',
35
            ],
36
            'no quote' => [
37
                'input' => 's:1:a;',
38
            ],
39
            'open quote exist but close quote not exist' => [
40
                'input' => 's:1:"a;',
41
            ],
42
            'close quote exist but open quote not exist' => [
43
                'input' => 's:1:a";',
44
            ],
45
            'enclosed by single quote' => [
46
                'input' => "s:1:'a';",
47
            ],
48
        ];
49
    }
50
51
    /**
52
     * @covers ::parse
53
     * @dataProvider provideInvalidData
54
     * @expectedException \xKerman\Restricted\UnserializeFailedException
55
     */
56
    public function testParseFailure($input)
57
    {
58
        $source = new Source($input);
59
        $parser = new StringParser();
60
        $parser->parse($source);
61
    }
62
}
63