93 : void
94 {
95 $start_date = new DateTime('2021-07-21 08:19');
96 $end_date = new DateTime('2021-07-21 08:20');
97
98 $sql =
99 'SELECT ref_id, online, effective_online, activation_start_ts, activation_end_ts' . PHP_EOL
100 . 'FROM lso_activation' . PHP_EOL
101 . 'WHERE ref_id = 33' . PHP_EOL
102 ;
103
104 $values = [
105 "ref_id" => 33,
106 "online" => true,
107 "effective_online" => true,
108 "activation_start_ts" => $start_date->getTimestamp(),
109 "activation_end_ts" => $end_date->getTimestamp()
110 ];
111
112 $this->db
113 ->expects($this->once())
114 ->method('quote')
115 ->with(33, 'integer')
116 ->willReturn('33')
117 ;
118 $return_statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
119 $this->db
120 ->expects($this->once())
121 ->method('query')
122 ->with($sql)
123 ->willReturn($return_statement)
124 ;
125 $this->db
126 ->expects($this->once())
127 ->method('numRows')
128 ->willReturn(1)
129 ;
130 $this->db
131 ->expects($this->once())
132 ->method('fetchAssoc')
133 ->with($return_statement)
134 ->willReturn($values)
135 ;
136
138 $settings = $obj->getActivationForRefId(33);
139
140 $this->assertInstanceOf(ilLearningSequenceActivation::class, $settings);
141 $this->assertEquals(33, $settings->getRefId());
142 $this->assertTrue($settings->getIsOnline());
143 $this->assertTrue($settings->getEffectiveOnlineStatus());
144 $this->assertEquals($start_date, $settings->getActivationStart());
145 $this->assertEquals($end_date, $settings->getActivationEnd());
146 }