diff options
author | DannyS712 <dannys712.wiki@gmail.com> | 2021-05-03 16:35:08 +0000 |
---|---|---|
committer | DannyS712 <dannys712.wiki@gmail.com> | 2021-05-03 16:40:54 +0000 |
commit | 450174b7a569a0c31453e41f72683dd66f8d0ab8 (patch) | |
tree | 804216b0f353675eb9732bb62067fe25d7e2ffee /tests/phpunit | |
parent | a8a2b4b0b6798eada88e5f4d35fb4166fa58b385 (diff) | |
download | mediawikicore-450174b7a569a0c31453e41f72683dd66f8d0ab8.tar.gz mediawikicore-450174b7a569a0c31453e41f72683dd66f8d0ab8.zip |
MockTitleTrait: clean up makeMockTitle
Don't mock Title::getContentModel() twice:
The first time, its either $props['contentModel'] or falling
back to CONTENT_MODEL_WIKITEXT, and the second was
just always CONTENT_MODEL_WIKITEXT - keep the first.
Update the documentation with latest supported options.
Add a todo about ::getPageLanguage() returning 'qqx' by default,
it should be returning a Language object
Change-Id: I715e46ecc56288be5f8cbd8672ffe051b2c3f8d9
Diffstat (limited to 'tests/phpunit')
-rw-r--r-- | tests/phpunit/mocks/MockTitleTrait.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/phpunit/mocks/MockTitleTrait.php b/tests/phpunit/mocks/MockTitleTrait.php index bc42f1a38166..26cdde6d8b16 100644 --- a/tests/phpunit/mocks/MockTitleTrait.php +++ b/tests/phpunit/mocks/MockTitleTrait.php @@ -13,8 +13,12 @@ trait MockTitleTrait { * @param array $props Additional properties to set. Supported keys: * - id: int * - namespace: int + * - fragment: string + * - interwiki: string + * - redirect: bool * - language: Language - * - contentModel: string + * - contentModel: string + * - revision: int * * @return Title|MockObject */ @@ -49,6 +53,8 @@ trait MockTitleTrait { $title->method( 'exists' )->willReturn( $id > 0 ); $title->method( 'isRedirect' )->willReturn( $props['redirect'] ?? false ); $title->method( 'getTouched' )->willReturn( $id ? '20200101223344' : false ); + + // TODO getPageLanguage should return a Language object, 'qqx' is a string $title->method( 'getPageLanguage' )->willReturn( $props['language'] ?? 'qqx' ); $title->method( 'getContentModel' ) ->willReturn( $props['contentModel'] ?? CONTENT_MODEL_WIKITEXT ); @@ -62,7 +68,6 @@ trait MockTitleTrait { } else { $title->method( 'getLatestRevId' )->willReturn( $id === 0 ? 0 : 43 ); } - $title->method( 'getContentModel' )->willReturn( CONTENT_MODEL_WIKITEXT ); $title->method( 'isContentPage' )->willReturn( true ); $title->method( 'isSamePageAs' )->willReturnCallback( static function ( $other ) use ( $id ) { return $other && $id === $other->getArticleId(); |