| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
namespace MediaWiki\Skins\Vector\Tests\Unit\Components; |
| 23 |
|
| 24 |
use MediaWiki\Skins\Vector\Components\VectorComponentDropdown; |
| 25 |
use MediaWikiUnitTestCase; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
class VectorComponentDropdownTest extends MediaWikiUnitTestCase { |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public function provideDropdownData(): array { |
| 38 |
return [ |
| 39 |
'Dropdown' => [ |
| 40 |
'id' => 'mock-dropdown', |
| 41 |
'label' => 'Mock Dropdown', |
| 42 |
'class' => 'some-class', |
| 43 |
'icon' => null, |
| 44 |
'tooltip' => 'A tooltip for the dropdown', |
| 45 |
'expectedClasses' => 'some-class', |
| 46 |
'expectedIconButtonClasses' => '', |
| 47 |
], |
| 48 |
'Dropdown with icon' => [ |
| 49 |
'id' => 'mock-icon-dropdown', |
| 50 |
'label' => 'Mock Icon Dropdown', |
| 51 |
'class' => 'some-icon-class', |
| 52 |
'icon' => 'icon-some', |
| 53 |
'tooltip' => 'A tooltip for the icon dropdown', |
| 54 |
'expectedClasses' => 'some-icon-class', |
| 55 |
'expectedIconButtonClasses' => 'cdx-button--icon-only', |
| 56 |
], |
| 57 |
]; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public function testGetTemplateData( string $id, string $label, string $class, $icon, string $tooltip, |
| 65 |
string $expectedClasses, string $expectedIconButtonClasses ) { |
| 66 |
|
| 67 |
$dropdown = new VectorComponentDropdown( $id, $label, $class, $icon, $tooltip ); |
| 68 |
|
| 69 |
$templateData = $dropdown->getTemplateData(); |
| 70 |
|
| 71 |
|
| 72 |
$this->assertEquals( $id, $templateData['id'] ); |
| 73 |
$this->assertEquals( $label, $templateData['label'] ); |
| 74 |
$this->assertEquals( $expectedClasses, $templateData['class'] ); |
| 75 |
$this->assertEquals( $icon, $templateData['icon'] ); |
| 76 |
$this->assertEquals( $tooltip, $templateData['html-tooltip'] ); |
| 77 |
|
| 78 |
$this->assertStringContainsString( $expectedIconButtonClasses, $templateData['label-class'] ); |
| 79 |
} |
| 80 |
} |