本文整理汇总了PHP中Drupal\Core\Render\BubbleableMetadata::merge方法的典型用法代码示例。如果您正苦于以下问题:PHP BubbleableMetadata::merge方法的具体用法?PHP BubbleableMetadata::merge怎么用?PHP BubbleableMetadata::merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Render\BubbleableMetadata
的用法示例。
在下文中一共展示了BubbleableMetadata::merge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMerge
/**
* @covers ::merge
* @dataProvider providerTestMerge
*
* This only tests at a high level, because it reuses existing logic. Detailed
* tests exist for the existing logic:
*
* @see \Drupal\Tests\Core\Cache\CacheTest::testMergeTags()
* @see \Drupal\Tests\Core\Cache\CacheTest::testMergeMaxAges()
* @see \Drupal\Tests\Core\Cache\CacheContextsTest
* @see \Drupal\Tests\Core\Render\RendererPlaceholdersTest
* @see testMergeAttachmentsLibraryMerging()
* @see testMergeAttachmentsFeedMerging()
* @see testMergeAttachmentsHtmlHeadMerging()
* @see testMergeAttachmentsHtmlHeadLinkMerging()
* @see testMergeAttachmentsHttpHeaderMerging()
*/
public function testMerge(BubbleableMetadata $a, CacheableMetadata $b, BubbleableMetadata $expected)
{
// Verify that if the second operand is a CacheableMetadata object, not a
// BubbleableMetadata object, that BubbleableMetadata::merge() doesn't
// attempt to merge assets.
if (!$b instanceof BubbleableMetadata) {
$renderer = $this->getMockBuilder('Drupal\\Core\\Render\\Renderer')->disableOriginalConstructor()->getMock();
$renderer->expects($this->never())->method('mergeAttachments');
} else {
$renderer = $this->getMockBuilder('Drupal\\Core\\Render\\Renderer')->disableOriginalConstructor()->setMethods(NULL)->getMock();
}
$cache_contexts_manager = $this->getMockBuilder('Drupal\\Core\\Cache\\Context\\CacheContextsManager')->disableOriginalConstructor()->getMock();
$container = new ContainerBuilder();
$container->set('cache_contexts_manager', $cache_contexts_manager);
$container->set('renderer', $renderer);
\Drupal::setContainer($container);
$this->assertEquals($expected, $a->merge($b));
}