X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FCommentStoreTest.php;h=9369f3062929c35f0babb6a68a4563973d4087bf;hb=125f9e1ab4cc50c5b7ca8b232f5035608b3dc798;hp=4e0210a5438fe312f80c4b504f75afef22a24b2d;hpb=98514de508e8d2f5094c8c4b9d24063060d4ef58;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/CommentStoreTest.php b/tests/phpunit/includes/CommentStoreTest.php index 4e0210a543..9369f30629 100644 --- a/tests/phpunit/includes/CommentStoreTest.php +++ b/tests/phpunit/includes/CommentStoreTest.php @@ -615,6 +615,31 @@ class CommentStoreTest extends MediaWikiLangTestCase { $this->assertTrue( is_callable( $callback ) ); } + public function testInsertTruncation() { + $comment = str_repeat( '💣', 16400 ); + $truncated1 = str_repeat( '💣', 63 ) . '...'; + $truncated2 = str_repeat( '💣', CommentStore::COMMENT_CHARACTER_LIMIT - 3 ) . '...'; + + $store = $this->makeStore( MIGRATION_WRITE_BOTH, 'ipb_reason' ); + $fields = $store->insert( $this->db, $comment ); + $this->assertSame( $truncated1, $fields['ipb_reason'] ); + $stored = $this->db->selectField( + 'comment', 'comment_text', [ 'comment_id' => $fields['ipb_reason_id'] ], __METHOD__ + ); + $this->assertSame( $truncated2, $stored ); + } + + /** + * @expectedException OverflowException + * @expectedExceptionMessage Comment data is too long (65611 bytes, maximum is 65535) + */ + public function testInsertTooMuchData() { + $store = $this->makeStore( MIGRATION_WRITE_BOTH, 'ipb_reason' ); + $store->insert( $this->db, 'foo', [ + 'long' => str_repeat( '💣', 16400 ) + ] ); + } + public function testConstructor() { $this->assertInstanceOf( CommentStore::class, CommentStore::newKey( 'dummy' ) ); }