X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FPageArchiveTest.php;h=15b26c23e65779249a08932d9ed902df26f5bef8;hp=28991a0a670ef033b12833d96f1032a07bae61df;hb=dbad540cd37617879aff6f28ce9c016dd8049d4e;hpb=96188af6dbb48a4b930c8741bcd5787534e1cb05 diff --git a/tests/phpunit/includes/PageArchiveTest.php b/tests/phpunit/includes/PageArchiveTest.php index 28991a0a67..15b26c23e6 100644 --- a/tests/phpunit/includes/PageArchiveTest.php +++ b/tests/phpunit/includes/PageArchiveTest.php @@ -79,6 +79,7 @@ class PageArchiveTest extends MediaWikiTestCase { /** * @covers PageArchive::undelete + * @covers PageArchive::undeleteRevisions */ public function testUndeleteRevisions() { // First make sure old revisions are archived @@ -141,6 +142,12 @@ class PageArchiveTest extends MediaWikiTestCase { 'ar_content_format' => null, 'ar_content_model' => null, 'ts_tags' => null, + 'ar_id' => '2', + 'ar_namespace' => '0', + 'ar_title' => 'PageArchiveTest_thePage', + 'ar_text' => '', + 'ar_text_id' => '3', + 'ar_parent_id' => '2', ], $row1 ); @@ -160,9 +167,76 @@ class PageArchiveTest extends MediaWikiTestCase { 'ar_content_format' => null, 'ar_content_model' => null, 'ts_tags' => null, + 'ar_id' => '1', + 'ar_namespace' => '0', + 'ar_title' => 'PageArchiveTest_thePage', + 'ar_text' => '', + 'ar_text_id' => '2', + 'ar_parent_id' => '0', ], $row2 ); } + /** + * @covers PageArchive::listPagesBySearch + */ + public function testListPagesBySearch() { + $pages = PageArchive::listPagesBySearch( 'PageArchiveTest_thePage' ); + $this->assertSame( 1, $pages->numRows() ); + + $page = (array)$pages->current(); + + $this->assertSame( + [ + 'ar_namespace' => '0', + 'ar_title' => 'PageArchiveTest_thePage', + 'count' => '2', + ], + $page + ); + } + + /** + * @covers PageArchive::listPagesBySearch + */ + public function testListPagesByPrefix() { + $pages = PageArchive::listPagesByPrefix( 'PageArchiveTest' ); + $this->assertSame( 1, $pages->numRows() ); + + $page = (array)$pages->current(); + + $this->assertSame( + [ + 'ar_namespace' => '0', + 'ar_title' => 'PageArchiveTest_thePage', + 'count' => '2', + ], + $page + ); + } + + /** + * @covers PageArchive::getTextFromRow + */ + public function testGetTextFromRow() { + $row = (object)[ 'ar_text_id' => 2 ]; + $text = $this->archivedPage->getTextFromRow( $row ); + $this->assertSame( 'testing', $text ); + } + + /** + * @covers PageArchive::getLastRevisionText + */ + public function testGetLastRevisionText() { + $text = $this->archivedPage->getLastRevisionText(); + $this->assertSame( 'Lorem Ipsum', $text ); + } + + /** + * @covers PageArchive::isDeleted + */ + public function testIsDeleted() { + $this->assertTrue( $this->archivedPage->isDeleted() ); + } }