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


PHP PluginManagerInterface::expects方法代码示例

本文整理汇总了PHP中Drupal\Component\Plugin\PluginManagerInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginManagerInterface::expects方法的具体用法?PHP PluginManagerInterface::expects怎么用?PHP PluginManagerInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Component\Plugin\PluginManagerInterface的用法示例。


在下文中一共展示了PluginManagerInterface::expects方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetWithConfigurablePlugin

 /**
  * Tests the get() method with a configurable plugin.
  */
 public function testGetWithConfigurablePlugin()
 {
     $plugin = $this->getMock('Drupal\\search\\Plugin\\ConfigurableSearchPluginInterface');
     $plugin->expects($this->once())->method('setSearchPageId')->with('fruit_stand')->will($this->returnValue($plugin));
     $this->pluginManager->expects($this->once())->method('createInstance')->will($this->returnValue($plugin));
     $this->assertSame($plugin, $this->searchPluginBag->get('banana'));
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:SearchPluginBagTest.php

示例2: testCreateInstance

 /**
  * @covers ::createInstance
  */
 public function testCreateInstance()
 {
     $plugin_id_a = $this->randomMachineName();
     $plugin_a = $this->getMock(PluginInspectionInterface::class);
     $plugin_id_b = $this->randomMachineName();
     $plugin_b = $this->getMock(PaymentAwarePluginFilteredPluginManagerUnitTestPaymentAwarePlugin::class);
     $plugin_b->expects($this->atLeastOnce())->method('setPayment')->with($this->payment);
     $map = [[$plugin_id_a, [], $plugin_a], [$plugin_id_b, [], $plugin_b]];
     $this->pluginManager->expects($this->atLeast(count($map)))->method('createInstance')->willReturnMap($map);
     $this->assertSame($plugin_a, $this->sut->createInstance($plugin_id_a));
     $this->assertSame($plugin_b, $this->sut->createInstance($plugin_id_b));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:15,代码来源:PaymentAwarePluginFilteredPluginManagerTest.php

示例3: setupPluginCollection

 /**
  * Sets up the default plugin collection.
  *
  * @param \PHPUnit_Framework_MockObject_Matcher_InvokedRecorder|null $create_count
  *   (optional) The number of times that createInstance() is expected to be
  *   called. For example, $this->any(), $this->once(), $this->exactly(6).
  *   Defaults to $this->never().
  */
 protected function setupPluginCollection(\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder $create_count = NULL)
 {
     $this->pluginInstances = array();
     $map = array();
     foreach ($this->getPluginDefinitions() as $plugin_id => $definition) {
         // Create a mock plugin instance.
         $this->pluginInstances[$plugin_id] = $this->getPluginMock($plugin_id, $definition);
         $map[] = array($plugin_id, $this->config[$plugin_id], $this->pluginInstances[$plugin_id]);
     }
     $create_count = $create_count ?: $this->never();
     $this->pluginManager->expects($create_count)->method('createInstance')->will($this->returnCallback(array($this, 'returnPluginMap')));
     $this->defaultPluginCollection = new DefaultLazyPluginCollection($this->pluginManager, $this->config);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:21,代码来源:LazyPluginCollectionTestBase.php

示例4: testGetDefinitionsWithoutAllowedPlugins

 /**
  * @covers ::getDefinitions
  * @covers ::processDecoratedDefinitions
  * @covers ::setDiscoveryLimit
  * @covers ::resetDiscoveryLimit
  */
 public function testGetDefinitionsWithoutAllowedPlugins()
 {
     $plugin_id_a = $this->randomMachineName();
     $plugin_definition_a = ['id' => $plugin_id_a];
     $plugin_id_b = $this->randomMachineName();
     $plugin_definition_b = ['id' => $plugin_id_b];
     $plugin_id_c = $this->randomMachineName();
     $plugin_definition_c = ['id' => $plugin_id_c];
     $plugin_definitions = [$plugin_id_a => $plugin_definition_a, $plugin_id_b => $plugin_definition_b, $plugin_id_c => $plugin_definition_c];
     $this->pluginManager->expects($this->atLeastOnce())->method('getDefinitions')->willReturn($plugin_definitions);
     $this->sut->setDiscoveryLimit([]);
     $this->assertEquals([], $this->sut->getDefinitions());
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:19,代码来源:LimitedPluginDiscoveryDecoratorTest.php

示例5: testInvoke

 /**
  * @covers ::getPermissions
  */
 public function testInvoke()
 {
     $payment_method_configuration_plugin_id = $this->randomMachineName();
     $payment_method_configuration_label = $this->randomMachineName();
     $payment_method_configuration_definitions = array($payment_method_configuration_plugin_id => array('label' => $payment_method_configuration_label));
     $this->paymentMethodConfigurationManager->expects($this->once())->method('getDefinitions')->willReturn($payment_method_configuration_definitions);
     $permissions = $this->sut->getPermissions();
     $this->assertInternalType('array', $permissions);
     foreach ($permissions as $permission) {
         $this->assertInternalType('array', $permission);
         $this->assertArrayHasKey('title', $permission);
     }
     $this->arrayHasKey('payment.payment_method_configuration.create.' . $payment_method_configuration_plugin_id, $permissions);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:17,代码来源:PermissionsTest.php

示例6: testGetDefinitions

 /**
  * @covers ::getDefinitions
  * @covers ::processDecoratedDefinitions
  */
 public function testGetDefinitions()
 {
     $decorated_plugin_id_a = $this->randomMachineName();
     $decorated_plugin_definition_a = ['id' => $decorated_plugin_id_a];
     $decorated_plugin_id_b = $this->randomMachineName();
     $decorated_plugin_definition_b = ['id' => $decorated_plugin_id_b];
     $decorated_plugin_definitions = [$decorated_plugin_id_a => $decorated_plugin_definition_a, $decorated_plugin_id_b => $decorated_plugin_definition_b];
     $this->pluginManager->expects($this->once())->method('getDefinitions')->willReturn($decorated_plugin_definitions);
     $typed_plugin_definition_a = $this->getMock(PluginDefinitionInterface::class);
     $typed_plugin_definition_b = $this->getMock(PluginDefinitionInterface::class);
     $map = [[$decorated_plugin_definition_a, $typed_plugin_definition_a], [$decorated_plugin_definition_b, $typed_plugin_definition_b]];
     $this->pluginType->expects($this->atLeastOnce())->method('ensureTypedPluginDefinition')->willReturnMap($map);
     $expected_plugin_definitions = [$decorated_plugin_id_a => $typed_plugin_definition_a, $decorated_plugin_id_b => $typed_plugin_definition_b];
     $this->assertSame($expected_plugin_definitions, $this->sut->getDefinitions());
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:19,代码来源:TypedDefinitionEnsuringPluginDiscoveryDecoratorTest.php

示例7: testInvoke

 /**
  * @covers ::invoke
  */
 public function testInvoke()
 {
     $payment_type_plugin_id = $this->randomMachineName();
     $payment_type_label = $this->randomMachineName();
     $payment_type_definitions = array($payment_type_plugin_id => array('label' => $payment_type_label));
     $this->paymentTypeManager->expects($this->once())->method('getDefinitions')->willReturn($payment_type_definitions);
     $payment_method_configuration_plugin_id = $this->randomMachineName();
     $payment_method_configuration_label = $this->randomMachineName();
     $payment_method_configuration_definitions = array($payment_method_configuration_plugin_id => array('label' => $payment_method_configuration_label));
     $this->paymentMethodConfigurationManager->expects($this->once())->method('getDefinitions')->willReturn($payment_method_configuration_definitions);
     $entity_types = array('payment' => $payment_type_definitions, 'payment_method_configuration' => $payment_method_configuration_definitions);
     $entity_types_bundles_info = $this->sut->invoke();
     $this->assertSame(count($entity_types), count($entity_types_bundles_info));
     foreach ($entity_types as $entity_type => $plugin_definitions) {
         $entity_type_bundles_info = $entity_types_bundles_info[$entity_type];
         $this->assertInternalType('array', $entity_type_bundles_info);
         foreach ($plugin_definitions as $plugin_id => $plugin_definition) {
             $this->assertArrayHasKey('label', $entity_type_bundles_info[$plugin_id]);
             $this->assertSame($plugin_definition['label'], $entity_type_bundles_info[$plugin_id]['label']);
         }
     }
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:25,代码来源:EntityBundleInfoTest.php

示例8: testLoad

 /**
  * @covers ::load
  */
 public function testLoad()
 {
     $currency_code_from = 'EUR';
     $currency_code_to = 'NLG';
     $rate = new ExchangeRate($currency_code_from, $currency_code_to, '2.20371');
     $exchange_rate_provider_id_a = $this->randomMachineName();
     $exchange_rate_provider_id_b = $this->randomMachineName();
     $exchange_rate_provider_b = $this->getMock('\\Commercie\\CurrencyExchange\\ExchangeRateProviderInterface');
     $exchange_rate_provider_b->expects($this->once())->method('load')->with($currency_code_from, $currency_code_to)->willReturn($rate);
     $plugin_definitions = [$exchange_rate_provider_id_a => ['id' => $exchange_rate_provider_id_a], $exchange_rate_provider_id_b => ['id' => $exchange_rate_provider_id_b]];
     $this->currencyExchangeRateProviderManager->expects($this->once())->method('createInstance')->with($exchange_rate_provider_id_b)->willReturn($exchange_rate_provider_b);
     $this->currencyExchangeRateProviderManager->expects($this->once())->method('getDefinitions')->willReturn($plugin_definitions);
     $config_value = [['plugin_id' => $exchange_rate_provider_id_a, 'status' => FALSE], ['plugin_id' => $exchange_rate_provider_id_b, 'status' => TRUE]];
     $config = $this->getMockBuilder('\\Drupal\\Core\\Config\\Config')->disableOriginalConstructor()->getMock();
     $config->expects($this->once())->method('get')->with('plugins')->will($this->returnValue($config_value));
     $this->configFactory->expects($this->once())->method('get')->with('currency.exchange_rate_provider')->will($this->returnValue($config));
     $this->assertSame($rate, $this->sut->load($currency_code_from, $currency_code_to));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:21,代码来源:PluginBasedExchangeRateProviderTest.php


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