ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilForumTopicTest Class Reference
+ Inheritance diagram for ilForumTopicTest:
+ Collaboration diagram for ilForumTopicTest:

Public Member Functions

 testConstruct ()
 
 testAssignData ()
 
 testInsert ()
 
 testInsertFalse ()
 
 testUpdate ()
 
 testUpdateFalse ()
 
 testReload ()
 
 testGetPostRootId ()
 
 testGetFirstVisiblePostId ()
 
 testGetPostRootIdFailed ()
 
 testGetFirstVisiblePostIdFailed ()
 
 testCountPosts ()
 
 testCountPostsFailed ()
 
 testCountActivePosts ()
 
 testCountActivePostsFailed ()
 
 testGetAllPostIds ()
 
 testIsNotificationEnabled ()
 
 testIsNotificationEnabledNoResult ()
 
 testIsNotificationEnabledInvalidIds ()
 
 testEnableNotification ()
 
 testDisableNotification ()
 
 testMakeSticky ()
 
 testMakeStickyFailed ()
 
 testUnmakeSticky ()
 
 testUnmakeStickyFalse ()
 
 testClose ()
 
 testReopen ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Private Member Functions

 withIgnoredQuery (InvocationMocker $mock, array ... $expected)
 

Private Attributes

MockObject &ilDBInterface $mockDatabase
 
MockObject &ilObjUser $mockUser
 
Container $dic = null
 

Detailed Description

Definition at line 26 of file ilForumTopicTest.php.

Member Function Documentation

◆ setUp()

ilForumTopicTest::setUp ( )
protected

Definition at line 541 of file ilForumTopicTest.php.

References $DIC, $mockDatabase, and $mockUser.

541  : void
542  {
543  global $DIC;
544 
545  $this->dic = is_object($DIC) ? clone $DIC : $DIC;
546 
547  $DIC = new Container();
548 
549  $this->mockDatabase = $this->getMockBuilder(ilDBInterface::class)->getMock();
550  $this->mockUser = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->getMock();
551 
552  $DIC['ilDB'] = $this->mockDatabase;
553  $DIC['ilUser'] = $this->mockUser;
554  }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
global $DIC
Definition: shib_login.php:26
MockObject &ilObjUser $mockUser
MockObject &ilDBInterface $mockDatabase

◆ tearDown()

ilForumTopicTest::tearDown ( )
protected

Definition at line 556 of file ilForumTopicTest.php.

References $DIC, and $dic.

556  : void
557  {
558  global $DIC;
559 
560  $DIC = $this->dic;
561 
562  parent::tearDown();
563  }
global $DIC
Definition: shib_login.php:26

◆ testAssignData()

ilForumTopicTest::testAssignData ( )

Definition at line 71 of file ilForumTopicTest.php.

References $data.

71  : void
72  {
73  $data = [
74  'thr_pk' => '',
75  'thr_top_fk' => '',
76  'thr_subject' => '',
77  'thr_display_user_id' => '',
78  'thr_usr_alias' => '',
79  'thr_last_post' => '',
80  'thr_date' => '',
81  'thr_update' => '',
82  'visits' => '',
83  'import_name' => '',
84  'is_sticky' => '',
85  'is_closed' => '',
86  'avg_rating' => '',
87  'thr_author_id' => '',
88 
89  'num_posts' => '',
90  'num_unread_posts' => '',
91  'usr_notification_is_enabled' => '',
92  ];
93 
94  $instance = new ilForumTopic();
95  $instance->assignData($data);
96 
97  $this->assertSame(0, $instance->getId());
98  $this->assertSame(0, $instance->getForumId());
99  $this->assertSame('', $instance->getSubject());
100  $this->assertSame(0, $instance->getDisplayUserId());
101  $this->assertSame('', $instance->getUserAlias());
102  $this->assertSame('', $instance->getLastPostString());
103  $this->assertSame('', $instance->getCreateDate());
104  $this->assertSame('', $instance->getChangeDate());
105  $this->assertSame(0, $instance->getVisits());
106  $this->assertSame('', $instance->getImportName());
107  $this->assertFalse($instance->isSticky());
108  $this->assertFalse($instance->isClosed());
109  $this->assertSame(0.0, $instance->getAverageRating());
110  $this->assertSame(0, $instance->getThrAuthorId());
111 
112  $this->assertSame(0, $instance->getNumPosts());
113  $this->assertSame(0, $instance->getNumUnreadPosts());
114  $this->assertFalse($instance->isUserNotificationEnabled());
115  }

