| 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\VectorComponent; |
| 25 |
use MediaWiki\Skins\Vector\Components\VectorComponentMenu; |
| 26 |
use MediaWikiUnitTestCase; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
class VectorComponentMenuTest extends MediaWikiUnitTestCase { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
public function provideMenuData(): array { |
| 39 |
return [ |
| 40 |
[ |
| 41 |
[ |
| 42 |
'class' => 'some-class', |
| 43 |
'label' => 'Some label', |
| 44 |
'html-tooltip' => 'Some tooltip', |
| 45 |
'label-class' => 'some-label-class', |
| 46 |
'html-before-portal' => 'Some before portal', |
| 47 |
'html-items' => 'Some items', |
| 48 |
'html-after-portal' => 'Some after portal', |
| 49 |
'array-list-items' => [ 'some-item-one', 'some-item-2', 'some-item-3' ] |
| 50 |
] |
| 51 |
] |
| 52 |
]; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public function provideCountData(): array { |
| 59 |
return [ |
| 60 |
[ |
| 61 |
[ |
| 62 |
'array-list-items' => [ 'some-item-one', 'some-item-2', 'some-item-3' ] |
| 63 |
], |
| 64 |
3 |
| 65 |
], |
| 66 |
[ |
| 67 |
[ |
| 68 |
'html-items' => '<li>Some item</li><li>Some item</li><li>Some item</li>' |
| 69 |
], |
| 70 |
3 |
| 71 |
] |
| 72 |
]; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
public function testConstruct() { |
| 80 |
|
| 81 |
$menu = new VectorComponentMenu( [] ); |
| 82 |
|
| 83 |
|
| 84 |
$this->assertInstanceOf( VectorComponent::class, $menu ); |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public function testCount( array $data, int $expected ) { |
| 93 |
|
| 94 |
$menu = new VectorComponentMenu( $data ); |
| 95 |
|
| 96 |
|
| 97 |
$this->assertSame( $expected, $menu->count() ); |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public function testGetTemplateData( array $data ) { |
| 106 |
|
| 107 |
$menu = new VectorComponentMenu( $data ); |
| 108 |
|
| 109 |
|
| 110 |
$actualData = $menu->getTemplateData(); |
| 111 |
|
| 112 |
|
| 113 |
$this->assertSame( $data, $actualData ); |
| 114 |
} |
| 115 |
} |