本文整理匯總了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));
}