Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 32... Línea 32...
32
 * @category  test
32
 * @category  test
33
 * @copyright 2009 Tim Hunt
33
 * @copyright 2009 Tim Hunt
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
35
 */
36
class xhtml_container_stack_test extends \advanced_testcase {
36
class xhtml_container_stack_test extends \advanced_testcase {
37
    public function test_push_then_pop() {
37
    public function test_push_then_pop(): void {
38
        // Set up.
38
        // Set up.
39
        $stack = new xhtml_container_stack();
39
        $stack = new xhtml_container_stack();
40
        // Exercise SUT.
40
        // Exercise SUT.
41
        $stack->push('testtype', '</div>');
41
        $stack->push('testtype', '</div>');
42
        $html = $stack->pop('testtype');
42
        $html = $stack->pop('testtype');
43
        // Verify outcome.
43
        // Verify outcome.
44
        $this->assertEquals('</div>', $html);
44
        $this->assertEquals('</div>', $html);
45
        $this->assertDebuggingNotCalled();
45
        $this->assertDebuggingNotCalled();
46
    }
46
    }
Línea 47... Línea 47...
47
 
47
 
48
    public function test_mismatched_pop_prints_warning() {
48
    public function test_mismatched_pop_prints_warning(): void {
49
        // Set up.
49
        // Set up.
50
        $stack = new xhtml_container_stack();
50
        $stack = new xhtml_container_stack();
51
        $stack->push('testtype', '</div>');
51
        $stack->push('testtype', '</div>');
52
        // Exercise SUT.
52
        // Exercise SUT.
53
        $html = $stack->pop('mismatch');
53
        $html = $stack->pop('mismatch');
54
        // Verify outcome.
54
        // Verify outcome.
55
        $this->assertEquals('</div>', $html);
55
        $this->assertEquals('</div>', $html);
56
        $this->assertDebuggingCalled();
56
        $this->assertDebuggingCalled();
Línea 57... Línea 57...
57
    }
57
    }
58
 
58
 
59
    public function test_pop_when_empty_prints_warning() {
59
    public function test_pop_when_empty_prints_warning(): void {
60
        // Set up.
60
        // Set up.
61
        $stack = new xhtml_container_stack();
61
        $stack = new xhtml_container_stack();
62
        // Exercise SUT.
62
        // Exercise SUT.
63
        $html = $stack->pop('testtype');
63
        $html = $stack->pop('testtype');
64
        // Verify outcome.
64
        // Verify outcome.
65
        $this->assertEquals('', $html);
65
        $this->assertEquals('', $html);
Línea 66... Línea 66...
66
        $this->assertDebuggingCalled();
66
        $this->assertDebuggingCalled();
67
    }
67
    }
68
 
68
 
69
    public function test_correct_nesting() {
69
    public function test_correct_nesting(): void {
70
        // Set up.
70
        // Set up.
71
        $stack = new xhtml_container_stack();
71
        $stack = new xhtml_container_stack();
Línea 78... Línea 78...
78
        $this->assertEquals('</p>', $html2);
78
        $this->assertEquals('</p>', $html2);
79
        $this->assertEquals('</div>', $html1);
79
        $this->assertEquals('</div>', $html1);
80
        $this->assertDebuggingNotCalled();
80
        $this->assertDebuggingNotCalled();
81
    }
81
    }
Línea 82... Línea 82...
82
 
82
 
83
    public function test_pop_all_but_last() {
83
    public function test_pop_all_but_last(): void {
84
        // Set up.
84
        // Set up.
85
        $stack = new xhtml_container_stack();
85
        $stack = new xhtml_container_stack();
86
        $stack->push('test1', '</h1>');
86
        $stack->push('test1', '</h1>');
87
        $stack->push('test2', '</h2>');
87
        $stack->push('test2', '</h2>');
Línea 93... Línea 93...
93
        $this->assertDebuggingNotCalled();
93
        $this->assertDebuggingNotCalled();
94
        // Tear down.
94
        // Tear down.
95
        $stack->discard();
95
        $stack->discard();
96
    }
96
    }
Línea 97... Línea 97...
97
 
97
 
98
    public function test_pop_all_but_last_only_one() {
98
    public function test_pop_all_but_last_only_one(): void {
99
        // Set up.
99
        // Set up.
100
        $stack = new xhtml_container_stack();
100
        $stack = new xhtml_container_stack();
101
        $stack->push('test1', '</h1>');
101
        $stack->push('test1', '</h1>');
102
        // Exercise SUT.
102
        // Exercise SUT.
Línea 106... Línea 106...
106
        $this->assertDebuggingNotCalled();
106
        $this->assertDebuggingNotCalled();
107
        // Tear down.
107
        // Tear down.
108
        $stack->discard();
108
        $stack->discard();
109
    }
109
    }
Línea 110... Línea 110...
110
 
110
 
111
    public function test_pop_all_but_last_empty() {
111
    public function test_pop_all_but_last_empty(): void {
112
        // Set up.
112
        // Set up.
113
        $stack = new xhtml_container_stack();
113
        $stack = new xhtml_container_stack();
114
        // Exercise SUT.
114
        // Exercise SUT.
115
        $html = $stack->pop_all_but_last();
115
        $html = $stack->pop_all_but_last();
116
        // Verify outcome.
116
        // Verify outcome.
117
        $this->assertEquals('', $html);
117
        $this->assertEquals('', $html);
118
        $this->assertDebuggingNotCalled();
118
        $this->assertDebuggingNotCalled();
Línea 119... Línea 119...
119
    }
119
    }
120
 
120
 
121
    public function test_discard() {
121
    public function test_discard(): void {
122
        // Set up.
122
        // Set up.
123
        $stack = new xhtml_container_stack();
123
        $stack = new xhtml_container_stack();
124
        $stack->push('test1', '</somethingdistinctive>');
124
        $stack->push('test1', '</somethingdistinctive>');