Test Setup Failed
Branch master (d251e3)
by Koen
02:30
created

LuaInputStreamTest::testMultipleLineError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
rs 9.4286
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/**
3
 * LuaInputStreamTest.php
4
 *
5
 * @author Koen Vlaswinkel <[email protected]>
6
 * @since  21/12/2015 16:57
7
 */
8
9
namespace Vlaswinkel\Lua\Tests;
10
11
use Vlaswinkel\Lua\LuaInputStream;
12
13
class LuaInputStreamTest extends \PHPUnit_Framework_TestCase {
14
    public function testSimpleNext() {
15
        $obj = new LuaInputStream("a");
16
        $this->assertEquals("a", $obj->next());
17
    }
18
19 View Code Duplication
    public function testMultipleLines() {
1 ignored issue
show
Duplication introduced by
This method 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...
20
        $obj = new LuaInputStream("a\nb\n");
21
22
        $this->assertEquals("a", $obj->next());
23
        $this->assertEquals("\n", $obj->next());
24
        $this->assertEquals("b", $obj->next());
25
        $this->assertEquals("\n", $obj->next());
26
        $this->assertTrue($obj->eof());
27
    }
28
29
    /**
30
     * @expectedException \Vlaswinkel\Lua\LuaParseException
31
     * @expectedExceptionMessage Simple error (1:1)
32
     */
33
    public function testSimpleError() {
34
        $obj = new LuaInputStream("a");
35
        $this->assertEquals("a", $obj->next());
36
37
        $obj->error("Simple error");
38
    }
39
40
    /**
41
     * @expectedException \Vlaswinkel\Lua\LuaParseException
42
     * @expectedExceptionMessage Other error (2:1)
43
     */
44 View Code Duplication
    public function testMultipleLineError() {
1 ignored issue
show
Duplication introduced by
This method 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...
45
        $obj = new LuaInputStream("a\nb");
46
        $this->assertEquals("a", $obj->next());
47
        $this->assertEquals("\n", $obj->next());
48
        $this->assertEquals("b", $obj->next());
49
50
        $obj->error("Other error");
51
    }
52
53
    /**
54
     * @expectedException \Vlaswinkel\Lua\LuaParseException
55
     * @expectedExceptionMessage This error (1:2)
56
     */
57 View Code Duplication
    public function testMultipleColumnError() {
1 ignored issue
show
Duplication introduced by
This method 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...
58
        $obj = new LuaInputStream("ab");
59
        $this->assertEquals("a", $obj->next());
60
        $this->assertEquals("b", $obj->next());
61
62
        $obj->error("This error");
63
    }
64
65
    /**
66
     * @expectedException \Vlaswinkel\Lua\LuaParseException
67
     * @expectedExceptionMessage Complex error (2:2)
68
     */
69 View Code Duplication
    public function testMultipleLineAndColumnError() {
1 ignored issue
show
Duplication introduced by
This method 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...
70
        $obj = new LuaInputStream("ab\nab\n");
71
        $this->assertEquals("a", $obj->next());
72
        $this->assertEquals("b", $obj->next());
73
        $this->assertEquals("\n", $obj->next());
74
75
        $this->assertEquals("a", $obj->next());
76
        $this->assertEquals("b", $obj->next());
77
78
        $obj->error("Complex error");
79
    }
80
}