mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-25 06:03:10 +00:00
be11774875
Adds tests for VectorComponentPinnableContainer in Vector skin, ensuring: - Proper initialization with ID and pin status. - Correct template data based on init params. - Consistent template data for pinned/unpinned states. Change-Id: Iec33c11b0afbe2bea5b6708b83b9ea618f7e809b
61 lines
2.3 KiB
PHP
61 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
*
|
|
* @file
|
|
* @since 1.42
|
|
*/
|
|
|
|
namespace MediaWiki\Skins\Vector\Tests\Unit\Components;
|
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentPinnableContainer;
|
|
use MediaWikiUnitTestCase;
|
|
|
|
/**
|
|
* @group Vector
|
|
* @group Components
|
|
* @coversDefaultClass \MediaWiki\Skins\Vector\Components\VectorComponentPinnableContainer
|
|
*/
|
|
class VectorComponentPinnableContainerTest extends MediaWikiUnitTestCase {
|
|
|
|
/**
|
|
* @covers ::getTemplateData
|
|
*/
|
|
public function testGetTemplateData() {
|
|
// Test initialization with ID and isPinned set to true
|
|
$mockIdTrue = 'pinned-container';
|
|
$pinnableContainerTrue = new VectorComponentPinnableContainer( $mockIdTrue, true );
|
|
$expectedTemplateDataTrue = [
|
|
'id' => $mockIdTrue,
|
|
'is-pinned' => true
|
|
];
|
|
// Assert that the actual template data matches the expected array for pinned=true
|
|
$this->assertSame( $expectedTemplateDataTrue, $pinnableContainerTrue->getTemplateData(),
|
|
'Template data for a pinned container should correctly include the ID and is-pinned status.' );
|
|
|
|
// Test initialization with ID and isPinned set to false
|
|
$mockIdFalse = 'unpinned-container';
|
|
$pinnableContainerFalse = new VectorComponentPinnableContainer( $mockIdFalse, false );
|
|
$expectedTemplateDataFalse = [
|
|
'id' => $mockIdFalse,
|
|
'is-pinned' => false
|
|
];
|
|
// Assert that the actual template data matches the expected array for pinned=false
|
|
$this->assertSame( $expectedTemplateDataFalse, $pinnableContainerFalse->getTemplateData(),
|
|
'Template data for an unpinned container should accurately reflect a different ID and is-pinned status.' );
|
|
}
|
|
}
|