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


PHP EntityStorageInterface::expects方法代码示例

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


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

示例1: testGetUniqueMachineName

 /**
  * Tests the unique machine name generator.
  *
  * @see \Drupal\block\BlockForm::getUniqueMachineName()
  */
 public function testGetUniqueMachineName()
 {
     $blocks = array();
     $blocks['test'] = $this->getBlockMockWithMachineName('test');
     $blocks['other_test'] = $this->getBlockMockWithMachineName('other_test');
     $blocks['other_test_1'] = $this->getBlockMockWithMachineName('other_test');
     $blocks['other_test_2'] = $this->getBlockMockWithMachineName('other_test');
     $query = $this->getMock('Drupal\\Core\\Entity\\Query\\QueryInterface');
     $query->expects($this->exactly(5))->method('condition')->will($this->returnValue($query));
     $query->expects($this->exactly(5))->method('execute')->will($this->returnValue(array('test', 'other_test', 'other_test_1', 'other_test_2')));
     $this->storage->expects($this->exactly(5))->method('getQuery')->will($this->returnValue($query));
     $block_form_controller = new BlockForm($this->entityManager, $this->conditionManager, $this->contextRepository, $this->language, $this->themeHandler);
     // Ensure that the block with just one other instance gets the next available
     // name suggestion.
     $this->assertEquals('test_2', $block_form_controller->getUniqueMachineName($blocks['test']));
     // Ensure that the block with already three instances (_0, _1, _2) gets the
     // 4th available name.
     $this->assertEquals('other_test_3', $block_form_controller->getUniqueMachineName($blocks['other_test']));
     $this->assertEquals('other_test_3', $block_form_controller->getUniqueMachineName($blocks['other_test_1']));
     $this->assertEquals('other_test_3', $block_form_controller->getUniqueMachineName($blocks['other_test_2']));
     // Ensure that a block without an instance yet gets the suggestion as
     // unique machine name.
     $last_block = $this->getBlockMockWithMachineName('last_test');
     $this->assertEquals('last_test', $block_form_controller->getUniqueMachineName($last_block));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:30,代码来源:BlockFormTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // TODO: Change the autogenerated stub
     $condition_plugin_manager = $this->getMock('Drupal\\Core\\Executable\\ExecutableManagerInterface');
     $condition_plugin_manager->expects($this->any())->method('getDefinitions')->will($this->returnValue(array()));
     $container = new ContainerBuilder();
     $container->set('plugin.manager.condition', $condition_plugin_manager);
     \Drupal::setContainer($container);
     $this->executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')->disableOriginalConstructor()->setMethods(['buildRenderable', 'setDisplay', 'setItemsPerPage'])->getMock();
     $this->executable->expects($this->any())->method('setDisplay')->with('block_1')->will($this->returnValue(TRUE));
     $this->executable->expects($this->any())->method('getShowAdminLinks')->willReturn(FALSE);
     $this->executable->display_handler = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\Block')->disableOriginalConstructor()->setMethods(NULL)->getMock();
     $this->view = $this->getMockBuilder('Drupal\\views\\Entity\\View')->disableOriginalConstructor()->getMock();
     $this->view->expects($this->any())->method('id')->willReturn('test_view');
     $this->executable->storage = $this->view;
     $this->executableFactory = $this->getMockBuilder('Drupal\\views\\ViewExecutableFactory')->disableOriginalConstructor()->getMock();
     $this->executableFactory->expects($this->any())->method('get')->with($this->view)->will($this->returnValue($this->executable));
     $this->displayHandler = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\Block')->disableOriginalConstructor()->getMock();
     $this->displayHandler->expects($this->any())->method('blockSettings')->willReturn([]);
     $this->displayHandler->expects($this->any())->method('getPluginId')->willReturn('block');
     $this->executable->display_handler = $this->displayHandler;
     $this->storage = $this->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')->disableOriginalConstructor()->getMock();
     $this->storage->expects($this->any())->method('load')->with('test_view')->will($this->returnValue($this->view));
     $this->account = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:ViewsBlockTest.php

示例3: testExecute

 /**
  * @covers ::execute
  */
 public function testExecute()
 {
     $currency = $this->getMock(CurrencyInterface::class);
     $this->currencyStorage->expects($this->once())->method('create')->with(array())->willReturn($currency);
     $form = $this->getMock(EntityFormInterface::class);
     $this->entityFormBuilder->expects($this->once())->method('getForm')->with($currency)->willReturn($form);
     $this->assertSame($form, $this->sut->execute());
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:11,代码来源:AddCurrencyTest.php

示例4: testExecute

 /**
  * @covers ::execute
  */
 public function testExecute()
 {
     $payment_status = $this->getMock(PaymentStatusInterface::class);
     $this->paymentStatusStorage->expects($this->once())->method('create')->willReturn($payment_status);
     $form = $this->getMock(FormInterface::class);
     $this->entityFormBuilder->expects($this->once())->method('getForm')->with($payment_status)->willReturn($form);
     $this->assertSame($form, $this->sut->execute());
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:11,代码来源:AddPaymentStatusTest.php

示例5: testGetOperations

 /**
  * @covers ::getOperations
  */
 public function testGetOperations()
 {
     $entity_id = $this->randomMachineName();
     $plugin_id = 'payment_config:' . $entity_id;
     $payment_status = $this->getMock(PaymentStatusInterface::class);
     $this->paymentStatusStorage->expects($this->once())->method('load')->with($entity_id)->willReturn($payment_status);
     $operations = array('foo' => array('title' => $this->randomMachineName()));
     $this->paymentStatusListBuilder->expects($this->once())->method('getOperations')->with($payment_status)->willReturn($operations);
     $this->assertSame($operations, $this->sut->getOperations($plugin_id));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:13,代码来源:ConfigOperationsProviderTest.php

示例6: testGetPaymentMethodConfiguration

 /**
  * @covers ::getPaymentMethodConfiguration
  */
 public function testGetPaymentMethodConfiguration()
 {
     $entity_id = $this->randomMachineName();
     $plugin_id = 'payment_basic:' . $entity_id;
     $payment_method_configuration = $this->getMock(PaymentMethodConfigurationInterface::class);
     $this->paymentMethodConfigurationStorage->expects($this->once())->method('load')->with($entity_id)->willReturn($payment_method_configuration);
     $method = new \ReflectionMethod($this->sut, 'getPaymentMethodConfiguration');
     $method->setAccessible(TRUE);
     $this->assertEquals($payment_method_configuration, $method->invoke($this->sut, $plugin_id));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:13,代码来源:BasicOperationsProviderTest.php

示例7: testProcess

 /**
  * @covers ::process
  * @covers ::processCallback
  */
 function testProcess()
 {
     $cache_contexts = Cache::mergeContexts(['baz', 'qux']);
     $cache_tags = Cache::mergeTags(['foo', 'bar']);
     $map = [['100', TRUE, LanguageInterface::TYPE_CONTENT, '€100.00'], ['100.7654', TRUE, LanguageInterface::TYPE_CONTENT, '€100.77'], ['1.99', TRUE, LanguageInterface::TYPE_CONTENT, '€1.99'], ['2.99', TRUE, LanguageInterface::TYPE_CONTENT, '€2.99']];
     $currency = $this->getMock(CurrencyInterface::class);
     $currency->expects($this->any())->method('formatAmount')->willReturnMap($map);
     $currency->expects($this->atLeastOnce())->method('getCacheContexts')->willReturn($cache_contexts);
     $currency->expects($this->atLeastOnce())->method('getCacheTags')->willReturn($cache_tags);
     $this->currencyStorage->expects($this->any())->method('load')->with('EUR')->willReturn($currency);
     $this->input->expects($this->any())->method('parseAmount')->will($this->returnArgument(0));
     $langcode = $this->randomMachineName(2);
     $tokens_valid = ['[currency-localize:EUR:100]' => '€100.00', '[currency-localize:EUR:100.7654]' => '€100.77', '[currency-localize:EUR:1.99]' => '€1.99', '[currency-localize:EUR:2.99]' => '€2.99'];
     $tokens_invalid = ['[currency-localize]', '[currency-localize:]', '[currency-localize::]', '[currency-localize:EUR]', '[currency-localize:123:456]', '[currency-localize:123]'];
     foreach ($tokens_valid as $token => $replacement) {
         $result = $this->sut->process($token, $langcode);
         $this->assertInstanceOf(FilterProcessResult::class, $result);
         $this->assertSame($replacement, $result->getProcessedText());
         $this->assertSame($cache_contexts, $result->getCacheContexts());
         $this->assertSame($cache_tags, $result->getCacheTags());
     }
     foreach ($tokens_invalid as $token) {
         $result = $this->sut->process($token, $langcode);
         $this->assertInstanceOf(FilterProcessResult::class, $result);
         $this->assertSame($token, $result->getProcessedText());
         $this->assertEmpty($result->getCacheContexts());
         $this->assertEmpty($result->getCacheTags());
     }
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:33,代码来源:CurrencyLocalizeTest.php

示例8: testValidateCurrencyNumber

 /**
  * @covers ::validateCurrencyNumber
  * @dataProvider providerTestValidateCurrencyNumber
  */
 public function testValidateCurrencyNumber($valid, $currency_number, $currency_is_new, $currency_number_exists = FALSE)
 {
     $element = array('#value' => $currency_number);
     $form = array();
     $form_state = $this->getMock(FormStateInterface::class);
     $this->currency->expects($this->any())->method('isNew')->willReturn($currency_is_new);
     if (!$valid) {
         $form_state->expects($this->once())->method('setError')->with($element, 'The currency number must be three digits.');
     } elseif ($currency_number_exists) {
         $loaded_currency_code = $this->randomMachineName();
         $loaded_currency_label = $this->randomMachineName();
         $loaded_currency_url = new Url($this->randomMachineName());
         $loaded_currency = $this->getMock(CurrencyInterface::class);
         $loaded_currency->expects($this->any())->method('id')->willReturn($loaded_currency_code);
         $loaded_currency->expects($this->any())->method('label')->willReturn($loaded_currency_label);
         $loaded_currency->expects($this->atLeastOnce())->method('urlInfo')->willReturn($loaded_currency_url);
         $this->currencyStorage->expects($this->once())->method('loadByProperties')->with(array('currencyNumber' => $currency_number))->willReturn(array($loaded_currency));
         $form_state->expects($this->once())->method('setError');
         $this->linkGenerator->expects($this->once())->method('generate')->with($loaded_currency_label, $loaded_currency_url);
     } else {
         $this->currencyStorage->expects($this->once())->method('loadByProperties')->with(array('currencyNumber' => $currency_number))->willReturn(FALSE);
         $form_state->expects($this->never())->method('setError');
         $form_state->expects($this->never())->method('setErrorByName');
     }
     $this->sut->validateCurrencyNumber($element, $form_state, $form);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:30,代码来源:CurrencyFormTest.php

示例9: testGetDerivativeDefinitions

 /**
  * @covers ::getDerivativeDefinitions
  */
 public function testGetDerivativeDefinitions()
 {
     $status_a = $this->getMock(PaymentStatusInterface::class);
     $status_a->expects($this->once())->method('getDescription')->willReturn($this->randomMachineName());
     $status_a->expects($this->once())->method('id')->willReturn($this->randomMachineName());
     $status_a->expects($this->once())->method('label')->willReturn($this->randomMachineName());
     $status_a->expects($this->once())->method('getParentId')->willReturn($this->randomMachineName());
     $status_b = $this->getMock(PaymentStatusInterface::class);
     $status_b->expects($this->once())->method('getDescription')->willReturn($this->randomMachineName());
     $status_b->expects($this->once())->method('id')->willReturn($this->randomMachineName());
     $status_b->expects($this->once())->method('label')->willReturn($this->randomMachineName());
     $status_b->expects($this->once())->method('getParentId')->willReturn($this->randomMachineName());
     $this->paymentStatusStorage->expects($this->once())->method('loadMultiple')->willReturn(array($status_a, $status_b));
     $derivatives = $this->sut->getDerivativeDefinitions([]);
     $this->assertCount(2, $derivatives);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:19,代码来源:ConfigDeriverTest.php

示例10: testPaymentMethodConfigurationIdExists

 /**
  * @covers ::paymentMethodConfigurationIdExists
  */
 public function testPaymentMethodConfigurationIdExists()
 {
     $payment_method_configuration_id = $this->randomMachineName();
     $this->paymentMethodConfigurationStorage->expects($this->at(0))->method('load')->with($payment_method_configuration_id)->willReturn($this->paymentMethodConfiguration);
     $this->paymentMethodConfigurationStorage->expects($this->at(1))->method('load')->with($payment_method_configuration_id)->willReturn(NULL);
     $this->assertTrue($this->sut->paymentMethodConfigurationIdExists($payment_method_configuration_id));
     $this->assertFalse($this->sut->paymentMethodConfigurationIdExists($payment_method_configuration_id));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:11,代码来源:PaymentMethodConfigurationFormTest.php

示例11: testCalculateDependencies

 /**
  * @covers ::calculateDependencies
  */
 public function testCalculateDependencies()
 {
     /* @var $view_this \Drupal\views\Entity\View */
     /* @var $view_other \Drupal\views\Entity\View */
     $view_this = $this->getMock('Drupal\\views\\ViewEntityInterface');
     $view_this->expects($this->any())->method('getConfigDependencyKey')->willReturn('config');
     $view_this->expects($this->any())->method('getConfigDependencyName')->willReturn('view.this');
     $view_this->expects($this->any())->method('id')->willReturn('this');
     $view_other = $this->getMock('Drupal\\views\\ViewEntityInterface');
     $view_other->expects($this->any())->method('getConfigDependencyKey')->willReturn('config');
     $view_other->expects($this->any())->method('getConfigDependencyName')->willReturn('view.other');
     $this->entityStorage->expects($this->any())->method('load')->willReturnMap([['this', $view_this], ['other', $view_other]]);
     $this->viewHandler->view->storage = $view_this;
     $this->viewHandler->options['view_to_insert'] = 'other:default';
     $this->assertArrayEquals(array('config' => array('view.other')), $this->viewHandler->calculateDependencies());
     $this->viewHandler->options['view_to_insert'] = 'this:default';
     $this->assertArrayEquals(array(), $this->viewHandler->calculateDependencies());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:21,代码来源:ViewTest.php

示例12: testRenderWithNonExistingCurrency

 /**
  * @covers ::render
  */
 function testRenderWithNonExistingCurrency()
 {
     $currency_code = $this->randomMachineName();
     $field_alias = $this->randomMachineName();
     $this->sut->field_alias = $field_alias;
     $result_row = new ResultRow([$field_alias => $currency_code]);
     $this->currencyStorage->expects($this->atLeastOnce())->method('load')->with($currency_code)->willReturn(NULL);
     $this->assertInstanceOf(MarkupInterface::class, $this->sut->render($result_row));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:12,代码来源:CurrencyTest.php

示例13: testImportCurrencyLocaleWithExistingCurrency

 /**
  * @covers ::importCurrencyLocale
  */
 public function testImportCurrencyLocaleWithExistingCurrency()
 {
     $locale = $this->randomMachineName();
     $currency_locale = $this->getMock(CurrencyLocaleInterface::class);
     $this->currencyLocaleStorage->expects($this->never())->method('create');
     $this->currencyLocaleStorage->expects($this->once())->method('load')->with($locale)->willReturn($currency_locale);
     $this->configStorage->expects($this->never())->method('read');
     $this->sut->setConfigStorage($this->configStorage);
     $this->assertFalse($this->sut->importCurrencyLocale($locale));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:13,代码来源:ConfigImporterTest.php

示例14: testBuild

 /**
  * Tests the building of a full page variant.
  *
  * @covers ::build
  * @covers ::getRegionAssignments
  */
 public function testBuild()
 {
     $theme = $this->randomMachineName();
     $display_variant = $this->setUpDisplayVariant();
     $this->themeNegotiator->expects($this->any())->method('determineActiveTheme')->with($this->routeMatch)->will($this->returnValue($theme));
     $display_variant->expects($this->once())->method('getRegionNames')->will($this->returnValue(array('top' => 'Top', 'bottom' => 'Bottom')));
     $blocks_config = array('block1' => array(TRUE, 'top', 0), 'block2' => array(FALSE, 'bottom', 0), 'block3' => array(TRUE, 'bottom', 5), 'block4' => array(TRUE, 'bottom', -5));
     $blocks = array();
     foreach ($blocks_config as $block_id => $block_config) {
         $block = $this->getMock('Drupal\\block\\BlockInterface');
         $block->expects($this->once())->method('access')->will($this->returnValue($block_config[0]));
         $block->expects($this->any())->method('get')->will($this->returnValueMap(array(array('region', $block_config[1]), array('weight', $block_config[2]), array('status', TRUE))));
         $blocks[$block_id] = $block;
     }
     $this->blockViewBuilder->expects($this->exactly(3))->method('view')->will($this->returnValue(array()));
     $this->blockStorage->expects($this->once())->method('loadByProperties')->with(array('theme' => $theme))->will($this->returnValue($blocks));
     $expected = array('top' => array('block1' => array(), '#sorted' => TRUE), 'bottom' => array('block4' => array(), 'block3' => array(), '#sorted' => TRUE));
     $this->assertSame($expected, $display_variant->build());
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:25,代码来源:FullPageVariantTest.php

示例15: testResolveCurrencyLocaleMissingFallback

 /**
  * @covers ::resolveCurrencyLocale
  *
  * @expectedException \RuntimeException
  */
 function testResolveCurrencyLocaleMissingFallback()
 {
     $this->prepareLanguageManager();
     $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
     $config->expects($this->any())->method('get')->with('country.default')->willReturn(NULL);
     $this->configFactory->expects($this->once())->method('get')->with('system.data')->willReturn($config);
     $this->currencyLocaleStorage->expects($this->any())->method('load')->with(LocaleResolverInterface::DEFAULT_LOCALE)->willReturn(NULL);
     // Test loading the fallback locale.
     $this->sut->resolveCurrencyLocale();
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:15,代码来源:LocaleResolverTest.php


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