false,
'label' => 'vector-page-tools-label',
'label-tag-name' => 'div',
'pin-label' => 'vector-pin-element-label',
'unpin-label' => 'vector-unpin-element-label',
'data-feature-name' => 'page-tools-pinned',
'data-pinnable-element-id' => 'vector-page-tools',
'data-unpinned-container-id' => 'vector-page-tools-unpinned-container',
'data-pinned-container-id' => 'vector-page-tools-pinned-container',
], $data );
}
public static function provideConstructorData() {
$menus = [ [
'id' => 'p-cactions',
'array-items' => [ [
'id' => 'ca-delete',
'html-item' => "
Delete"
] ]
], [
'id' => 'p-tb',
'array-items' => [ [
'id' => 't-whatlinkshere',
'html-item' => "What links here"
] ]
] ];
$expectedMenus = $menus;
$expectedMenus[ 0 ][ 'label' ] = 'vector-page-tools-actions-label';
$expectedMenus[ 1 ][ 'label' ] = 'vector-page-tools-general-label';
return [
[
$menus,
false,
false,
[
'id' => 'vector-page-tools',
'is-pinned' => false,
'data-pinnable-header' => self::getPinnableHeaderData(),
'data-menus' => $expectedMenus
]
],
[
$menus,
false,
true,
[
'id' => 'vector-page-tools',
'is-pinned' => true,
'data-pinnable-header' => self::getPinnableHeaderData( [
'is-pinned' => true,
] ),
'data-menus' => $expectedMenus
]
],
[
$menus,
true,
false,
[
'id' => 'vector-page-tools',
'is-pinned' => false,
'data-pinnable-header' => self::getPinnableHeaderData(),
'data-menus' => $expectedMenus
]
]
];
}
/**
* @covers ::getTemplateData
* @dataProvider provideConstructorData
*/
public function testGetTemplateData(
array $menus,
bool $isRegistered,
bool $isPinned,
array $expected
) {
$localizer = $this->createMock( MessageLocalizer::class );
$localizer->method( 'msg' )->willReturnCallback( function ( $key, ...$params ) {
$msg = $this->createMock( Message::class );
$msg->method( '__toString' )->willReturn( $key );
$msg->method( 'text' )->willReturn( $key );
return $msg;
} );
$featureManager = $this->createMock( FeatureManager::class );
$featureManager->method( 'isFeatureEnabled' )->willReturn( $isPinned );
$pageTools = new VectorComponentPageTools(
$menus,
$localizer,
$featureManager
);
$this->assertEquals( $expected, $pageTools->getTemplateData() );
}
}