nodestack_plugin_prosemirror_test::test_addpop()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 10
c 1
b 0
f 1
1
<?php
2
3
use dokuwiki\plugin\prosemirror\schema\Node;
4
use dokuwiki\plugin\prosemirror\schema\NodeStack;
5
6
/**
7
 * NodeStack tests for the prosemirror plugin
8
 *
9
 * @group plugin_prosemirror
10
 * @group plugins
11
 */
12
class nodestack_plugin_prosemirror_test extends DokuWikiTest
13
{
14
15
16
    public function test_init()
17
    {
18
        $nodestack = new NodeStack();
19
        $this->assertSame('doc', $nodestack->current()->getType());
20
    }
21
22
    public function test_addpop()
23
    {
24
        $nodestack = new NodeStack();
25
        $node = new Node('foo');
26
27
        $nodestack->addTop($node);
28
        $this->assertSame($node, $nodestack->current());
29
30
        $popped = $nodestack->drop('foo');
31
        $this->assertSame($node, $popped);
32
    }
33
34
    public function test_dropfail()
35
    {
36
        $this->expectException('\\RuntimeException');
37
38
        $nodestack = new NodeStack();
39
        $node = new Node('foo');
40
        $nodestack->addTop($node);
41
42
        $nodestack->drop('baz');
43
    }
44
45
}
46