ILIAS  release_7 Revision v7.30-3-g800a261c036
LSTOCBuilderTest.php
Go to the documentation of this file.
1<?php
2
3use PHPUnit\Framework\TestCase;
5
6class LSTOCBuilderTest extends TestCase
7{
8 public function testConstruction()
9 {
10 $cb = $this->createMock(LSControlBuilder::class);
11 $tb = new LSTOCBuilder($cb, '');
12 $this->assertEquals(
13 json_encode(["label" => "","command" => "","parameter" => null,"state" => null,"childs" => []]),
14 $tb->toJSON()
15 );
16 }
17
18 public function testRecursion()
19 {
20 $cb = $this->createMock(LSControlBuilder::class);
21 $tb = new LSTOCBuilder($cb, '');
22 $tb
23 ->node('node1')
24 ->item('item1.1', 1)
25 ->item('item1.2', 2)
26 ->end()
27 ->item('item2', 3)
28 ->node('node3')
29 ->item('item3.1', 4)
30 ->node('node3.2', 5)
31 ->item('item3.2.1', 6)
32 ->end()
33 ->end()
34 ->end();
35
36 $expected = [
37 "label" => "","command" => "","parameter" => null,"state" => null,"childs" => [
38 ["label" => "node1","command" => "","parameter" => null,"state" => null,"childs" => [
39 ["label" => "item1.1","command" => "","parameter" => 1,"state" => null,"current" => false],
40 ["label" => "item1.2","command" => "","parameter" => 2,"state" => null,"current" => false]
41 ]],
42 ["label" => "item2","command" => "","parameter" => 3,"state" => null, "current" => false],
43 ["label" => "node3","command" => "","parameter" => null,"state" => null,"childs" => [
44 ["label" => "item3.1","command" => "","parameter" => 4,"state" => null,"current" => false],
45 ["label" => "node3.2","command" => "","parameter" => 5,"state" => null,"childs" => [
46 ["label" => "item3.2.1","command" => "","parameter" => 6,"state" => null,"current" => false]
47 ]
48 ]]]]];
49
50 $this->assertEquals(
51 json_encode($expected),
52 $tb->toJSON()
53 );
54 }
55
56 public function testToCEnd()
57 {
58 $cb = $this->createMock(LSControlBuilder::class);
59 $tb = new LSTOCBuilder($cb, '');
60 $tb = $tb->end();
61 $this->assertInstanceOf(ControlBuilder::class, $tb);
62 }
63}
An exception for terminatinating execution or to throw for unit testing.
Class LSTOCBuilder.
Build controls for the view.