'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' => null,
'data-menus' => $expectedMenus
]
], [
$menus,
false,
true,
[
'id' => 'vector-page-tools',
'is-pinned' => true,
'data-pinnable-header' => null,
'data-menus' => $expectedMenus
]
], [
$menus,
true,
false,
[
'id' => 'vector-page-tools',
'is-pinned' => false,
'data-pinnable-header' => [
'is-pinned' => false,
'label' => 'vector-page-tools-label',
'label-tag-name' => 'div',
'pin-label' => 'vector-pin-element-label',
'unpin-label' => 'vector-unpin-element-label',
'data-name' => 'vector-page-tools',
'data-feature-name' => 'page-tools-pinned',
'data-pinnable-element-id' => 'vector-page-tools-pinnable-element',
'data-unpinned-container-id' => 'vector-page-tools-unpinned-container',
'data-pinned-container-id' => 'vector-page-tools-pinned-container',
],
'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;
} );
$user = $this->createMock( User::class );
$user->method( 'isRegistered' )->willReturn( $isRegistered );
$featureManager = $this->createMock( FeatureManager::class );
$featureManager->method( 'isFeatureEnabled' )->willReturn( $isPinned );
$pageTools = new VectorComponentPageTools(
$menus,
$localizer,
$user,
$featureManager
);
$this->assertEquals( $expected, $pageTools->getTemplateData() );
}
}