ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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,... $expected)
 

Private Attributes

 $mockDatabase
 
 $mockUser
 
Container $dic = null
 

Detailed Description

Definition at line 26 of file ilForumTopicTest.php.

Member Function Documentation

◆ setUp()

ilForumTopicTest::setUp ( )
protected

Definition at line 549 of file ilForumTopicTest.php.

References $DIC, $mockDatabase, and $mockUser.

549  : void
550  {
551  global $DIC;
552 
553  $this->dic = is_object($DIC) ? clone $DIC : $DIC;
554 
555  $DIC = new Container();
556 
557  $this->mockDatabase = $this->getMockBuilder(ilDBInterface::class)->getMock();
558  $this->mockUser = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->getMock();
559 
560  $DIC['ilDB'] = $this->mockDatabase;
561  $DIC['ilUser'] = $this->mockUser;
562  }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
global $DIC
Definition: feed.php:28

◆ tearDown()

ilForumTopicTest::tearDown ( )
protected

Definition at line 564 of file ilForumTopicTest.php.

References $DIC, and $dic.

564  : void
565  {
566  global $DIC;
567 
568  $DIC = $this->dic;
569 
570  parent::tearDown();
571  }
global $DIC
Definition: feed.php:28

◆ testAssignData()

ilForumTopicTest::testAssignData ( )

Definition at line 74 of file ilForumTopicTest.php.

References $data.

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

◆ testClose()

ilForumTopicTest::testClose ( )

Definition at line 517 of file ilForumTopicTest.php.

References $id.

