mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-12-04 10:49:22 +00:00
58 lines
1.7 KiB
PHP
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 );
|
||
|
}
|
||
|
}
|