[ 'label' => 'Languages', 'ariaLabel' => 'Choose language', 'class' => 'some-class', 'numLanguages' => 5, 'itemHTML' => '
  • Language Mock
  • ', 'titleExists' => true, 'expectedIcon' => 'language-progressive', 'isSubjectPage' => true, ], 'Talk page without languages' => [ 'label' => 'Languages', 'ariaLabel' => 'Choose language', 'class' => 'some-class', 'numLanguages' => 0, 'itemHTML' => '', 'titleExists' => false, 'expectedIcon' => 'language', 'isSubjectPage' => false, ], 'Subject page without languages' => [ 'label' => 'Languages', 'ariaLabel' => 'Choose language', 'class' => 'some-class', 'numLanguages' => 0, 'itemHTML' => '', 'titleExists' => true, 'expectedIcon' => 'language-progressive', 'isSubjectPage' => true, ], 'Talk page with languages' => [ 'label' => 'Languages', 'ariaLabel' => 'Choose language', 'class' => 'some-class', 'numLanguages' => 5, 'itemHTML' => '
  • Language Mock
  • ', 'titleExists' => false, 'expectedIcon' => 'language', 'isSubjectPage' => false, ], ]; } /** * @covers ::getTemplateData * @dataProvider provideLanguageDropdownData */ public function testGetTemplateData( $label, $ariaLabel, $class, $numLanguages, $itemHTML, $titleExists, $expectedIcon, $isSubjectPage ) { // Mock Title $titleMock = $this->createMock( Title::class ); // Mock Title methods $titleMock->method( 'exists' )->willReturn( $titleExists ); $titleMock->method( 'isTalkPage' )->willReturn( !$titleExists ); // Create a new VectorComponentLanguageDropdown object $languageDropdown = new VectorComponentLanguageDropdown( $label, $ariaLabel, $class, $numLanguages, $itemHTML, '', '', $titleMock ); // Call the getTemplateData method $templateData = $languageDropdown->getTemplateData(); // Verifying that the template data is constructed as expected $this->assertEquals( $label, $templateData['label'] ); $this->assertEquals( $ariaLabel, $templateData['aria-label'] ); $this->assertEquals( $expectedIcon, $templateData['icon'] ); $this->assertStringContainsString( 'cdx-button--fake-button', $templateData['label-class'] ); $this->assertEquals( $itemHTML, $templateData['html-items'] ); $this->assertSame( !$titleExists, $templateData['is-language-selector-empty'] ); // Verifying that the template data is constructed as expected if ( !$isSubjectPage ) { $this->assertStringContainsString( 'cdx-button--fake-button', $templateData['label-class'] ); $this->assertStringContainsString( 'cdx-button--icon-only', $templateData['label-class'] ); $this->assertStringContainsString( 'mw-portlet-lang-heading-empty', $templateData['label-class'] ); $this->assertStringContainsString( 'mw-interlanguage-selector-empty', $templateData['checkbox-class'] ); $this->assertStringContainsString( 'mw-portlet-lang-icon-only', $templateData['class'] ); } else { $this->assertStringContainsString( 'cdx-button--fake-button', $templateData['label-class'] ); $this->assertStringNotContainsString( 'cdx-button--icon-only', $templateData['label-class'] ); $this->assertStringNotContainsString( 'mw-portlet-lang-heading-empty', $templateData['label-class'] ); $this->assertStringNotContainsString( 'mw-interlanguage-selector-empty', $templateData['checkbox-class'] ); $this->assertStringNotContainsString( 'mw-portlet-lang-icon-only', $templateData['class'] ); } } }