Tpt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371469 )

Change subject: Makes unit test namespace ids independent
......................................................................

Makes unit test namespace ids independent

Change-Id: I2b64e6a2725992ce1524b3c73479f12b351e2d91
---
M tests/phpunit/FileProviderTest.php
M tests/phpunit/Pagination/FilePaginationTest.php
M tests/phpunit/Pagination/PagePaginationTest.php
M tests/phpunit/Pagination/PaginationFactoryTest.php
M tests/phpunit/ProofreadPageTestCase.php
M tests/phpunit/index/IndexContentTest.php
M tests/phpunit/index/IndexRedirectContentTest.php
M tests/phpunit/index/ProofreadIndexPageTest.php
M tests/phpunit/page/PageContentBuilderTest.php
M tests/phpunit/page/PageContentTest.php
M tests/phpunit/page/PageDisplayHandlerTest.php
M tests/phpunit/page/ProofreadPagePageTest.php
12 files changed, 123 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/69/371469/1

diff --git a/tests/phpunit/FileProviderTest.php 
b/tests/phpunit/FileProviderTest.php
index 3ebcdf4..85d5786 100644
--- a/tests/phpunit/FileProviderTest.php
+++ b/tests/phpunit/FileProviderTest.php
@@ -37,7 +37,7 @@
 
                return [
                        [
-                               ProofreadIndexPage::newFromTitle( 
Title::makeTitle( 252, 'LoremIpsum.djvu' ) ),
+                               $this->newIndexPage( 'LoremIpsum.djvu' ),
                                $this->getFileFromName( 'LoremIpsum.djvu' ),
                                $fileProvider
                        ],
@@ -62,11 +62,11 @@
 
                return [
                        [
-                               ProofreadIndexPage::newFromTitle( 
Title::makeTitle( 252, 'LoremIpsum2.djvu' ) ),
+                               $this->newIndexPage( 'LoremIpsum2.djvu' ),
                                $fileProvider
                        ],
                        [
-                               ProofreadIndexPage::newFromTitle( 
Title::makeTitle( 252, 'Test' ) ),
+                               $this->newIndexPage( 'Test' ),
                                $fileProvider
                        ],
                ];
@@ -89,24 +89,22 @@
 
                return [
                        [
-                               ProofreadPagePage::newFromTitle( 
Title::makeTitle( 250, 'LoremIpsum.djvu/4' ) ),
+                               $this->newPagePage( 'LoremIpsum.djvu/4' ),
                                $this->getFileFromName( 'LoremIpsum.djvu' ),
                                $fileProvider
                        ],
                        [
-                               ProofreadPagePage::newFromTitle(
-                                       Title::makeTitle( 250, 
'LoremIpsum.djvu/djvu/1' )
-                               ),
+                               $this->newPagePage( 'LoremIpsum.djvu/djvu/1' ),
                                $this->getFileFromName( 'LoremIpsum.djvu' ),
                                $fileProvider
                        ],
                        [
-                               ProofreadPagePage::newFromTitle( 
Title::makeTitle( 250, 'LoremIpsum.djvu' ) ),
+                               $this->newPagePage( 'LoremIpsum.djvu' ),
                                $this->getFileFromName( 'LoremIpsum.djvu' ),
                                $fileProvider
                        ],
                        [
-                               ProofreadPagePage::newFromTitle( 
Title::makeTitle( 250, 'Test.jpg' ) ),
+                               $this->newPagePage( 'Test.jpg' ),
                                $this->getFileFromName( 'Test.jpg' ),
                                $fileProvider
                        ],
@@ -131,11 +129,11 @@
 
                return [
                        [
-                               ProofreadPagePage::newFromTitle( 
Title::makeTitle( 252, 'LoremIpsum2.djvu/4' ) ),
+                               $this->newPagePage( 'LoremIpsum2.djvu/4' ),
                                $fileProvider
                        ],
                        [
-                               ProofreadPagePage::newFromTitle( 
Title::makeTitle( 252, 'Test' ) ),
+                               $this->newPagePage( 'Test' ),
                                $fileProvider
                        ],
                ];
diff --git a/tests/phpunit/Pagination/FilePaginationTest.php 
b/tests/phpunit/Pagination/FilePaginationTest.php
index b17be7f..dadd19a 100644
--- a/tests/phpunit/Pagination/FilePaginationTest.php
+++ b/tests/phpunit/Pagination/FilePaginationTest.php
@@ -5,7 +5,6 @@
 use InvalidArgumentException;
 use MediaHandler;
 use OutOfBoundsException;
-use ProofreadIndexPageTest;
 use ProofreadPagePage;
 use ProofreadPageTestCase;
 use Title;
@@ -17,7 +16,7 @@
 class FilePaginationTest extends ProofreadPageTestCase {
 
        public function testGetPageNumber() {
-               $index = ProofreadIndexPageTest::newIndexPage( 
'LoremIpsum.djvu' );
+               $index = $this->newIndexPage( 'LoremIpsum.djvu' );
                $pagination = new FilePagination(
                        $index,
                        new PageList( [] ),
@@ -27,7 +26,7 @@
                        $this->getContext()
                );
                $this->assertEquals( 2, $pagination->getPageNumber(
-                       new ProofreadPagePage( Title::makeTitle( 250, 
'LoremIpsum.djvu/2' ), $index )
+                       $this->newPagePage( 'LoremIpsum.djvu/2', $index )
                ) );
        }
 
@@ -42,7 +41,7 @@
        }
 
        public function getPageNumberWithFailureProvider() {
-               $index = ProofreadIndexPageTest::newIndexPage( 
'LoremIpsum.djvu' );
+               $index = $this->newIndexPage( 'LoremIpsum.djvu' );
                $pagination = new FilePagination(
                        $index, new PageList( [] ),
                        
$this->getContext()->getFileProvider()->getFileFromTitle(
@@ -53,15 +52,15 @@
                return [
                        [
                                $pagination,
-                               new ProofreadPagePage( Title::makeTitle( 250, 
'Test.djvu/2' ) )
+                               $this->newPagePage( 'Test.djvu/2' )
                        ],
                        [
                                $pagination,
-                               new ProofreadPagePage( Title::makeTitle( 250, 
'Test2.djvu/2' ) )
+                               $this->newPagePage( 'Test2.djvu/2' )
                        ],
                        [
                                $pagination,
-                               new ProofreadPagePage( Title::makeTitle( 250, 
'42.jpg' ), $index )
+                               $this->newPagePage( '42.jpg' )
                        ],
                ];
        }
@@ -70,7 +69,7 @@
                if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) {
                        $this->markTestSkipped( 'There is no support for DjVu 
files, please enable it.' );
                }
-               $index = ProofreadIndexPageTest::newIndexPage( 
'LoremIpsum.djvu' );
+               $index = $this->newIndexPage( 'LoremIpsum.djvu' );
                $pageNumber = new PageNumber( 'TOC' );
                $pagination = new FilePagination(
                        $index, new PageList( [ '1' => 'TOC' ] ),
@@ -86,7 +85,7 @@
                if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) {
                        $this->markTestSkipped( 'There is no support for DjVu 
files, please enable it.' );
                }
-               $index = ProofreadIndexPageTest::newIndexPage( 
'LoremIpsum.djvu' );
+               $index = $this->newIndexPage( 'LoremIpsum.djvu' );
                $pageNumber = new PageNumber( 1 );
                $pagination = new FilePagination(
                        $index, new PageList( [] ),
@@ -102,7 +101,7 @@
         * @expectedException OutOfBoundsException
         */
        public function testGetDisplayedPageNumberWithFailure() {
-               $index = ProofreadIndexPageTest::newIndexPage();
+               $index = $this->newIndexPage();
                $pagination = new PagePagination( $index, [], [] );
                $pagination->getDisplayedPageNumber( 3 );
        }
@@ -111,7 +110,7 @@
                if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) {
                        $this->markTestSkipped( 'There is no support for DjVu 
files, please enable it.' );
                }
-               $index = ProofreadIndexPageTest::newIndexPage( 
'LoremIpsum.djvu' );
+               $index = $this->newIndexPage( 'LoremIpsum.djvu' );
                $pagination = new FilePagination(
                        $index, new PageList( [] ),
                        
$this->getContext()->getFileProvider()->getFileFromTitle(
@@ -126,8 +125,8 @@
                if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) {
                        $this->markTestSkipped( 'There is no support for DjVu 
files, please enable it.' );
                }
-               $index = ProofreadIndexPageTest::newIndexPage( 
'LoremIpsum.djvu' );
-               $page = new ProofreadPagePage( Title::makeTitle( 250, 
'LoremIpsum.djvu/2' ), $index );
+               $index = $this->newIndexPage( 'LoremIpsum.djvu' );
+               $page = $this->newPagePage( 'LoremIpsum.djvu/2', $index );
                $pagination = new FilePagination(
                        $index, new PageList( [] ),
                        
$this->getContext()->getFileProvider()->getFileFromTitle(
@@ -145,7 +144,7 @@
                if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) {
                        $this->markTestSkipped( 'There is no support for DjVu 
files, please enable it.' );
                }
-               $index = ProofreadIndexPageTest::newIndexPage( 
'LoremIpsum.djvu' );
+               $index = $this->newIndexPage( 'LoremIpsum.djvu' );
                $pagination = new FilePagination(
                        $index, new PageList( [] ),
                        
$this->getContext()->getFileProvider()->getFileFromTitle(
@@ -160,9 +159,9 @@
                if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) {
                        $this->markTestSkipped( 'There is no support for DjVu 
files, please enable it.' );
                }
-               $index = ProofreadIndexPageTest::newIndexPage( 
'LoremIpsum.djvu' );
-               $page1 = new ProofreadPagePage( Title::makeTitle( 250, 
'LoremIpsum.djvu/1' ), $index );
-               $page2 = new ProofreadPagePage( Title::makeTitle( 250, 
'LoremIpsum.djvu/2' ), $index );
+               $index = $this->newIndexPage( 'LoremIpsum.djvu' );
+               $page1 = $this->newPagePage( 'LoremIpsum.djvu/1', $index );
+               $page2 = $this->newPagePage( 'LoremIpsum.djvu/2', $index );
                $pagination = new FilePagination(
                        $index, new PageList( [] ),
                        
$this->getContext()->getFileProvider()->getFileFromTitle(
diff --git a/tests/phpunit/Pagination/PagePaginationTest.php 
b/tests/phpunit/Pagination/PagePaginationTest.php
index 5e46275..677e8cc 100644
--- a/tests/phpunit/Pagination/PagePaginationTest.php
+++ b/tests/phpunit/Pagination/PagePaginationTest.php
@@ -4,7 +4,6 @@
 
 use InvalidArgumentException;
 use OutOfBoundsException;
-use ProofreadIndexPageTest;
 use ProofreadPagePage;
 use ProofreadPageTestCase;
 use Title;
@@ -16,7 +15,7 @@
 class PagePaginationTest extends ProofreadPageTestCase {
 
        public function testGetPageNumber() {
-               $index = ProofreadIndexPageTest::newIndexPage();
+               $index = $this->newIndexPage();
                $page = new ProofreadPagePage( Title::newFromText( 'Page:Test 
2.tiff' ), $index );
                $pagination = new PagePagination(
                        $index,
@@ -40,7 +39,7 @@
         * @expectedException InvalidArgumentException
         */
        public function testGetPageNumberWithFailure() {
-               $index = ProofreadIndexPageTest::newIndexPage();
+               $index = $this->newIndexPage();
                $pagination = new PagePagination( $index, [], [] );
                $pagination->getPageNumber(
                        new ProofreadPagePage( Title::newFromText( 'Page:Test 
2.tiff' ), $index )
@@ -48,7 +47,7 @@
        }
 
        public function testGetDisplayedPageNumber() {
-               $index = ProofreadIndexPageTest::newIndexPage();
+               $index = $this->newIndexPage();
                $pageNumber = new PageNumber( 'TOC' );
                $pagination = new PagePagination(
                        $index,
@@ -62,13 +61,13 @@
         * @expectedException OutOfBoundsException
         */
        public function testGetDisplayedPageNumberWithFailure() {
-               $index = ProofreadIndexPageTest::newIndexPage();
+               $index = $this->newIndexPage();
                $pagination = new PagePagination( $index, [], [] );
                $pagination->getDisplayedPageNumber( 3 );
        }
 
        public function testGetNumberOfPages() {
-               $index = ProofreadIndexPageTest::newIndexPage();
+               $index = $this->newIndexPage();
                $pagination = new PagePagination(
                        $index,
                        [
@@ -86,7 +85,7 @@
        }
 
        public function testGetPage() {
-               $index = ProofreadIndexPageTest::newIndexPage();
+               $index = $this->newIndexPage();
                $page = new ProofreadPagePage( Title::newFromText( 'Page:Test 
1.jpg' ), $index );
                $pagination = new PagePagination(
                        $index,
@@ -108,13 +107,13 @@
         * @expectedException OutOfBoundsException
         */
        public function testGetPageWithFailure() {
-               $index = ProofreadIndexPageTest::newIndexPage();
+               $index = $this->newIndexPage();
                $pagination = new PagePagination( $index, [], [] );
                $pagination->getPage( 3 );
        }
 
        public function testIterator() {
-               $index = ProofreadIndexPageTest::newIndexPage();
+               $index = $this->newIndexPage();
                $page1 = new ProofreadPagePage( Title::newFromText( 'Page:Test 
1.jpg' ), $index );
                $page2 = new ProofreadPagePage( Title::newFromText( 'Page:Test 
2.jpg' ), $index );
                $pagination = new PagePagination(
diff --git a/tests/phpunit/Pagination/PaginationFactoryTest.php 
b/tests/phpunit/Pagination/PaginationFactoryTest.php
index 752a5f0..ddf0627 100644
--- a/tests/phpunit/Pagination/PaginationFactoryTest.php
+++ b/tests/phpunit/Pagination/PaginationFactoryTest.php
@@ -3,7 +3,6 @@
 namespace ProofreadPage\Pagination;
 
 use MediaHandler;
-use ProofreadIndexPageTest;
 use ProofreadPagePage;
 use ProofreadPageTestCase;
 use Title;
@@ -18,7 +17,7 @@
                if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) {
                        $this->markTestSkipped( 'There is no support for DjVu 
files, please enable it.' );
                }
-               $page = ProofreadIndexPageTest::newIndexPage(
+               $page = $this->newIndexPage(
                        'LoremIpsum.djvu',
                        "{{\n|Pages=<pagelist 1to2=-/> <pagelist 3=1 4to5=roman 
/>\n|Author=[[Author:Me]]\n}}"
                );
@@ -38,7 +37,7 @@
        }
 
        public function testGetPaginationWithoutPagelist() {
-               $page = ProofreadIndexPageTest::newIndexPage(
+               $page = $this->newIndexPage(
                        'Test',
                        "{{\n|Pages=[[Page:Test 1.jpg|TOC]] [[Page:Test 
2.tiff|1]] " .
                        "[[Page:Test:3.png|2]]\n|Author=[[Author:Me]]\n}}"
diff --git a/tests/phpunit/ProofreadPageTestCase.php 
b/tests/phpunit/ProofreadPageTestCase.php
index cb23d43..03d3e3f 100644
--- a/tests/phpunit/ProofreadPageTestCase.php
+++ b/tests/phpunit/ProofreadPageTestCase.php
@@ -4,6 +4,9 @@
 use ProofreadPage\FileProvider;
 use ProofreadPage\FileProviderMock;
 use ProofreadPage\Index\CustomIndexFieldsParser;
+use ProofreadPage\Index\IndexContent;
+use ProofreadPage\Page\PageContent;
+use ProofreadPage\ProofreadPageInit;
 
 /**
  * @group ProofreadPage
@@ -89,13 +92,9 @@
        private $context;
 
        protected function setUp() {
-               global $wgProofreadPageNamespaceIds, $wgNamespacesWithSubpages;
                parent::setUp();
 
-               $wgProofreadPageNamespaceIds = [
-                       'page' => 250,
-                       'index' => 252
-               ];
+               global $wgNamespacesWithSubpages;
                $wgNamespacesWithSubpages[NS_MAIN] = true;
        }
 
@@ -105,8 +104,8 @@
        protected function getContext() {
                if ( $this->context === null ) {
                        $this->context = new Context(
-                               250,
-                               252,
+                               ProofreadPageInit::getNamespaceId( 'page' ),
+                               ProofreadPageInit::getNamespaceId( 'index' ),
                                $this->getFileProvider(),
                                new CustomIndexFieldsParser( 
self::$customIndexFieldsConfiguration )
                        );
@@ -116,6 +115,51 @@
        }
 
        /**
+        * Constructor of a new ProofreadPagePage
+        * @param Title|string $title
+        * @param PageContent|null $content
+        * @param ProofreadIndexPage|null $index
+        * @return ProofreadPagePage
+        */
+       public function newPagePage( $title = 'test.jpg', ProofreadIndexPage 
$index = null ) {
+               if ( is_string( $title ) ) {
+                       $title = Title::makeTitle( $this->getPageNamespaceId(), 
$title );
+               }
+               return new ProofreadPagePage( $title, $index );
+       }
+
+       /**
+        * Constructor of a new ProofreadIndexPage
+        * @param Title|string $title
+        * @param string|IndexContent|null $content
+        * @return ProofreadIndexPage
+        */
+       protected function newIndexPage( $title = 'test.djvu', $content = null 
) {
+               if ( is_string( $title ) ) {
+                       $title = Title::makeTitle( 
$this->getIndexNamespaceId(), $title );
+               }
+               if ( is_string( $content ) ) {
+                       $content = ContentHandler::getForModelID( 
CONTENT_MODEL_PROOFREAD_INDEX )
+                               ->unserializeContent( $content );
+               }
+               return new ProofreadIndexPage( $title, $content );
+       }
+
+       /**
+        * @return int
+        */
+       protected function getPageNamespaceId() {
+               return $this->getContext()->getPageNamespaceId();
+       }
+
+       /**
+        * @return int
+        */
+       protected function getIndexNamespaceId() {
+               return $this->getContext()->getIndexNamespaceId();
+       }
+
+       /**
         * Returns a FileProvider that use files puts in data/media
         *
         * @return FileProvider
diff --git a/tests/phpunit/index/IndexContentTest.php 
b/tests/phpunit/index/IndexContentTest.php
index 3dd0172..0fcb50f 100644
--- a/tests/phpunit/index/IndexContentTest.php
+++ b/tests/phpunit/index/IndexContentTest.php
@@ -28,7 +28,7 @@
                parent::setUp();
 
                $this->requestContext = new RequestContext( new FauxRequest() );
-               $this->requestContext->setTitle( Title::makeTitle( 252, 
'Test.pdf' ) );
+               $this->requestContext->setTitle( Title::makeTitle( 
$this->getIndexNamespaceId(), 'Test.pdf' ) );
                $this->requestContext->setUser( new User() );
        }
 
@@ -218,7 +218,7 @@
                        $links,
                        $content->getLinksToNamespace(
                                
Context::getDefaultContext()->getPageNamespaceId(),
-                               Title::makeTitle( 252, 'Test' )
+                               Title::makeTitle( $this->getIndexNamespaceId(), 
'Test' )
                        )
                );
        }
diff --git a/tests/phpunit/index/IndexRedirectContentTest.php 
b/tests/phpunit/index/IndexRedirectContentTest.php
index 27faf20..5969f5b 100644
--- a/tests/phpunit/index/IndexRedirectContentTest.php
+++ b/tests/phpunit/index/IndexRedirectContentTest.php
@@ -24,7 +24,7 @@
                parent::setUp();
 
                $this->requestContext = new RequestContext( new FauxRequest() );
-               $this->requestContext->setTitle( Title::makeTitle( 252, 
'Test.pdf' ) );
+               $this->requestContext->setTitle( Title::makeTitle( 
$this->getIndexNamespaceId(), 'Test.pdf' ) );
                $this->requestContext->setUser( new User() );
        }
 
diff --git a/tests/phpunit/index/ProofreadIndexPageTest.php 
b/tests/phpunit/index/ProofreadIndexPageTest.php
index a8c9f15..416170e 100644
--- a/tests/phpunit/index/ProofreadIndexPageTest.php
+++ b/tests/phpunit/index/ProofreadIndexPageTest.php
@@ -1,35 +1,15 @@
 <?php
 
-use ProofreadPage\Index\CustomIndexField;
-use ProofreadPage\Index\IndexContent;
-
 /**
  * @group ProofreadPage
  * @covers ProofreadIndexPage
  */
 class ProofreadIndexPageTest extends ProofreadPageTestCase {
 
-       /**
-        * Constructor of a new ProofreadIndexPage
-        * @param Title|string $title
-        * @param string|IndexContent|null $content
-        * @return ProofreadIndexPage
-        */
-       public static function newIndexPage( $title = 'test.djvu', $content = 
null ) {
-               if ( is_string( $title ) ) {
-                       $title = Title::makeTitle( 252, $title );
-               }
-               if ( is_string( $content ) ) {
-                       $content = ContentHandler::getForModelID( 
CONTENT_MODEL_PROOFREAD_INDEX )
-                               ->unserializeContent( $content );
-               }
-               return new ProofreadIndexPage( $title, $content );
-       }
-
        public function testEquals() {
-               $page = self::newIndexPage( 'Test.djvu' );
-               $page2 = self::newIndexPage( 'Test.djvu' );
-               $page3 = self::newIndexPage( 'Test2.djvu' );
+               $page = $this->newIndexPage( 'Test.djvu' );
+               $page2 = $this->newIndexPage( 'Test.djvu' );
+               $page3 = $this->newIndexPage( 'Test2.djvu' );
                $this->assertTrue( $page->equals( $page2 ) );
                $this->assertTrue( $page2->equals( $page ) );
                $this->assertFalse( $page->equals( $page3 ) );
@@ -37,7 +17,7 @@
        }
 
        public function testGetTitle() {
-               $title = Title::makeTitle( 252, 'Test.djvu' );
+               $title = Title::makeTitle( $this->getIndexNamespaceId(), 
'Test.djvu' );
                $page = ProofreadIndexPage::newFromTitle( $title );
                $this->assertEquals( $title, $page->getTitle() );
        }
@@ -54,6 +34,6 @@
         * @dataProvider mimeTypesProvider
         */
        public function testGetMimeType( $mime, $name ) {
-               $this->assertEquals( $mime, self::newIndexPage( $name 
)->getMimeType() );
+               $this->assertEquals( $mime, $this->newIndexPage( $name 
)->getMimeType() );
        }
 }
diff --git a/tests/phpunit/page/PageContentBuilderTest.php 
b/tests/phpunit/page/PageContentBuilderTest.php
index c97d48e..8688f79 100644
--- a/tests/phpunit/page/PageContentBuilderTest.php
+++ b/tests/phpunit/page/PageContentBuilderTest.php
@@ -4,11 +4,9 @@
 
 use IContextSource;
 use MediaHandler;
-use ProofreadIndexPageTest;
-use ProofreadPagePage;
-use ProofreadPagePageTest;
-use ProofreadPageTestCase;
 use ProofreadPage\FileNotFoundException;
+use ProofreadPagePage;
+use ProofreadPageTestCase;
 use RequestContext;
 use User;
 
@@ -54,24 +52,24 @@
        public function buildDefaultContentForPageProvider() {
                return [
                        [
-                               ProofreadPagePageTest::newPagePage(
+                               $this->newPagePage(
                                        'Test.djvu/1',
-                                       ProofreadIndexPageTest::newIndexPage(
+                                       $this->newIndexPage(
                                                'Test.djvu', "{{\n|Title=Test 
book\n|Header={{{title}}}\n}}"
                                        )
                                ),
                                PageContentTest::newContent( 'Test book', '', 
'<references />', 1 ),
                        ],
                        [
-                               ProofreadPagePageTest::newPagePage(
+                               $this->newPagePage(
                                        'LoremIpsum.djvu/2'
                                ),
                                PageContentTest::newContent( '', "Lorem ipsum 
\n2 \n", '<references/>', 1 ),
                        ],
                        [
-                               ProofreadPagePageTest::newPagePage(
+                               $this->newPagePage(
                                        'LoremIpsum.djvu/2',
-                                       ProofreadIndexPageTest::newIndexPage(
+                                       $this->newIndexPage(
                                                'LoremIpsum.djvu',
                                                "{{\n|Title=Test 
book\n|Pages=<pagelist/>\n|Header={{{pagenum}}}\n}}"
                                        )
@@ -79,9 +77,9 @@
                                PageContentTest::newContent( '2', "Lorem ipsum 
\n2 \n", '<references />', 1 ),
                        ],
                        [
-                               ProofreadPagePageTest::newPagePage(
+                               $this->newPagePage(
                                        'LoremIpsum.djvu/2',
-                                       ProofreadIndexPageTest::newIndexPage(
+                                       $this->newIndexPage(
                                                'LoremIpsum.djvu',
                                                "{{\n|Title=Test 
book\n|Pages=<pagelist 1to5=roman />\n" .
                                                        
"|Header={{{pagenum}}}\n}}"
diff --git a/tests/phpunit/page/PageContentTest.php 
b/tests/phpunit/page/PageContentTest.php
index 75b342b..14894a8 100644
--- a/tests/phpunit/page/PageContentTest.php
+++ b/tests/phpunit/page/PageContentTest.php
@@ -36,7 +36,7 @@
                ] );
 
                $this->requestContext = new RequestContext( new FauxRequest() );
-               $this->requestContext->setTitle( Title::makeTitle( 250, 
'Test.jpg' ) );
+               $this->requestContext->setTitle( Title::makeTitle( 
$this->getPageNamespaceId(), 'Test.jpg' ) );
                $this->requestContext->setUser( $user );
        }
 
diff --git a/tests/phpunit/page/PageDisplayHandlerTest.php 
b/tests/phpunit/page/PageDisplayHandlerTest.php
index 6f975e8..9a0983a 100644
--- a/tests/phpunit/page/PageDisplayHandlerTest.php
+++ b/tests/phpunit/page/PageDisplayHandlerTest.php
@@ -2,8 +2,6 @@
 
 namespace ProofreadPage\Page;
 
-use ProofreadIndexPageTest;
-use ProofreadPagePageTest;
 use ProofreadPageTestCase;
 
 /**
@@ -15,32 +13,32 @@
        public function testGetImageWidth() {
                $handler = new PageDisplayHandler( $this->getContext() );
 
-               $index = ProofreadIndexPageTest::newIndexPage( 'Test', 
"{{\n|width= 500 \n}}" );
-               $page = ProofreadPagePageTest::newPagePage( 'Test.jpg', $index 
);
+               $index = $this->newIndexPage( 'Test', "{{\n|width= 500 \n}}" );
+               $page = $this->newPagePage( 'Test.jpg', $index );
                $this->assertEquals( 500, $handler->getImageWidth( $page ) );
 
-               $index = ProofreadIndexPageTest::newIndexPage( 'Test', 
"{{\n|title=500\n}}" );
-               $page = ProofreadPagePageTest::newPagePage( 'Test.jpg', $index 
);
+               $index = $this->newIndexPage( 'Test', "{{\n|title=500\n}}" );
+               $page = $this->newPagePage( 'Test.jpg', $index );
                $this->assertEquals( PageDisplayHandler::DEFAULT_IMAGE_WIDTH, 
$handler->getImageWidth( $page ) );
        }
 
        public function testGetCustomCss() {
                $handler = new PageDisplayHandler( $this->getContext() );
 
-               $index = ProofreadIndexPageTest::newIndexPage( 'Test', 
"{{\n|CSS= width:300px; \n}}" );
-               $page = ProofreadPagePageTest::newPagePage( 'Test.jpg', $index 
);
+               $index = $this->newIndexPage( 'Test', "{{\n|CSS= width:300px; 
\n}}" );
+               $page = $this->newPagePage( 'Test.jpg', $index );
                $this->assertEquals( 'width:300px;', $handler->getCustomCss( 
$page ) );
 
-               $index = ProofreadIndexPageTest::newIndexPage(
+               $index = $this->newIndexPage(
                        'Test', "{{\n|CSS= background: 
url('/my-bad-url.jpg');\n}}"
                );
-               $page = ProofreadPagePageTest::newPagePage( 'Test.jpg', $index 
);
+               $page = $this->newPagePage( 'Test.jpg', $index );
                $this->assertEquals( '/* insecure input */', 
$handler->getCustomCss( $page ) );
 
-               $index = ProofreadIndexPageTest::newIndexPage(
+               $index = $this->newIndexPage(
                        'Test', "{{\n|CSS= width:300px;<style> \n}}"
                );
-               $page = ProofreadPagePageTest::newPagePage( 'Test.jpg', $index 
);
+               $page = $this->newPagePage( 'Test.jpg', $index );
                $this->assertEquals( 'width:300px;&lt;style&gt;', 
$handler->getCustomCss( $page ) );
        }
 }
diff --git a/tests/phpunit/page/ProofreadPagePageTest.php 
b/tests/phpunit/page/ProofreadPagePageTest.php
index 56f46be..86b8d34 100644
--- a/tests/phpunit/page/ProofreadPagePageTest.php
+++ b/tests/phpunit/page/ProofreadPagePageTest.php
@@ -1,31 +1,15 @@
 <?php
 
-use ProofreadPage\Page\PageContent;
-
 /**
  * @group ProofreadPage
  * @covers ProofreadPagePage
  */
 class ProofreadPagePageTest extends ProofreadPageTestCase {
 
-       /**
-        * Constructor of a new ProofreadPagePage
-        * @param Title|string $title
-        * @param PageContent|null $content
-        * @param ProofreadIndexPage|null $index
-        * @return ProofreadPagePage
-        */
-       public static function newPagePage( $title = 'test.jpg', 
ProofreadIndexPage $index = null ) {
-               if ( is_string( $title ) ) {
-                       $title = Title::makeTitle( 250, $title );
-               }
-               return new ProofreadPagePage( $title, $index );
-       }
-
        public function testEquals() {
-               $page = self::newPagePage( 'Test.djvu' );
-               $page2 = self::newPagePage( 'Test.djvu' );
-               $page3 = self::newPagePage( 'Test2.djvu' );
+               $page = $this->newPagePage( 'Test.djvu' );
+               $page2 = $this->newPagePage( 'Test.djvu' );
+               $page3 = $this->newPagePage( 'Test2.djvu' );
                $this->assertTrue( $page->equals( $page2 ) );
                $this->assertTrue( $page2->equals( $page ) );
                $this->assertFalse( $page->equals( $page3 ) );
@@ -33,19 +17,19 @@
        }
 
        public function testGetTitle() {
-               $title = Title::makeTitle( 250, 'Test.djvu' );
-               $page = ProofreadPagePage::newFromTitle( $title );
+               $title = Title::makeTitle( $this->getPageNamespaceId(), 
'Test.djvu' );
+               $page = $this->newPagePage( $title );
                $this->assertEquals( $title, $page->getTitle() );
        }
 
        public function testGetPageNumber() {
-               $this->assertEquals( 1, self::newPagePage( 'Test.djvu/1' 
)->getPageNumber() );
+               $this->assertEquals( 1, $this->newPagePage( 'Test.djvu/1' 
)->getPageNumber() );
 
-               $this->assertNull( self::newPagePage( 'Test.djvu' 
)->getPageNumber() );
+               $this->assertNull( $this->newPagePage( 'Test.djvu' 
)->getPageNumber() );
        }
 
        public function testGetIndex() {
-               $index = ProofreadIndexPageTest::newIndexPage();
-               $this->assertEquals( $index, self::newPagePage( 'Test.jpg', 
$index )->getIndex() );
+               $index = $this->newIndexPage();
+               $this->assertEquals( $index, $this->newPagePage( 'Test.jpg', 
$index )->getIndex() );
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/371469
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b64e6a2725992ce1524b3c73479f12b351e2d91
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Tpt <thoma...@hotmail.fr>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to