From 450174b7a569a0c31453e41f72683dd66f8d0ab8 Mon Sep 17 00:00:00 2001 From: DannyS712 Date: Mon, 3 May 2021 16:35:08 +0000 Subject: 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 --- tests/phpunit/mocks/MockTitleTrait.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/phpunit') 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(); -- cgit v1.2.3