517  : void
518  {
519  $id = 1929;
520 
521  $this->mockDatabase->expects(self::once())->method('manipulateF')->with(
522  'UPDATE frm_threads SET is_closed = %s WHERE thr_pk = %s',
523  ['integer', 'integer'],
524  [1, $id]
525  );
526 
527  $instance = new ilForumTopic();
528  $instance->setId($id);
529  $instance->setClosed(false);
530  $instance->close();
531  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testConstruct()

ilForumTopicTest::testConstruct ( )

Definition at line 34 of file ilForumTopicTest.php.

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

34  : void
35  {
36  $id = 78;
37 
38  $valueAsObject = new stdClass();
39 
40  $valueAsObject->thr_top_fk = 8;
41  $valueAsObject->thr_display_user_id = 8;
42  $valueAsObject->thr_usr_alias = '';
43  $valueAsObject->thr_subject = '';
44  $valueAsObject->thr_date = '';
45  $valueAsObject->thr_update = '';
46  $valueAsObject->import_name = '';
47  $valueAsObject->thr_num_posts = 8;
48  $valueAsObject->thr_last_post = '';
49  $valueAsObject->visits = 8;
50  $valueAsObject->is_sticky = false;
51  $valueAsObject->thread_sorting = 0;
52  $valueAsObject->is_closed = false;
53  $valueAsObject->frm_obj_id = 8;
54  $valueAsObject->avg_rating = 9;
55  $valueAsObject->thr_author_id = 8;
56 
57  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
58  $mockStatement->expects(self::once())
59  ->method('fetchRow')
61  ->willReturn($valueAsObject);
62 
63  $this->withIgnoredQuery(
64  $this->mockDatabase->expects(self::once())->method('queryF'),
65  ['integer'],
66  [$id]
67  )->willReturn($mockStatement);
68 
69  $instance = new ilForumTopic($id);
70 
71  $this->assertInstanceOf(ilForumTopic::class, $instance);
72  }
withIgnoredQuery(InvocationMocker $mock,... $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 319 of file ilForumTopicTest.php.

References $id, and withIgnoredQuery().

319  : void
320  {
321  $id = 789;
322  $userId = 354;
323  $this->mockUser->expects(self::once())->method('getId')->willReturn($userId);
324  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
325  $this->withIgnoredQuery(
326  $this->mockDatabase->expects(self::once())->method('queryF'),
327  ['integer', 'integer', 'integer', 'integer'],
328  ['1', '0', $userId, $id]
329  )->willReturn($mockStatement);
330  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(['cnt' => 79]);
331 
332  $instance = new ilForumTopic();
333  $instance->setId($id);
334  $this->assertSame(79, $instance->countActivePosts(true));
335  }
withIgnoredQuery(InvocationMocker $mock,... $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 337 of file ilForumTopicTest.php.

References $id, and withIgnoredQuery().

337  : void
338  {
339  $id = 789;
340  $userId = 354;
341  $this->mockUser->expects(self::once())->method('getId')->willReturn($userId);
342  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
343  $this->withIgnoredQuery(
344  $this->mockDatabase->expects(self::once())->method('queryF'),
345  ['integer', 'integer', 'integer', 'integer'],
346  ['1', '0', $userId, $id]
347  )->willReturn($mockStatement);
348  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(null);
349 
350  $instance = new ilForumTopic();
351  $instance->setId($id);
352  $this->assertSame(0, $instance->countActivePosts(true));
353  }
withIgnoredQuery(InvocationMocker $mock,... $expected)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ testCountPosts()

ilForumTopicTest::testCountPosts ( )

Definition at line 287 of file ilForumTopicTest.php.

References $id, and withIgnoredQuery().

287  : void
288  {
289  $id = 789;
290  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
291  $this->withIgnoredQuery(
292  $this->mockDatabase->expects(self::once())->method('queryF'),
293  ['integer'],
294  [$id]
295  )->willReturn($mockStatement);
296  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(['cnt' => 678]);
297 
298  $instance = new ilForumTopic();
299  $instance->setId($id);
300  $this->assertSame(678, $instance->countPosts(true));
301  }
withIgnoredQuery(InvocationMocker $mock,... $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 303 of file ilForumTopicTest.php.

References $id, and withIgnoredQuery().

303  : void
304  {
305  $id = 789;
306  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
307  $this->withIgnoredQuery(
308  $this->mockDatabase->expects(self::once())->method('queryF'),
309  ['integer'],
310  [$id]
311  )->willReturn($mockStatement);
312  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(null);
313 
314  $instance = new ilForumTopic();
315  $instance->setId($id);
316  $this->assertSame(0, $instance->countPosts(true));
317  }
withIgnoredQuery(InvocationMocker $mock,... $expected)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ testDisableNotification()

ilForumTopicTest::testDisableNotification ( )

Definition at line 449 of file ilForumTopicTest.php.

References $id.

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

◆ testEnableNotification()

ilForumTopicTest::testEnableNotification ( )

Definition at line 428 of file ilForumTopicTest.php.

References $id, and withIgnoredQuery().

428  : void
429  {
430  $nextId = 3847;
431  $id = 3739;
432  $userId = 8283;
433 
434  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
435  $this->mockDatabase->expects(self::once())->method('nextId')->with('frm_notification')->willReturn($nextId);
436  $this->mockDatabase->expects(self::once())->method('queryF')->willReturn($mockStatement);
437  $this->withIgnoredQuery(
438  $this->mockDatabase->expects(self::once())->method('manipulateF'),
439  ['integer', 'integer', 'integer'],
440  [$nextId, $userId, $id]
441  )->willReturn(0);
442  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(['cnt' => 0]);
443 
444  $instance = new ilForumTopic();
445  $instance->setId($id);
446  $instance->enableNotification($userId);
447  }
withIgnoredQuery(InvocationMocker $mock,... $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 355 of file ilForumTopicTest.php.

References $id, and ilDBConstants\FETCHMODE_OBJECT.

355  : void
356  {
357  $firstRow = new stdClass();
358  $firstRow->pos_pk = 89;
359  $id = 284;
360  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
361  $mockStatement->expects(self::exactly(2))
362  ->method('fetchRow')
364  ->willReturnOnConsecutiveCalls($firstRow, null);
365  $this->mockDatabase->expects(self::once())->method('queryF')->with(
366  'SELECT pos_pk FROM frm_posts WHERE pos_thr_fk = %s',
367  ['integer'],
368  [$id]
369  )->willReturn($mockStatement);
370 
371  $instance = new ilForumTopic();
372  $instance->setId($id);
373  $this->assertSame([$firstRow->pos_pk => $firstRow->pos_pk], $instance->getAllPostIds());
374  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testGetFirstVisiblePostId()

ilForumTopicTest::testGetFirstVisiblePostId ( )

Definition at line 237 of file ilForumTopicTest.php.

References $id.

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

◆ testGetFirstVisiblePostIdFailed()

ilForumTopicTest::testGetFirstVisiblePostIdFailed ( )

Definition at line 271 of file ilForumTopicTest.php.

References $id.

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

◆ testGetPostRootId()

ilForumTopicTest::testGetPostRootId ( )

Definition at line 219 of file ilForumTopicTest.php.

References $id.

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

◆ testGetPostRootIdFailed()

ilForumTopicTest::testGetPostRootIdFailed ( )

Definition at line 255 of file ilForumTopicTest.php.

References $id.

255  : void
256  {
257  $id = 909;
258  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
259  $this->mockDatabase->expects(self::once())->method('queryF')->with(
260  'SELECT pos_fk FROM frm_posts_tree WHERE thr_fk = %s AND parent_pos = %s AND depth = %s ORDER BY rgt DESC',
261  ['integer', 'integer', 'integer'],
262  [$id, 0, 1]
263  )->willReturn($mockStatement);
264  $this->mockDatabase->expects(self::once())->method('fetchObject')->with($mockStatement)->willReturn(null);
265 
266  $instance = new ilForumTopic();
267  $instance->setId($id);
268  $this->assertSame(0, $instance->getPostRootId());
269  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testInsert()

ilForumTopicTest::testInsert ( )

Definition at line 122 of file ilForumTopicTest.php.

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

◆ testInsertFalse()

ilForumTopicTest::testInsertFalse ( )

Definition at line 166 of file ilForumTopicTest.php.

166  : void
167  {
168  $instance = new ilForumTopic();
169  $this->mockDatabase->expects(self::never())->method('nextId');
170  $this->mockDatabase->expects(self::never())->method('insert');
171  $instance->setForumId(0);
172  $this->assertFalse($instance->insert());
173  }

◆ testIsNotificationEnabled()

ilForumTopicTest::testIsNotificationEnabled ( )

Definition at line 376 of file ilForumTopicTest.php.

References $id.

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

◆ testIsNotificationEnabledInvalidIds()

ilForumTopicTest::testIsNotificationEnabledInvalidIds ( )

Definition at line 414 of file ilForumTopicTest.php.

References $id.

414  : void
415  {
416  $id = 723;
417  $userId = 0;
418 
419  $instance = new ilForumTopic();
420  $instance->setId($id);
421 
422  $this->mockDatabase->expects(self::never())->method('queryF');
423  $this->mockDatabase->expects(self::never())->method('fetchAssoc');
424 
425  $this->assertFalse($instance->isNotificationEnabled($userId));
426  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testIsNotificationEnabledNoResult()

ilForumTopicTest::testIsNotificationEnabledNoResult ( )

Definition at line 395 of file ilForumTopicTest.php.

References $id.

395  : void
396  {
397  $id = 723;
398  $userId = 639;
399 
400  $instance = new ilForumTopic();
401  $instance->setId($id);
402 
403  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
404  $this->mockDatabase->expects(self::once())->method('queryF')->with(
405  'SELECT COUNT(notification_id) cnt FROM frm_notification WHERE user_id = %s AND thread_id = %s',
406  ['integer', 'integer'],
407  [$userId, $id]
408  )->willReturn($mockStatement);
409  $this->mockDatabase->expects(self::once())->method('fetchAssoc')->with($mockStatement)->willReturn(null);
410 
411  $this->assertFalse($instance->isNotificationEnabled($userId));
412  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testMakeSticky()

ilForumTopicTest::testMakeSticky ( )

Definition at line 465 of file ilForumTopicTest.php.

References $id.

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

◆ testMakeStickyFailed()

ilForumTopicTest::testMakeStickyFailed ( )

Definition at line 480 of file ilForumTopicTest.php.

References $id.

480  : void
481  {
482  $id = 1929;
483 
484  $this->mockDatabase->expects(self::never())->method('manipulateF');
485 
486  $instance = new ilForumTopic();
487  $this->assertFalse($instance->makeSticky());
488  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testReload()

ilForumTopicTest::testReload ( )

Definition at line 209 of file ilForumTopicTest.php.

209  : void
210  {
211  $mockStatement = $this->getMockBuilder(ilDBStatement::class)->disableOriginalConstructor()->getMock();
212  $mockStatement->expects(self::once())->method('fetchRow')->willReturn(null);
213  $this->mockDatabase->expects(self::once())->method('queryF')->willReturn($mockStatement);
214  $instance = new ilForumTopic();
215  $instance->setId(89);
216  $instance->reload();
217  }

◆ testReopen()

ilForumTopicTest::testReopen ( )

Definition at line 533 of file ilForumTopicTest.php.

References $id.

533  : void
534  {
535  $id = 1929;
536 
537  $this->mockDatabase->expects(self::once())->method('manipulateF')->with(
538  'UPDATE frm_threads SET is_closed = %s WHERE thr_pk = %s',
539  ['integer', 'integer'],
540  [0, $id]
541  );
542 
543  $instance = new ilForumTopic();
544  $instance->setId($id);
545  $instance->setClosed(true);
546  $instance->reopen();
547  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testUnmakeSticky()

ilForumTopicTest::testUnmakeSticky ( )

Definition at line 490 of file ilForumTopicTest.php.

References $id.

490  : void
491  {
492  $id = 1929;
493 
494  $this->mockDatabase->expects(self::once())->method('manipulateF')->with(
495  'UPDATE frm_threads SET is_sticky = %s WHERE thr_pk = %s',
496  ['integer', 'integer'],
497  [0, $id]
498  );
499 
500  $instance = new ilForumTopic();
501  $instance->setId($id);
502  $instance->setSticky(true);
503  $this->assertTrue($instance->unmakeSticky());
504  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testUnmakeStickyFalse()

ilForumTopicTest::testUnmakeStickyFalse ( )

Definition at line 506 of file ilForumTopicTest.php.

References $id.

506  : void
507  {
508  $id = 1929;
509 
510  $this->mockDatabase->expects(self::never())->method('manipulateF');
511 
512  $instance = new ilForumTopic();
513  $instance->setId($id);
514  $this->assertFalse($instance->unmakeSticky());
515  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testUpdate()

ilForumTopicTest::testUpdate ( )

Definition at line 175 of file ilForumTopicTest.php.

References withIgnoredQuery().

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

◆ testUpdateFalse()

ilForumTopicTest::testUpdateFalse ( )

Definition at line 201 of file ilForumTopicTest.php.

201  : void
202  {
203  $instance = new ilForumTopic();
204  $this->mockDatabase->expects(self::never())->method('manipulateF');
205  $instance->setForumId(0);
206  $this->assertFalse($instance->update());
207  }

◆ withIgnoredQuery()

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

Definition at line 573 of file ilForumTopicTest.php.

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

573  : InvocationMocker
574  {
575  return $mock->willReturnCallback(function ($ignored, ...$actual) use ($expected) {
576  $this->assertSame($expected, $actual);
577  });
578  }
+ Here is the caller graph for this function:

Field Documentation

◆ $dic

Container ilForumTopicTest::$dic = null
private

Definition at line 32 of file ilForumTopicTest.php.

Referenced by tearDown().

◆ $mockDatabase

ilForumTopicTest::$mockDatabase
private

Definition at line 29 of file ilForumTopicTest.php.

Referenced by setUp().

◆ $mockUser

ilForumTopicTest::$mockUser
private

Definition at line 31 of file ilForumTopicTest.php.

Referenced by setUp().


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