createMock( MessageLocalizer::class ); $featureManager = $this->createMock( FeatureManager::class ); // The isFeatureEnabled method is called and returns true $featureManager->method( 'isFeatureEnabled' ) ->willReturn( true ); // Create a new VectorComponentAppearance object $appearanceMenu = new VectorComponentAppearance( $localizer, $featureManager ); // Call the getTemplateData method $actualData = $appearanceMenu->getTemplateData(); // The expected data $expectedData = [ // The id is set to 'vector-appearance' 'id' => 'vector-appearance', // The is-pinned value is true 'is-pinned' => true, // The data-pinnable-header array 'data-pinnable-header' => [ // The is-pinned value is true 'is-pinned' => true, // The label is null 'label' => null, // The label-tag-name is set to 'div' 'label-tag-name' => 'div', // The pin-label is null 'pin-label' => null, // The unpin-label is null 'unpin-label' => null, // The data-pinnable-element-id is set to 'vector-appearance' 'data-pinnable-element-id' => 'vector-appearance', // The data-feature-name is set to 'appearance-pinned' 'data-feature-name' => 'appearance-pinned', // The data-unpinned-container-id is set to 'vector-appearance-unpinned-container' 'data-unpinned-container-id' => 'vector-appearance-unpinned-container', // The data-pinned-container-id is set to 'vector-appearance-pinned-container' 'data-pinned-container-id' => 'vector-appearance-pinned-container', ] ]; // Assert that the actual data matches the expected data $this->assertEquals( $expectedData, $actualData ); // Assert that the is-pinned value is true $this->assertSame( true, $actualData['is-pinned'], 'Assertion for the pinned state failed.' ); } /** * @covers ::getTemplateData */ public function testGetTemplateDataUnpinned() { // Mock the MessageLocalizer and FeatureManager $localizer = $this->createMock( MessageLocalizer::class ); $featureManager = $this->createMock( FeatureManager::class ); // The isFeatureEnabled method is called and returns false $featureManager->method( 'isFeatureEnabled' ) ->willReturn( false ); // Create a new VectorComponentAppearance object $clientPrefs = new VectorComponentAppearance( $localizer, $featureManager ); // Call the getTemplateData method $actualData = $clientPrefs->getTemplateData(); // The expected data $expectedData = [ // The id is set to 'vector-appearance' 'id' => 'vector-appearance', // The is-pinned value is false 'is-pinned' => false, // The data-pinnable-header array 'data-pinnable-header' => [ // The is-pinned value is false 'is-pinned' => false, // The label is null 'label' => null, // The label-tag-name is set to 'div' 'label-tag-name' => 'div', // The pin-label is null 'pin-label' => null, // The unpin-label is null 'unpin-label' => null, // The data-pinnable-element-id is set to 'vector-appearance' 'data-pinnable-element-id' => 'vector-appearance', // The data-feature-name is set to 'appearance-pinned' 'data-feature-name' => 'appearance-pinned', // The data-unpinned-container-id is set to 'vector-appearance-unpinned-container' 'data-unpinned-container-id' => 'vector-appearance-unpinned-container', // The data-pinned-container-id is set to 'vector-appearance-pinned-container' 'data-pinned-container-id' => 'vector-appearance-pinned-container', ] ]; // Assert that the actual data matches the expected data $this->assertEquals( $expectedData, $actualData ); // Assert that the is-pinned value is false $this->assertSame( false, $actualData['is-pinned'], 'Assertion for the pinned state failed.' ); } }