ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLSPostConditionDBTest Class Reference
+ Inheritance diagram for ilLSPostConditionDBTest:
+ Collaboration diagram for ilLSPostConditionDBTest:

Public Member Functions

 testCreateObject ()
 
 testSelectWithEmptyArray ()
 
 testSelectWithNoDBResults ()
 
 testSelectWithDBResults ()
 
 testDelete ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $db
 

Detailed Description

Definition at line 23 of file ilLSPostConditionDBTest.php.

Member Function Documentation

◆ setUp()

ilLSPostConditionDBTest::setUp ( )
protected

Definition at line 30 of file ilLSPostConditionDBTest.php.

30 : void
31 {
32 $this->db = $this->createMock(ilDBInterface::class);
33 }

◆ testCreateObject()

ilLSPostConditionDBTest::testCreateObject ( )

Definition at line 35 of file ilLSPostConditionDBTest.php.

35 : void
36 {
37 $obj = new ilLSPostConditionDB($this->db);
38
39 $this->assertInstanceOf(ilLSPostConditionDB::class, $obj);
40 }
Storage for ilLSPostConditions.

◆ testDelete()

ilLSPostConditionDBTest::testDelete ( )

Definition at line 134 of file ilLSPostConditionDBTest.php.

134 : void
135 {
136 $sql =
137 "DELETE FROM post_conditions" . PHP_EOL
138 . "WHERE ref_id IN (20,22)" . PHP_EOL
139 ;
140
141 $this->db
142 ->expects($this->once())
143 ->method('manipulate')
144 ->with($sql)
145 ;
146
147 $obj = new ilLSPostConditionDB($this->db);
148 $obj->delete([20,22]);
149 }

◆ testSelectWithDBResults()

ilLSPostConditionDBTest::testSelectWithDBResults ( )

Definition at line 86 of file ilLSPostConditionDBTest.php.

86 : void
87 {
88 $sql =
89 "SELECT ref_id, condition_operator, value" . PHP_EOL
90 . "FROM post_conditions" . PHP_EOL
91 . "WHERE ref_id IN (33,44)" . PHP_EOL
92 ;
93
94 $rows = [
95 [
96 'ref_id' => 33,
97 'condition_operator' => 'failed',
98 'value' => "11"
99 ],
100 [
101 'ref_id' => 44,
102 'condition_operator' => 'finished',
103 'value' => "12"
104 ],
105 null
106 ];
107
108 $return_statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
109 $this->db
110 ->expects($this->once())
111 ->method('query')
112 ->with($sql)
113 ->willReturn($return_statement)
114 ;
115 $this->db
116 ->expects($this->any())
117 ->method('fetchAssoc')
118 ->with($return_statement)
119 ->willReturnOnConsecutiveCalls(...$rows)
120 ;
121
122 $obj = new ilLSPostConditionDB($this->db);
123 $result = $obj->select([33,44]);
124
125 $this->assertEquals(33, $result[0]->getRefId());
126 $this->assertEquals('failed', $result[0]->getConditionOperator());
127 $this->assertEquals("11", $result[0]->getValue());
128
129 $this->assertEquals(44, $result[1]->getRefId());
130 $this->assertEquals('finished', $result[1]->getConditionOperator());
131 $this->assertEquals("12", $result[1]->getValue());
132 }
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:49

References ILIAS\UI\Implementation\Component\Input\getValue().

+ Here is the call graph for this function:

◆ testSelectWithEmptyArray()

ilLSPostConditionDBTest::testSelectWithEmptyArray ( )

Definition at line 42 of file ilLSPostConditionDBTest.php.

42 : void
43 {
44 $obj = new ilLSPostConditionDB($this->db);
45
46 $result = $obj->select([]);
47
48 $this->assertIsArray($result);
49 $this->assertEmpty($result);
50 }

◆ testSelectWithNoDBResults()

ilLSPostConditionDBTest::testSelectWithNoDBResults ( )

Definition at line 52 of file ilLSPostConditionDBTest.php.

52 : void
53 {
54 $sql =
55 "SELECT ref_id, condition_operator, value" . PHP_EOL
56 . "FROM post_conditions" . PHP_EOL
57 . "WHERE ref_id IN (20,22)" . PHP_EOL
58 ;
59
60 $return = $this->getMockBuilder(ilDBStatement::class)->getMock();
61 $this->db
62 ->expects($this->once())
63 ->method('query')
64 ->with($sql)
65 ->willReturn($return)
66 ;
67 $this->db
68 ->expects($this->once())
69 ->method('fetchAssoc')
70 ->with($return)
71 ->willReturn([])
72 ;
73
74 $obj = new ilLSPostConditionDB($this->db);
75 $result = $obj->select([20,22]);
76
77 $this->assertEquals(20, $result[0]->getRefId());
78 $this->assertEquals(ilLSPostConditionDB::STD_ALWAYS_OPERATOR, $result[0]->getConditionOperator());
79 $this->assertNull($result[0]->getValue());
80
81 $this->assertEquals(22, $result[1]->getRefId());
82 $this->assertEquals(ilLSPostConditionDB::STD_ALWAYS_OPERATOR, $result[1]->getConditionOperator());
83 $this->assertNull($result[1]->getValue());
84 }

References ILIAS\UI\Implementation\Component\Input\getValue(), and ilLSPostConditionDB\STD_ALWAYS_OPERATOR.

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilLSPostConditionDBTest::$db
protected

Definition at line 28 of file ilLSPostConditionDBTest.php.


The documentation for this class was generated from the following file: