| 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\VectorComponentAppearance; |
| 25 |
use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager; |
| 26 |
use MediaWikiUnitTestCase; |
| 27 |
use MessageLocalizer; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
class VectorComponentAppearanceTest extends MediaWikiUnitTestCase { |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public function testGetTemplateDataPinned() { |
| 40 |
|
| 41 |
$localizer = $this->createMock( MessageLocalizer::class ); |
| 42 |
$featureManager = $this->createMock( FeatureManager::class ); |
| 43 |
|
| 44 |
$featureManager->method( 'isFeatureEnabled' ) |
| 45 |
->willReturn( true ); |
| 46 |
|
| 47 |
|
| 48 |
$appearanceMenu = new VectorComponentAppearance( $localizer, $featureManager ); |
| 49 |
|
| 50 |
$actualData = $appearanceMenu->getTemplateData(); |
| 51 |
|
| 52 |
|
| 53 |
$expectedData = [ |
| 54 |
|
| 55 |
'id' => 'vector-appearance', |
| 56 |
|
| 57 |
'is-pinned' => true, |
| 58 |
|
| 59 |
'data-pinnable-header' => [ |
| 60 |
|
| 61 |
'is-pinned' => true, |
| 62 |
|
| 63 |
'label' => null, |
| 64 |
|
| 65 |
'label-tag-name' => 'div', |
| 66 |
|
| 67 |
'pin-label' => null, |
| 68 |
|
| 69 |
'unpin-label' => null, |
| 70 |
|
| 71 |
'data-pinnable-element-id' => 'vector-appearance', |
| 72 |
|
| 73 |
'data-feature-name' => 'appearance-pinned', |
| 74 |
|
| 75 |
'data-unpinned-container-id' => 'vector-appearance-unpinned-container', |
| 76 |
|
| 77 |
'data-pinned-container-id' => 'vector-appearance-pinned-container', |
| 78 |
] |
| 79 |
]; |
| 80 |
|
| 81 |
|
| 82 |
$this->assertEquals( $expectedData, $actualData ); |
| 83 |
|
| 84 |
$this->assertSame( true, $actualData['is-pinned'], 'Assertion for the pinned state failed.' ); |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
public function testGetTemplateDataUnpinned() { |
| 91 |
|
| 92 |
$localizer = $this->createMock( MessageLocalizer::class ); |
| 93 |
$featureManager = $this->createMock( FeatureManager::class ); |
| 94 |
|
| 95 |
$featureManager->method( 'isFeatureEnabled' ) |
| 96 |
->willReturn( false ); |
| 97 |
|
| 98 |
|
| 99 |
$clientPrefs = new VectorComponentAppearance( $localizer, $featureManager ); |
| 100 |
|
| 101 |
$actualData = $clientPrefs->getTemplateData(); |
| 102 |
|
| 103 |
|
| 104 |
$expectedData = [ |
| 105 |
|
| 106 |
'id' => 'vector-appearance', |
| 107 |
|
| 108 |
'is-pinned' => false, |
| 109 |
|
| 110 |
'data-pinnable-header' => [ |
| 111 |
|
| 112 |
'is-pinned' => false, |
| 113 |
|
| 114 |
'label' => null, |
| 115 |
|
| 116 |
'label-tag-name' => 'div', |
| 117 |
|
| 118 |
'pin-label' => null, |
| 119 |
|
| 120 |
'unpin-label' => null, |
| 121 |
|
| 122 |
'data-pinnable-element-id' => 'vector-appearance', |
| 123 |
|
| 124 |
'data-feature-name' => 'appearance-pinned', |
| 125 |
|
| 126 |
'data-unpinned-container-id' => 'vector-appearance-unpinned-container', |
| 127 |
|
| 128 |
'data-pinned-container-id' => 'vector-appearance-pinned-container', |
| 129 |
] |
| 130 |
]; |
| 131 |
|
| 132 |
|
| 133 |
$this->assertEquals( $expectedData, $actualData ); |
| 134 |
|
| 135 |
$this->assertSame( false, $actualData['is-pinned'], 'Assertion for the pinned state failed.' ); |
| 136 |
} |
| 137 |
} |