当前位置: 首页>>代码示例>>PHP>>正文


PHP BubbleableMetadata::merge方法代码示例

本文整理汇总了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));
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:35,代码来源:BubbleableMetadataTest.php


注:本文中的Drupal\Core\Render\BubbleableMetadata::merge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。