mediawiki-skins-Citizen/tests/phpunit/Unit/Components/CitizenComponentMainMenuTest.php
2024-05-09 17:46:19 -04:00

58 lines
1.7 KiB
PHP

<?php
declare( strict_types=1 );
namespace MediaWiki\Skins\Citizen\Tests\Unit\Components;
use MediaWiki\Skins\Citizen\Components\CitizenComponent;
use MediaWiki\Skins\Citizen\Components\CitizenComponentMainMenu;
use MediaWikiUnitTestCase;
/**
* @group Citizen
* @group Components
* @coversDefaultClass \MediaWiki\Skins\Citizen\Components\CitizenComponentMainMenu
*/
class CitizenComponentMainMenuTest extends MediaWikiUnitTestCase {
/**
* This test checks if the CitizenComponentMainMenu class can be instantiated
* @covers ::__construct
*/
public function testConstruct() {
// Mock the sidebar data
$sidebarData = [];
// Create a new CitizenComponentMainMenu object
$mainMenu = new CitizenComponentMainMenu(
$sidebarData
);
// Assert that the object is an instance of CitizenComponent
$this->assertInstanceOf( CitizenComponent::class, $mainMenu );
}
/**
* @covers ::getTemplateData
*/
public function testGetTemplateData( array $sidebarData, array $languageData, bool $isPinned ) {
// Create a new CitizenComponentMainMenu object
$mainMenu = new CitizenComponentMainMenu(
$sidebarData
);
// Call the getTemplateData method
$templateData = $mainMenu->getTemplateData();
// Assert main menu id
$this->assertSame( 'citizen-main-menu', $templateData['id'] );
// Assert the structure and types of expected keys
$this->assertIsArray( $templateData['data-portlets-first'] );
$this->assertIsArray( $templateData['array-portlets-rest'] );
// Assert the structure and types of expected keys
$this->assertArrayHasKey( 'data-portlets-first', $templateData );
$this->assertArrayHasKey( 'array-portlets-rest', $templateData );
}
}