3 use MediaWiki\MediaWikiServices
;
4 use Wikimedia\ScopedCallback
;
5 use Wikimedia\TestingAccessWrapper
;
10 * @covers CommentStoreComment
12 class CommentStoreTest
extends MediaWikiLangTestCase
{
14 protected $tablesUsed = [
16 'revision_comment_temp',
21 protected function getSchemaOverrides( IMaintainableDatabase
$db ) {
24 __DIR__
. '/CommentStoreTest.sql',
27 'create' => [ 'commentstore1', 'commentstore2', 'commentstore2_temp' ],
33 * Create a store for a particular stage
35 * @return CommentStore
37 protected function makeStore( $stage ) {
38 $store = new CommentStore( MediaWikiServices
::getInstance()->getContentLanguage(), $stage );
40 TestingAccessWrapper
::newFromObject( $store )->tempTables +
= [ 'cs2_comment' => [
41 'table' => 'commentstore2_temp',
43 'field' => 'cs2t_comment_id',
45 'stage' => MIGRATION_OLD
,
46 'deprecatedIn' => null,
53 * Create a store for a particular stage and key (for testing deprecated behaviour)
56 * @return CommentStore
58 protected function makeStoreWithKey( $stage, $key ) {
59 $this->hideDeprecated( 'CommentStore::newKey' );
60 $store = CommentStore
::newKey( $key );
61 TestingAccessWrapper
::newFromObject( $store )->stage
= $stage;
63 TestingAccessWrapper
::newFromObject( $store )->tempTables +
= [ 'cs2_comment' => [
64 'table' => 'commentstore2_temp',
66 'field' => 'cs2t_comment_id',
68 'stage' => MIGRATION_OLD
,
69 'deprecatedIn' => null,
76 * @dataProvider provideGetFields
79 * @param array $expect
81 public function testGetFields_withKeyConstruction( $stage, $key, $expect ) {
82 $store = $this->makeStoreWithKey( $stage, $key );
83 $result = $store->getFields();
84 $this->assertEquals( $expect, $result );
88 * @dataProvider provideGetFields
91 * @param array $expect
93 public function testGetFields( $stage, $key, $expect ) {
94 $store = $this->makeStore( $stage );
95 $result = $store->getFields( $key );
96 $this->assertEquals( $expect, $result );
99 public static function provideGetFields() {
101 'Simple table, old' => [
102 MIGRATION_OLD
, 'ipb_reason',
103 [ 'ipb_reason_text' => 'ipb_reason', 'ipb_reason_data' => 'NULL', 'ipb_reason_cid' => 'NULL' ],
105 'Simple table, write-both' => [
106 MIGRATION_WRITE_BOTH
, 'ipb_reason',
107 [ 'ipb_reason_old' => 'ipb_reason', 'ipb_reason_id' => 'ipb_reason_id' ],
109 'Simple table, write-new' => [
110 MIGRATION_WRITE_NEW
, 'ipb_reason',
111 [ 'ipb_reason_old' => 'ipb_reason', 'ipb_reason_id' => 'ipb_reason_id' ],
113 'Simple table, new' => [
114 MIGRATION_NEW
, 'ipb_reason',
115 [ 'ipb_reason_id' => 'ipb_reason_id' ],
119 MIGRATION_OLD
, 'rev_comment',
121 'rev_comment_text' => 'rev_comment',
122 'rev_comment_data' => 'NULL',
123 'rev_comment_cid' => 'NULL',
126 'Revision, write-both' => [
127 MIGRATION_WRITE_BOTH
, 'rev_comment',
128 [ 'rev_comment_old' => 'rev_comment', 'rev_comment_pk' => 'rev_id' ],
130 'Revision, write-new' => [
131 MIGRATION_WRITE_NEW
, 'rev_comment',
132 [ 'rev_comment_old' => 'rev_comment', 'rev_comment_pk' => 'rev_id' ],
135 MIGRATION_NEW
, 'rev_comment',
136 [ 'rev_comment_pk' => 'rev_id' ],
140 MIGRATION_OLD
, 'img_description',
142 'img_description_text' => 'img_description',
143 'img_description_data' => 'NULL',
144 'img_description_cid' => 'NULL',
147 'Image, write-both' => [
148 MIGRATION_WRITE_BOTH
, 'img_description',
150 'img_description_old' => 'img_description',
151 'img_description_id' => 'img_description_id'
154 'Image, write-new' => [
155 MIGRATION_WRITE_NEW
, 'img_description',
157 'img_description_old' => 'img_description',
158 'img_description_id' => 'img_description_id'
162 MIGRATION_NEW
, 'img_description',
164 'img_description_id' => 'img_description_id'
171 * @dataProvider provideGetJoin
174 * @param array $expect
176 public function testGetJoin_withKeyConstruction( $stage, $key, $expect ) {
177 $store = $this->makeStoreWithKey( $stage, $key );
178 $result = $store->getJoin();
179 $this->assertEquals( $expect, $result );
183 * @dataProvider provideGetJoin
186 * @param array $expect
188 public function testGetJoin( $stage, $key, $expect ) {
189 $store = $this->makeStore( $stage );
190 $result = $store->getJoin( $key );
191 $this->assertEquals( $expect, $result );
194 public static function provideGetJoin() {
196 'Simple table, old' => [
197 MIGRATION_OLD
, 'ipb_reason', [
200 'ipb_reason_text' => 'ipb_reason',
201 'ipb_reason_data' => 'NULL',
202 'ipb_reason_cid' => 'NULL',
207 'Simple table, write-both' => [
208 MIGRATION_WRITE_BOTH
, 'ipb_reason', [
209 'tables' => [ 'comment_ipb_reason' => 'comment' ],
211 'ipb_reason_text' => 'COALESCE( comment_ipb_reason.comment_text, ipb_reason )',
212 'ipb_reason_data' => 'comment_ipb_reason.comment_data',
213 'ipb_reason_cid' => 'comment_ipb_reason.comment_id',
216 'comment_ipb_reason' => [ 'LEFT JOIN', 'comment_ipb_reason.comment_id = ipb_reason_id' ],
220 'Simple table, write-new' => [
221 MIGRATION_WRITE_NEW
, 'ipb_reason', [
222 'tables' => [ 'comment_ipb_reason' => 'comment' ],
224 'ipb_reason_text' => 'COALESCE( comment_ipb_reason.comment_text, ipb_reason )',
225 'ipb_reason_data' => 'comment_ipb_reason.comment_data',
226 'ipb_reason_cid' => 'comment_ipb_reason.comment_id',
229 'comment_ipb_reason' => [ 'LEFT JOIN', 'comment_ipb_reason.comment_id = ipb_reason_id' ],
233 'Simple table, new' => [
234 MIGRATION_NEW
, 'ipb_reason', [
235 'tables' => [ 'comment_ipb_reason' => 'comment' ],
237 'ipb_reason_text' => 'comment_ipb_reason.comment_text',
238 'ipb_reason_data' => 'comment_ipb_reason.comment_data',
239 'ipb_reason_cid' => 'comment_ipb_reason.comment_id',
242 'comment_ipb_reason' => [ 'JOIN', 'comment_ipb_reason.comment_id = ipb_reason_id' ],
248 MIGRATION_OLD
, 'rev_comment', [
251 'rev_comment_text' => 'rev_comment',
252 'rev_comment_data' => 'NULL',
253 'rev_comment_cid' => 'NULL',
258 'Revision, write-both' => [
259 MIGRATION_WRITE_BOTH
, 'rev_comment', [
261 'temp_rev_comment' => 'revision_comment_temp',
262 'comment_rev_comment' => 'comment',
265 'rev_comment_text' => 'COALESCE( comment_rev_comment.comment_text, rev_comment )',
266 'rev_comment_data' => 'comment_rev_comment.comment_data',
267 'rev_comment_cid' => 'comment_rev_comment.comment_id',
270 'temp_rev_comment' => [ 'LEFT JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
271 'comment_rev_comment' => [ 'LEFT JOIN',
272 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
276 'Revision, write-new' => [
277 MIGRATION_WRITE_NEW
, 'rev_comment', [
279 'temp_rev_comment' => 'revision_comment_temp',
280 'comment_rev_comment' => 'comment',
283 'rev_comment_text' => 'COALESCE( comment_rev_comment.comment_text, rev_comment )',
284 'rev_comment_data' => 'comment_rev_comment.comment_data',
285 'rev_comment_cid' => 'comment_rev_comment.comment_id',
288 'temp_rev_comment' => [ 'LEFT JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
289 'comment_rev_comment' => [ 'LEFT JOIN',
290 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
295 MIGRATION_NEW
, 'rev_comment', [
297 'temp_rev_comment' => 'revision_comment_temp',
298 'comment_rev_comment' => 'comment',
301 'rev_comment_text' => 'comment_rev_comment.comment_text',
302 'rev_comment_data' => 'comment_rev_comment.comment_data',
303 'rev_comment_cid' => 'comment_rev_comment.comment_id',
306 'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
307 'comment_rev_comment' => [ 'JOIN',
308 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
314 MIGRATION_OLD
, 'img_description', [
317 'img_description_text' => 'img_description',
318 'img_description_data' => 'NULL',
319 'img_description_cid' => 'NULL',
324 'Image, write-both' => [
325 MIGRATION_WRITE_BOTH
, 'img_description', [
327 'comment_img_description' => 'comment',
330 'img_description_text' => 'COALESCE( comment_img_description.comment_text, img_description )',
331 'img_description_data' => 'comment_img_description.comment_data',
332 'img_description_cid' => 'comment_img_description.comment_id',
335 'comment_img_description' => [ 'LEFT JOIN',
336 'comment_img_description.comment_id = img_description_id',
341 'Image, write-new' => [
342 MIGRATION_WRITE_NEW
, 'img_description', [
344 'comment_img_description' => 'comment',
347 'img_description_text' => 'COALESCE( comment_img_description.comment_text, img_description )',
348 'img_description_data' => 'comment_img_description.comment_data',
349 'img_description_cid' => 'comment_img_description.comment_id',
352 'comment_img_description' => [ 'LEFT JOIN',
353 'comment_img_description.comment_id = img_description_id',
359 MIGRATION_NEW
, 'img_description', [
361 'comment_img_description' => 'comment',
364 'img_description_text' => 'comment_img_description.comment_text',
365 'img_description_data' => 'comment_img_description.comment_data',
366 'img_description_cid' => 'comment_img_description.comment_id',
369 'comment_img_description' => [ 'JOIN',
370 'comment_img_description.comment_id = img_description_id',
378 private function assertComment( $expect, $actual, $from ) {
379 $this->assertSame( $expect['text'], $actual->text
, "text $from" );
380 $this->assertInstanceOf( get_class( $expect['message'] ), $actual->message
,
381 "message class $from" );
382 $this->assertSame( $expect['message']->getKeysToTry(), $actual->message
->getKeysToTry(),
383 "message keys $from" );
384 $this->assertEquals( $expect['message']->text(), $actual->message
->text(),
385 "message rendering $from" );
386 $this->assertEquals( $expect['data'], $actual->data
, "data $from" );
390 * @dataProvider provideInsertRoundTrip
391 * @param string $table
394 * @param string|Message $comment
395 * @param array|null $data
396 * @param array $expect
398 public function testInsertRoundTrip( $table, $key, $pk, $comment, $data, $expect ) {
402 'text' => $expect['text'],
403 'message' => new RawMessage( '$1', [ $expect['text'] ] ),
408 MIGRATION_OLD
=> [ MIGRATION_OLD
, MIGRATION_WRITE_BOTH
, MIGRATION_WRITE_NEW
],
409 MIGRATION_WRITE_BOTH
=> [ MIGRATION_OLD
, MIGRATION_WRITE_BOTH
, MIGRATION_WRITE_NEW
,
411 MIGRATION_WRITE_NEW
=> [ MIGRATION_WRITE_BOTH
, MIGRATION_WRITE_NEW
, MIGRATION_NEW
],
412 MIGRATION_NEW
=> [ MIGRATION_WRITE_BOTH
, MIGRATION_WRITE_NEW
, MIGRATION_NEW
],
415 foreach ( $stages as $writeStage => $possibleReadStages ) {
416 $wstore = $this->makeStore( $writeStage );
417 $usesTemp = $key === 'cs2_comment';
420 list( $fields, $callback ) = $wstore->insertWithTempTable(
421 $this->db
, $key, $comment, $data
424 $fields = $wstore->insert( $this->db
, $key, $comment, $data );
427 if ( $writeStage <= MIGRATION_WRITE_BOTH
) {
428 $this->assertSame( $expect['text'], $fields[$key], "old field, stage=$writeStage" );
430 $this->assertArrayNotHasKey( $key, $fields, "old field, stage=$writeStage" );
432 if ( $writeStage >= MIGRATION_WRITE_BOTH
&& !$usesTemp ) {
433 $this->assertArrayHasKey( "{$key}_id", $fields, "new field, stage=$writeStage" );
435 $this->assertArrayNotHasKey( "{$key}_id", $fields, "new field, stage=$writeStage" );
438 $this->db
->insert( $table, [ $pk => ++
$id ] +
$fields, __METHOD__
);
443 foreach ( $possibleReadStages as $readStage ) {
444 $rstore = $this->makeStore( $readStage );
446 $fieldRow = $this->db
->selectRow(
448 $rstore->getFields( $key ),
453 $queryInfo = $rstore->getJoin( $key );
454 $joinRow = $this->db
->selectRow(
455 [ $table ] +
$queryInfo['tables'],
456 $queryInfo['fields'],
463 $this->assertComment(
464 $writeStage === MIGRATION_OLD ||
$readStage === MIGRATION_OLD ?
$expectOld : $expect,
465 $rstore->getCommentLegacy( $this->db
, $key, $fieldRow ),
466 "w=$writeStage, r=$readStage, from getFields()"
468 $this->assertComment(
469 $writeStage === MIGRATION_OLD ||
$readStage === MIGRATION_OLD ?
$expectOld : $expect,
470 $rstore->getComment( $key, $joinRow ),
471 "w=$writeStage, r=$readStage, from getJoin()"
478 * @dataProvider provideInsertRoundTrip
479 * @param string $table
482 * @param string|Message $comment
483 * @param array|null $data
484 * @param array $expect
486 public function testInsertRoundTrip_withKeyConstruction(
487 $table, $key, $pk, $comment, $data, $expect
492 'text' => $expect['text'],
493 'message' => new RawMessage( '$1', [ $expect['text'] ] ),
498 MIGRATION_OLD
=> [ MIGRATION_OLD
, MIGRATION_WRITE_BOTH
, MIGRATION_WRITE_NEW
],
499 MIGRATION_WRITE_BOTH
=> [ MIGRATION_OLD
, MIGRATION_WRITE_BOTH
, MIGRATION_WRITE_NEW
,
501 MIGRATION_WRITE_NEW
=> [ MIGRATION_WRITE_BOTH
, MIGRATION_WRITE_NEW
, MIGRATION_NEW
],
502 MIGRATION_NEW
=> [ MIGRATION_WRITE_BOTH
, MIGRATION_WRITE_NEW
, MIGRATION_NEW
],
505 foreach ( $stages as $writeStage => $possibleReadStages ) {
506 $wstore = $this->makeStoreWithKey( $writeStage, $key );
507 $usesTemp = $key === 'cs2_comment';
510 list( $fields, $callback ) = $wstore->insertWithTempTable(
511 $this->db
, $comment, $data
514 $fields = $wstore->insert( $this->db
, $comment, $data );
517 if ( $writeStage <= MIGRATION_WRITE_BOTH
) {
518 $this->assertSame( $expect['text'], $fields[$key], "old field, stage=$writeStage" );
520 $this->assertArrayNotHasKey( $key, $fields, "old field, stage=$writeStage" );
522 if ( $writeStage >= MIGRATION_WRITE_BOTH
&& !$usesTemp ) {
523 $this->assertArrayHasKey( "{$key}_id", $fields, "new field, stage=$writeStage" );
525 $this->assertArrayNotHasKey( "{$key}_id", $fields, "new field, stage=$writeStage" );
528 $this->db
->insert( $table, [ $pk => ++
$id ] +
$fields, __METHOD__
);
533 foreach ( $possibleReadStages as $readStage ) {
534 $rstore = $this->makeStoreWithKey( $readStage, $key );
536 $fieldRow = $this->db
->selectRow(
538 $rstore->getFields(),
543 $queryInfo = $rstore->getJoin();
544 $joinRow = $this->db
->selectRow(
545 [ $table ] +
$queryInfo['tables'],
546 $queryInfo['fields'],
553 $this->assertComment(
554 $writeStage === MIGRATION_OLD ||
$readStage === MIGRATION_OLD ?
$expectOld : $expect,
555 $rstore->getCommentLegacy( $this->db
, $fieldRow ),
556 "w=$writeStage, r=$readStage, from getFields()"
558 $this->assertComment(
559 $writeStage === MIGRATION_OLD ||
$readStage === MIGRATION_OLD ?
$expectOld : $expect,
560 $rstore->getComment( $joinRow ),
561 "w=$writeStage, r=$readStage, from getJoin()"
567 public static function provideInsertRoundTrip() {
568 $db = wfGetDB( DB_REPLICA
); // for timestamps
570 $msgComment = new Message( 'parentheses', [ 'message comment' ] );
571 $textCommentMsg = new RawMessage( '$1', [ 'text comment' ] );
572 $nestedMsgComment = new Message( [ 'parentheses', 'rawmessage' ], [ new Message( 'mainpage' ) ] );
573 $comStoreComment = new CommentStoreComment(
574 null, 'comment store comment', null, [ 'foo' => 'bar' ]
578 'Simple table, text comment' => [
579 'commentstore1', 'cs1_comment', 'cs1_id', 'text comment', null, [
580 'text' => 'text comment',
581 'message' => $textCommentMsg,
585 'Simple table, text comment with data' => [
586 'commentstore1', 'cs1_comment', 'cs1_id', 'text comment', [ 'message' => 42 ], [
587 'text' => 'text comment',
588 'message' => $textCommentMsg,
589 'data' => [ 'message' => 42 ],
592 'Simple table, message comment' => [
593 'commentstore1', 'cs1_comment', 'cs1_id', $msgComment, null, [
594 'text' => '(message comment)',
595 'message' => $msgComment,
599 'Simple table, message comment with data' => [
600 'commentstore1', 'cs1_comment', 'cs1_id', $msgComment, [ 'message' => 42 ], [
601 'text' => '(message comment)',
602 'message' => $msgComment,
603 'data' => [ 'message' => 42 ],
606 'Simple table, nested message comment' => [
607 'commentstore1', 'cs1_comment', 'cs1_id', $nestedMsgComment, null, [
608 'text' => '(Main Page)',
609 'message' => $nestedMsgComment,
613 'Simple table, CommentStoreComment' => [
614 'commentstore1', 'cs1_comment', 'cs1_id', clone $comStoreComment, [ 'baz' => 'baz' ], [
615 'text' => 'comment store comment',
616 'message' => $comStoreComment->message
,
617 'data' => [ 'foo' => 'bar' ],
621 'Revision, text comment' => [
622 'commentstore2', 'cs2_comment', 'cs2_id', 'text comment', null, [
623 'text' => 'text comment',
624 'message' => $textCommentMsg,
628 'Revision, text comment with data' => [
629 'commentstore2', 'cs2_comment', 'cs2_id', 'text comment', [ 'message' => 42 ], [
630 'text' => 'text comment',
631 'message' => $textCommentMsg,
632 'data' => [ 'message' => 42 ],
635 'Revision, message comment' => [
636 'commentstore2', 'cs2_comment', 'cs2_id', $msgComment, null, [
637 'text' => '(message comment)',
638 'message' => $msgComment,
642 'Revision, message comment with data' => [
643 'commentstore2', 'cs2_comment', 'cs2_id', $msgComment, [ 'message' => 42 ], [
644 'text' => '(message comment)',
645 'message' => $msgComment,
646 'data' => [ 'message' => 42 ],
649 'Revision, nested message comment' => [
650 'commentstore2', 'cs2_comment', 'cs2_id', $nestedMsgComment, null, [
651 'text' => '(Main Page)',
652 'message' => $nestedMsgComment,
656 'Revision, CommentStoreComment' => [
657 'commentstore2', 'cs2_comment', 'cs2_id', clone $comStoreComment, [ 'baz' => 'baz' ], [
658 'text' => 'comment store comment',
659 'message' => $comStoreComment->message
,
660 'data' => [ 'foo' => 'bar' ],
666 public function testGetCommentErrors() {
667 Wikimedia\
suppressWarnings();
668 $reset = new ScopedCallback( 'Wikimedia\restoreWarnings' );
670 $store = $this->makeStore( MIGRATION_OLD
);
671 $res = $store->getComment( 'dummy', [ 'dummy' => 'comment' ] );
672 $this->assertSame( '', $res->text
);
673 $res = $store->getComment( 'dummy', [ 'dummy' => 'comment' ], true );
674 $this->assertSame( 'comment', $res->text
);
676 $store = $this->makeStore( MIGRATION_NEW
);
678 $store->getComment( 'dummy', [ 'dummy' => 'comment' ] );
679 $this->fail( 'Expected exception not thrown' );
680 } catch ( InvalidArgumentException
$ex ) {
681 $this->assertSame( '$row does not contain fields needed for comment dummy', $ex->getMessage() );
683 $res = $store->getComment( 'dummy', [ 'dummy' => 'comment' ], true );
684 $this->assertSame( 'comment', $res->text
);
686 $store->getComment( 'dummy', [ 'dummy_id' => 1 ] );
687 $this->fail( 'Expected exception not thrown' );
688 } catch ( InvalidArgumentException
$ex ) {
690 '$row does not contain fields needed for comment dummy and getComment(), '
691 . 'but does have fields for getCommentLegacy()',
696 $store = $this->makeStore( MIGRATION_NEW
);
698 $store->getComment( 'rev_comment', [ 'rev_comment' => 'comment' ] );
699 $this->fail( 'Expected exception not thrown' );
700 } catch ( InvalidArgumentException
$ex ) {
702 '$row does not contain fields needed for comment rev_comment', $ex->getMessage()
705 $res = $store->getComment( 'rev_comment', [ 'rev_comment' => 'comment' ], true );
706 $this->assertSame( 'comment', $res->text
);
708 $store->getComment( 'rev_comment', [ 'rev_comment_pk' => 1 ] );
709 $this->fail( 'Expected exception not thrown' );
710 } catch ( InvalidArgumentException
$ex ) {
712 '$row does not contain fields needed for comment rev_comment and getComment(), '
713 . 'but does have fields for getCommentLegacy()',
719 public static function provideStages() {
721 'MIGRATION_OLD' => [ MIGRATION_OLD
],
722 'MIGRATION_WRITE_BOTH' => [ MIGRATION_WRITE_BOTH
],
723 'MIGRATION_WRITE_NEW' => [ MIGRATION_WRITE_NEW
],
724 'MIGRATION_NEW' => [ MIGRATION_NEW
],
729 * @dataProvider provideStages
731 * @expectedException InvalidArgumentException
732 * @expectedExceptionMessage Must use insertWithTempTable() for rev_comment
734 public function testInsertWrong( $stage ) {
735 $store = $this->makeStore( $stage );
736 $store->insert( $this->db
, 'rev_comment', 'foo' );
740 * @dataProvider provideStages
742 * @expectedException InvalidArgumentException
743 * @expectedExceptionMessage Must use insert() for ipb_reason
745 public function testInsertWithTempTableWrong( $stage ) {
746 $store = $this->makeStore( $stage );
747 $store->insertWithTempTable( $this->db
, 'ipb_reason', 'foo' );
751 * @dataProvider provideStages
754 public function testInsertWithTempTableDeprecated( $stage ) {
755 $store = $this->makeStore( $stage );
756 $wrap = TestingAccessWrapper
::newFromObject( $store );
757 $wrap->tempTables +
= [ 'ipb_reason' => [
758 'stage' => MIGRATION_NEW
,
759 'deprecatedIn' => '1.30',
762 $this->hideDeprecated( 'CommentStore::insertWithTempTable for ipb_reason' );
763 list( $fields, $callback ) = $store->insertWithTempTable( $this->db
, 'ipb_reason', 'foo' );
764 $this->assertTrue( is_callable( $callback ) );
767 public function testInsertTruncation() {
768 $comment = str_repeat( '💣', 16400 );
769 $truncated1 = str_repeat( '💣', 63 ) . '...';
770 $truncated2 = str_repeat( '💣', CommentStore
::COMMENT_CHARACTER_LIMIT
- 3 ) . '...';
772 $store = $this->makeStore( MIGRATION_WRITE_BOTH
);
773 $fields = $store->insert( $this->db
, 'ipb_reason', $comment );
774 $this->assertSame( $truncated1, $fields['ipb_reason'] );
775 $stored = $this->db
->selectField(
776 'comment', 'comment_text', [ 'comment_id' => $fields['ipb_reason_id'] ], __METHOD__
778 $this->assertSame( $truncated2, $stored );
782 * @expectedException OverflowException
783 * @expectedExceptionMessage Comment data is too long (65611 bytes, maximum is 65535)
785 public function testInsertTooMuchData() {
786 $store = $this->makeStore( MIGRATION_WRITE_BOTH
);
787 $store->insert( $this->db
, 'ipb_reason', 'foo', [
788 'long' => str_repeat( '💣', 16400 )
792 public function testGetStore() {
793 $this->assertInstanceOf( CommentStore
::class, CommentStore
::getStore() );
796 public function testNewKey() {
797 $this->hideDeprecated( 'CommentStore::newKey' );
798 $this->assertInstanceOf( CommentStore
::class, CommentStore
::newKey( 'dummy' ) );