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


PHP FieldDefinitionInterface::expects方法代码示例

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


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

示例1: testMassageFormValues

 /**
  * @covers ::massageFormValues
  */
 public function testMassageFormValues()
 {
     $field_name = $this->randomMachineName();
     $payment_id = mt_rand();
     $this->fieldDefinition->expects($this->atLeastOnce())->method('getName')->willReturn($field_name);
     $form_state = $this->getMock(FormStateInterface::class);
     $form[$field_name]['widget']['target_id']['#value'] = $payment_id;
     $values = [];
     $expected_value = array('target_id' => $payment_id);
     $this->assertSame($expected_value, $this->sut->massageFormValues($values, $form, $form_state));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:14,代码来源:PaymentReferenceTest.php

示例2: testMatch

 /**
  * Tests the match method.
  */
 public function testMatch()
 {
     $this->field->expects($this->any())->method('getType')->will($this->returnValue('crap'));
     $this->contact->expects($this->any())->method('getFieldDefinitions')->will($this->returnValue(array('foo' => $this->field)));
     $this->pluginManager->expects($this->any())->method('hasDefinition')->will($this->returnValue(TRUE));
     $this->matchHandler->expects($this->any())->method('match')->will($this->returnValue(array('42' => array('value' => 100))));
     //    $this->pluginManager->expects($this->once())
     //      ->method('createInstance')
     //      ->will($this->returnValue($this->matchHandler));
     //    $ids = $this->engine->match($this->contact);
     //    $this->assertEquals([], $ids);
 }
开发者ID:jasonruyle,项目名称:crm_core,代码行数:15,代码来源:DefaultEngineTest.php

示例3: testFormElementProcess

 /**
  * @covers ::formElementProcess
  */
 public function testFormElementProcess()
 {
     $field_storage_definition = $this->getMock(FieldStorageDefinitionInterface::class);
     $this->fieldDefinition->expects($this->atLeastOnce())->method('getFieldStorageDefinition')->willReturn($field_storage_definition);
     $iterator = new \ArrayIterator([(object) ['plugin_configuration' => [], 'plugin_id' => $this->randomMachineName()]]);
     $items = $this->getMockBuilder(FieldItemList::class)->disableOriginalConstructor()->setMethods(['getIterator'])->getMock();
     $items->expects($this->once())->method('getIterator')->willReturn($iterator);
     $element = ['#array_parents' => ['line_items'], '#items' => $items];
     $form = [];
     $form_state = $this->getMock(FormStateInterface::class);
     $element = $this->sut->formElementProcess($element, $form_state, $form);
     $this->assertInternalType('array', $element);
     $this->arrayHasKey('array_parents', $element);
     $this->arrayHasKey('line_items', $element);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:18,代码来源:PaymentFormTest.php

示例4: testViewElements

 /**
  * @covers ::viewElements
  */
 public function testViewElements()
 {
     $entity_type_id = $this->randomMachineName();
     $bundle = $this->randomMachineName();
     $field_name = $this->randomMachineName();
     $destination_url = $this->randomMachineName();
     $currency_code = $this->randomMachineName();
     $plugin_id = $this->randomMachineName();
     $plugin_configuration = [$this->randomMachineName() => $this->randomMachineName()];
     $plugin_id_property = $this->getMock(TypedDataInterface::class);
     $plugin_id_property->expects($this->once())->method('getValue')->willReturn($plugin_id);
     $plugin_configuration_property = $this->getMock(TypedDataInterface::class);
     $plugin_configuration_property->expects($this->once())->method('getValue')->willReturn($plugin_configuration);
     $map = [['plugin_id', $plugin_id_property], ['plugin_configuration', $plugin_configuration_property]];
     $item = $this->getMockBuilder(PaymentFormFieldType::class)->disableOriginalConstructor()->getMock();
     $item->expects($this->exactly(2))->method('get')->willReturnMap($map);
     $entity = $this->getMock(EntityInterface::class);
     $entity->expects($this->atLeastOnce())->method('bundle')->willReturn($bundle);
     $entity->expects($this->atLeastOnce())->method('getEntityTypeId')->willReturn($entity_type_id);
     $iterator = new \ArrayIterator([$item]);
     $items = $this->getMockBuilder(FieldItemList::class)->disableOriginalConstructor()->setMethods(['getEntity', 'getIterator'])->getMock();
     $items->expects($this->atLeastOnce())->method('getEntity')->willReturn($entity);
     $items->expects($this->atLeastOnce())->method('getIterator')->willReturn($iterator);
     $this->fieldDefinition->expects($this->once())->method('getName')->willReturn($field_name);
     $this->fieldDefinition->expects($this->atLeastOnce())->method('getSetting')->with('currency_code')->willReturn($currency_code);
     $payment_type = $this->getMockBuilder(PaymentFormPaymentType::class)->disableOriginalConstructor()->getMock();
     $payment_type->expects($this->once())->method('setEntityTypeId')->with($entity_type_id);
     $payment_type->expects($this->once())->method('setBundle')->with($bundle);
     $payment_type->expects($this->once())->method('setFieldName')->with($field_name);
     $payment_type->expects($this->once())->method('setDestinationUrl')->with($destination_url);
     $payment = $this->getMock(PaymentInterface::class);
     $payment->expects($this->once())->method('setCurrencyCode')->with($currency_code);
     $payment->expects($this->once())->method('getPaymentType')->willReturn($payment_type);
     $payment_line_item = $this->getMock(PaymentLineItemInterface::class);
     $this->paymentLineItemManager->expects($this->once())->method('createInstance')->with($plugin_id, $plugin_configuration)->willReturn($payment_line_item);
     $this->paymentStorage->expects($this->once())->method('create')->with(['bundle' => 'payment_form'])->willReturn($payment);
     $this->request->expects($this->atLeastOnce())->method('getUri')->willReturn($destination_url);
     $form = ['#foo' => $this->randomMachineName()];
     $this->entityFormBuilder->expects($this->once())->method('getForm')->with($payment, 'payment_form')->willReturn($form);
     $this->assertSame($form, $this->sut->viewElements($items, 'en'));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:44,代码来源:PaymentFormTest.php


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