◆ testClose()

ilForumTopicTest::testClose ( )

Definition at line 509 of file ilForumTopicTest.php.

References $id.

509  : void
510  {
511  $id = 1929;
512 
513  $this->mockDatabase->expects(self::once())->method('manipulateF')->with(
514  'UPDATE frm_threads SET is_closed = %s WHERE thr_pk = %s',
515  ['integer', 'integer'],
516  [1, $id]
517  );
518 
519  $instance = new ilForumTopic();
520  $instance->setId($id);
521  $instance->setClosed(false);
522  $instance->close();
523  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testConstruct()

ilForumTopicTest::testConstruct ( )

Definition at line 32 of file ilForumTopicTest.php.

References $id, ilDBConstants\FETCHMODE_OBJECT, and withIgnoredQuery().

32  : void
33  {
34  $id = 78;
35 
36  $valueAsObject = new stdClass();
37 
38  $valueAsObject->thr_top_fk = 8;
39  $valueAsObject->thr_display_user_id = 8;
40  $valueAsObject->thr_usr_alias = '';
41  $valueAsObject->thr_subject = '';
42  $valueAsObject->thr_date = '';
43  $valueAsObject->thr_update = '';
44  $valueAsObject->import_name = '';
45  $valueAsObject->thr_num_posts = 8;
46  $valueAsObject->thr_last_post = '';
47  $valueAsObject->visits = 8;
48  $valueAsObject->is_sticky = false;
49  $valueAsObject->is_closed = false;
50  $valueAsObject->frm_obj_id = 8;
51  $valueAsObject->avg_rating = 9;
52  $valueAsObject->thr_author_id = 8;
53 
54  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
55  $mockStatement->expects(self::once())
56  ->method('fetchRow')
58  ->willReturn($valueAsObject);
59 
60  $this->withIgnoredQuery(
61  $this->mockDatabase->expects(self::once())->method('queryF'),
62  ['integer'],
63  [$id]
64  )->willReturn($mockStatement);
65 
66  $instance = new ilForumTopic($id);
67 
68  $this->assertInstanceOf(ilForumTopic::class, $instance);
69  }
withIgnoredQuery(InvocationMocker $mock, array ... $expected)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ testCountActivePosts()

ilForumTopicTest::testCountActivePosts ( )

Definition at line 313 of file ilForumTopicTest.php.

References $id, and withIgnoredQuery().

313  : void
314  {
315  $id = 789;
316  $userId = 354;
317  $this->mockUser->expects(self::once())->method('getId')->willReturn($userId);
318  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
319  $this->withIgnoredQuery(
320  $this->mockDatabase->expects(self::once())->method('queryF'),
321  ['integer', 'integer', 'integer', 'integer'],
322  ['1', '0', $userId, $id]
323  )->willReturn($mockStatement);
324  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(['cnt' => 79]);
325 
326  $instance = new ilForumTopic();
327  $instance->setId($id);
328  $this->assertSame(79, $instance->countActivePosts(true));
329  }
withIgnoredQuery(InvocationMocker $mock, array ... $expected)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ testCountActivePostsFailed()

ilForumTopicTest::testCountActivePostsFailed ( )

Definition at line 331 of file ilForumTopicTest.php.

References $id, null, and withIgnoredQuery().

331  : void
332  {
333  $id = 789;
334  $userId = 354;
335  $this->mockUser->expects(self::once())->method('getId')->willReturn($userId);
336  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
337  $this->withIgnoredQuery(
338  $this->mockDatabase->expects(self::once())->method('queryF'),
339  ['integer', 'integer', 'integer', 'integer'],
340  ['1', '0', $userId, $id]
341  )->willReturn($mockStatement);
342  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(null);
343 
344  $instance = new ilForumTopic();
345  $instance->setId($id);
346  $this->assertSame(0, $instance->countActivePosts(true));
347  }
withIgnoredQuery(InvocationMocker $mock, array ... $expected)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ testCountPosts()

ilForumTopicTest::testCountPosts ( )

Definition at line 281 of file ilForumTopicTest.php.

References $id, and withIgnoredQuery().

281  : void
282  {
283  $id = 789;
284  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
285  $this->withIgnoredQuery(
286  $this->mockDatabase->expects(self::once())->method('queryF'),
287  ['integer'],
288  [$id]
289  )->willReturn($mockStatement);
290  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(['cnt' => 678]);
291 
292  $instance = new ilForumTopic();
293  $instance->setId($id);
294  $this->assertSame(678, $instance->countPosts(true));
295  }
withIgnoredQuery(InvocationMocker $mock, array ... $expected)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ testCountPostsFailed()

ilForumTopicTest::testCountPostsFailed ( )

Definition at line 297 of file ilForumTopicTest.php.

References $id, null, and withIgnoredQuery().

297  : void
298  {
299  $id = 789;
300  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
301  $this->withIgnoredQuery(
302  $this->mockDatabase->expects(self::once())->method('queryF'),
303  ['integer'],
304  [$id]
305  )->willReturn($mockStatement);
306  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(null);
307 
308  $instance = new ilForumTopic();
309  $instance->setId($id);
310  $this->assertSame(0, $instance->countPosts(true));
311  }
withIgnoredQuery(InvocationMocker $mock, array ... $expected)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ testDisableNotification()

ilForumTopicTest::testDisableNotification ( )

Definition at line 443 of file ilForumTopicTest.php.

References $id.

443  : void
444  {
445  $id = 384;
446  $userId = 48475;
447 
448  $this->mockDatabase->expects(self::once())->method('manipulateF')->with(
449  'DELETE FROM frm_notification WHERE user_id = %s AND thread_id = %s',
450  ['integer', 'integer'],
451  [$userId, $id]
452  );
453 
454  $instance = new ilForumTopic();
455  $instance->setId($id);
456  $instance->disableNotification($userId);
457  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testEnableNotification()

ilForumTopicTest::testEnableNotification ( )

Definition at line 422 of file ilForumTopicTest.php.

References $id, and withIgnoredQuery().

422  : void
423  {
424  $nextId = 3847;
425  $id = 3739;
426  $userId = 8283;
427 
428  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
429  $this->mockDatabase->expects(self::once())->method('nextId')->with('frm_notification')->willReturn($nextId);
430  $this->mockDatabase->expects(self::once())->method('queryF')->willReturn($mockStatement);
431  $this->withIgnoredQuery(
432  $this->mockDatabase->expects(self::once())->method('manipulateF'),
433  ['integer', 'integer', 'integer'],
434  [$nextId, $userId, $id]
435  )->willReturn(0);
436  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(['cnt' => 0]);
437 
438  $instance = new ilForumTopic();
439  $instance->setId($id);
440  $instance->enableNotification($userId);
441  }
withIgnoredQuery(InvocationMocker $mock, array ... $expected)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ testGetAllPostIds()

ilForumTopicTest::testGetAllPostIds ( )

Definition at line 349 of file ilForumTopicTest.php.

References $id, ilDBConstants\FETCHMODE_OBJECT, and null.

349  : void
350  {
351  $firstRow = new stdClass();
352  $firstRow->pos_pk = 89;
353  $id = 284;
354  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
355  $mockStatement->expects(self::exactly(2))
356  ->method('fetchRow')
358  ->willReturnOnConsecutiveCalls($firstRow, null);
359  $this->mockDatabase->expects(self::once())->method('queryF')->with(
360  'SELECT pos_pk FROM frm_posts WHERE pos_thr_fk = %s',
361  ['integer'],
362  [$id]
363  )->willReturn($mockStatement);
364 
365  $instance = new ilForumTopic();
366  $instance->setId($id);
367  $this->assertSame([$firstRow->pos_pk => $firstRow->pos_pk], $instance->getAllPostIds());
368  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testGetFirstVisiblePostId()

ilForumTopicTest::testGetFirstVisiblePostId ( )

Definition at line 231 of file ilForumTopicTest.php.

References $id.

231  : void
232  {
233  $id = 909;
234  $stdObject = new stdClass();
235  $stdObject->pos_fk = 5678;
236  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
237  $this->mockDatabase->expects(self::once())->method('queryF')->with(
238  'SELECT pos_fk FROM frm_posts_tree WHERE thr_fk = %s AND parent_pos != %s AND depth = %s ORDER BY rgt DESC',
239  ['integer', 'integer', 'integer'],
240  [$id, 0, 2]
241  )->willReturn($mockStatement);
242  $this->mockDatabase->expects(self::once())->method('fetchObject')->with($mockStatement)->willReturn($stdObject);
243 
244  $instance = new ilForumTopic();
245  $instance->setId($id);
246  $this->assertSame($stdObject->pos_fk, $instance->getFirstVisiblePostId());
247  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testGetFirstVisiblePostIdFailed()

ilForumTopicTest::testGetFirstVisiblePostIdFailed ( )

Definition at line 265 of file ilForumTopicTest.php.

References $id, and null.

265  : void
266  {
267  $id = 909;
268  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
269  $this->mockDatabase->expects(self::once())->method('queryF')->with(
270  'SELECT pos_fk FROM frm_posts_tree WHERE thr_fk = %s AND parent_pos != %s AND depth = %s ORDER BY rgt DESC',
271  ['integer', 'integer', 'integer'],
272  [$id, 0, 2]
273  )->willReturn($mockStatement);
274  $this->mockDatabase->expects(self::once())->method('fetchObject')->with($mockStatement)->willReturn(null);
275 
276  $instance = new ilForumTopic();
277  $instance->setId($id);
278  $this->assertSame(0, $instance->getFirstVisiblePostId());
279  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testGetPostRootId()

ilForumTopicTest::testGetPostRootId ( )

Definition at line 213 of file ilForumTopicTest.php.

References $id.

213  : void
214  {
215  $id = 909;
216  $stdObject = new stdClass();
217  $stdObject->pos_fk = 5678;
218  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
219  $this->mockDatabase->expects(self::once())->method('queryF')->with(
220  'SELECT pos_fk FROM frm_posts_tree WHERE thr_fk = %s AND parent_pos = %s AND depth = %s ORDER BY rgt DESC',
221  ['integer', 'integer', 'integer'],
222  [$id, 0, 1]
223  )->willReturn($mockStatement);
224  $this->mockDatabase->expects(self::once())->method('fetchObject')->with($mockStatement)->willReturn($stdObject);
225 
226  $instance = new ilForumTopic();
227  $instance->setId($id);
228  $this->assertSame($stdObject->pos_fk, $instance->getPostRootId());
229  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testGetPostRootIdFailed()

ilForumTopicTest::testGetPostRootIdFailed ( )

Definition at line 249 of file ilForumTopicTest.php.

References $id, and null.

249  : void
250  {
251  $id = 909;
252  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
253  $this->mockDatabase->expects(self::once())->method('queryF')->with(
254  'SELECT pos_fk FROM frm_posts_tree WHERE thr_fk = %s AND parent_pos = %s AND depth = %s ORDER BY rgt DESC',
255  ['integer', 'integer', 'integer'],
256  [$id, 0, 1]
257  )->willReturn($mockStatement);
258  $this->mockDatabase->expects(self::once())->method('fetchObject')->with($mockStatement)->willReturn(null);
259 
260  $instance = new ilForumTopic();
261  $instance->setId($id);
262  $this->assertSame(0, $instance->getPostRootId());
263  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testInsert()

ilForumTopicTest::testInsert ( )

Definition at line 117 of file ilForumTopicTest.php.

References null.

117  : void
118  {
119  $instance = new ilForumTopic();
120  $nextId = 8;
121  $instance->setId(9);
122  $instance->setForumId(10);
123  $instance->setSubject('aa');
124  $instance->setDisplayUserId(188);
125  $instance->setUserAlias('jl');
126  $instance->setNumPosts(86);
127  $instance->setLastPostString('ahssh');
128  $instance->setCreateDate('some date');
129  $instance->setImportName('xaii');
130  $instance->setSticky(true);
131  $instance->setClosed(true);
132  $instance->setAverageRating(78);
133  $instance->setThrAuthorId(8890);
134 
135  $this->mockDatabase->expects(self::once())->method('nextId')->with('frm_threads')->willReturn($nextId);
136 
137  $this->mockDatabase->expects(self::once())->method('insert')->with(
138  'frm_threads',
139  [
140  'thr_pk' => ['integer', $nextId],
141  'thr_top_fk' => ['integer', 10],
142  'thr_subject' => ['text', 'aa'],
143  'thr_display_user_id' => ['integer', 188],
144  'thr_usr_alias' => ['text', 'jl'],
145  'thr_num_posts' => ['integer', 86],
146  'thr_last_post' => ['text', 'ahssh'],
147  'thr_date' => ['timestamp', 'some date'],
148  'thr_update' => ['timestamp', null],
149  'import_name' => ['text', 'xaii'],
150  'is_sticky' => ['integer', 1],
151  'is_closed' => ['integer', 1],
152  'avg_rating' => ['text', 78],
153  'thr_author_id' => ['integer', 8890],
154  ]
155  );
156 
157  $this->assertTrue($instance->insert());
158  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ testInsertFalse()

ilForumTopicTest::testInsertFalse ( )

Definition at line 160 of file ilForumTopicTest.php.

160  : void
161  {
162  $instance = new ilForumTopic();
163  $this->mockDatabase->expects(self::never())->method('nextId');
164  $this->mockDatabase->expects(self::never())->method('insert');
165  $instance->setForumId(0);
166  $this->assertFalse($instance->insert());
167  }

◆ testIsNotificationEnabled()

ilForumTopicTest::testIsNotificationEnabled ( )

Definition at line 370 of file ilForumTopicTest.php.

References $id.

370  : void
371  {
372  $id = 723;
373  $userId = 639;
374 
375  $instance = new ilForumTopic();
376  $instance->setId($id);
377 
378  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
379  $this->mockDatabase->expects(self::once())->method('queryF')->with(
380  'SELECT COUNT(notification_id) cnt FROM frm_notification WHERE user_id = %s AND thread_id = %s',
381  ['integer', 'integer'],
382  [$userId, $id]
383  )->willReturn($mockStatement);
384  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(['cnt' => 46]);
385 
386  $this->assertTrue($instance->isNotificationEnabled($userId));
387  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testIsNotificationEnabledInvalidIds()

ilForumTopicTest::testIsNotificationEnabledInvalidIds ( )

Definition at line 408 of file ilForumTopicTest.php.

References $id.

408  : void
409  {
410  $id = 723;
411  $userId = 0;
412 
413  $instance = new ilForumTopic();
414  $instance->setId($id);
415 
416  $this->mockDatabase->expects(self::never())->method('queryF');
417  $this->mockDatabase->expects(self::never())->method('fetchAssoc');
418 
419  $this->assertFalse($instance->isNotificationEnabled($userId));
420  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testIsNotificationEnabledNoResult()

ilForumTopicTest::testIsNotificationEnabledNoResult ( )

Definition at line 389 of file ilForumTopicTest.php.

References $id, and null.

389  : void
390  {
391  $id = 723;
392  $userId = 639;
393 
394  $instance = new ilForumTopic();
395  $instance->setId($id);
396 
397  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
398  $this->mockDatabase->expects(self::once())->method('queryF')->with(
399  'SELECT COUNT(notification_id) cnt FROM frm_notification WHERE user_id = %s AND thread_id = %s',
400  ['integer', 'integer'],
401  [$userId, $id]
402  )->willReturn($mockStatement);
403  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(null);
404 
405  $this->assertFalse($instance->isNotificationEnabled($userId));
406  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testMakeSticky()

ilForumTopicTest::testMakeSticky ( )

Definition at line 459 of file ilForumTopicTest.php.

References $id.

459  : void
460  {
461  $id = 1929;
462 
463  $this->mockDatabase->expects(self::once())->method('manipulateF')->with(
464  'UPDATE frm_threads SET is_sticky = %s WHERE thr_pk = %s',
465  ['integer', 'integer'],
466  [1, $id]
467  );
468 
469  $instance = new ilForumTopic();
470  $instance->setId($id);
471  $this->assertTrue($instance->makeSticky());
472  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testMakeStickyFailed()

ilForumTopicTest::testMakeStickyFailed ( )

Definition at line 474 of file ilForumTopicTest.php.

474  : void
475  {
476  $this->mockDatabase->expects(self::never())->method('manipulateF');
477 
478  $instance = new ilForumTopic();
479  $this->assertFalse($instance->makeSticky());
480  }

◆ testReload()

ilForumTopicTest::testReload ( )

Definition at line 203 of file ilForumTopicTest.php.

References null.

203  : void
204  {
205  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
206  $mockStatement->expects(self::once())->method('fetchRow')->willReturn(null);
207  $this->mockDatabase->expects(self::once())->method('queryF')->willReturn($mockStatement);
208  $instance = new ilForumTopic();
209  $instance->setId(89);
210  $instance->reload();
211  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ testReopen()

ilForumTopicTest::testReopen ( )

Definition at line 525 of file ilForumTopicTest.php.

References $id.

525  : void
526  {
527  $id = 1929;
528 
529  $this->mockDatabase->expects(self::once())->method('manipulateF')->with(
530  'UPDATE frm_threads SET is_closed = %s WHERE thr_pk = %s',
531  ['integer', 'integer'],
532  [0, $id]
533  );
534 
535  $instance = new ilForumTopic();
536  $instance->setId($id);
537  $instance->setClosed(true);
538  $instance->reopen();
539  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testUnmakeSticky()

ilForumTopicTest::testUnmakeSticky ( )

Definition at line 482 of file ilForumTopicTest.php.

References $id.

482  : void
483  {
484  $id = 1929;
485 
486  $this->mockDatabase->expects(self::once())->method('manipulateF')->with(
487  'UPDATE frm_threads SET is_sticky = %s WHERE thr_pk = %s',
488  ['integer', 'integer'],
489  [0, $id]
490  );
491 
492  $instance = new ilForumTopic();
493  $instance->setId($id);
494  $instance->setSticky(true);
495  $this->assertTrue($instance->unmakeSticky());
496  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testUnmakeStickyFalse()

ilForumTopicTest::testUnmakeStickyFalse ( )

Definition at line 498 of file ilForumTopicTest.php.

References $id.

498  : void
499  {
500  $id = 1929;
501 
502  $this->mockDatabase->expects(self::never())->method('manipulateF');
503 
504  $instance = new ilForumTopic();
505  $instance->setId($id);
506  $this->assertFalse($instance->unmakeSticky());
507  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testUpdate()

ilForumTopicTest::testUpdate ( )

Definition at line 169 of file ilForumTopicTest.php.

References withIgnoredQuery().

169  : void
170  {
171  $instance = new ilForumTopic();
172  $instance->setId(8);
173  $instance->setForumId(789);
174  $instance->setSubject('abc');
175  $instance->setNumPosts(67);
176  $instance->setLastPostString('hej');
177  $instance->setAverageRating(27);
178 
179  $this->withIgnoredQuery(
180  $this->mockDatabase->expects(self::once())->method('manipulateF'),
181  ['integer', 'text', 'timestamp', 'integer', 'text', 'text', 'integer'],
182  [
183  789,
184  'abc',
185  date('Y-m-d H:i:s'),
186  67,
187  'hej',
188  '27',
189  8,
190  ]
191  )->willReturn(0);
192  $this->assertTrue($instance->update());
193  }
withIgnoredQuery(InvocationMocker $mock, array ... $expected)
+ Here is the call graph for this function:

◆ testUpdateFalse()

ilForumTopicTest::testUpdateFalse ( )

Definition at line 195 of file ilForumTopicTest.php.

195  : void
196  {
197  $instance = new ilForumTopic();
198  $this->mockDatabase->expects(self::never())->method('manipulateF');
199  $instance->setForumId(0);
200  $this->assertFalse($instance->update());
201  }

◆ withIgnoredQuery()

ilForumTopicTest::withIgnoredQuery ( InvocationMocker  $mock,
array ...  $expected 
)
private

Definition at line 565 of file ilForumTopicTest.php.

Referenced by testConstruct(), testCountActivePosts(), testCountActivePostsFailed(), testCountPosts(), testCountPostsFailed(), testEnableNotification(), and testUpdate().

565  : InvocationMocker
566  {
567  return $mock->willReturnCallback(function ($ignored, ...$actual) use ($expected): void {
568  $this->assertSame($expected, $actual);
569  });
570  }
+ Here is the caller graph for this function:

Field Documentation

◆ $dic

Container ilForumTopicTest::$dic = null
private

Definition at line 30 of file ilForumTopicTest.php.

Referenced by tearDown().

◆ $mockDatabase

MockObject& ilDBInterface ilForumTopicTest::$mockDatabase
private

Definition at line 28 of file ilForumTopicTest.php.

Referenced by setUp().

◆ $mockUser

MockObject& ilObjUser ilForumTopicTest::$mockUser
private

Definition at line 29 of file ilForumTopicTest.php.

Referenced by setUp().


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