當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。