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


PHP FieldUnitTestBase::setUp方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create a 'test_field' field and storage for validation.
     entity_create('field_storage_config', array('field_name' => $this->field_name, 'entity_type' => 'entity_test', 'type' => 'test_field'))->save();
     entity_create('field_config', array('entity_type' => 'entity_test', 'field_name' => $this->field_name, 'bundle' => 'entity_test'))->save();
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:7,代码来源:TestItemTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_rev');
     $this->storage = \Drupal::entityManager()->getStorage('entity_test');
     $this->storage_rev = \Drupal::entityManager()->getStorage('entity_test_rev');
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:10,代码来源:FieldDataCountTest.php

示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create a telephone field storage and field for validation.
     entity_create('field_storage_config', array('field_name' => 'field_test', 'entity_type' => 'entity_test', 'type' => 'telephone'))->save();
     entity_create('field_config', array('entity_type' => 'entity_test', 'field_name' => 'field_test', 'bundle' => 'entity_test'))->save();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:7,代码来源:TelephoneItemTest.php

示例4: setUp

 /**
  * {@inheritdoc}
  *
  * This sets up the entity_test and user types to use our example
  * field plugins.
  */
 protected function setUp()
 {
     array_unshift(self::$modules, 'field_permission_example');
     parent::setUp();
     // Tests for SimpleTest cannot usefully implement
     // ContainerInjectionInterface the way PHPUnit tests do.
     // We instead use KernelTest class' supplied container
     // to get services we require.
     $type_manager = $this->container->get('entity_type.manager');
     // Set up our entity_type and user type for our new field:
     $type_manager->getStorage('field_storage_config')->create(['field_name' => 'field_fieldnote', 'entity_type' => 'entity_test', 'type' => 'field_permission_example_fieldnote'])->save();
     $type_manager->getStorage('field_config')->create(['entity_type' => 'entity_test', 'field_name' => 'field_fieldnote', 'bundle' => 'entity_test'])->save();
     // Create a form display for the default form mode, and
     // add our field type.
     $type_manager->getStorage('entity_form_display')->create(['targetEntityType' => 'entity_test', 'bundle' => 'entity_test', 'mode' => 'default', 'status' => TRUE])->setComponent('field_fieldnote', ['type' => 'field_permission_example_widget'])->save();
     // Now do this for the user type.
     $type_manager->getStorage('field_storage_config')->create(['field_name' => 'user_fieldnote', 'entity_type' => 'user', 'type' => 'field_permission_example_fieldnote'])->save();
     $type_manager->getStorage('field_config')->create(['entity_type' => 'user', 'field_name' => 'user_fieldnote', 'bundle' => 'user'])->save();
     // Fetch a form display for a user. Most likely, this will already
     // exist, so check as Core does.
     // @see https://api.drupal.org/api/drupal/core%21includes%21entity.inc/function/entity_get_form_display/8
     $entity_form_display = $type_manager->getStorage('entity_form_display')->load('user.user.default');
     if (empty($entity_form_display)) {
         $entity_form_display = $type_manager->getStorage('entity_form_display')->create(['targetEntityType' => 'user', 'bundle' => 'user', 'mode' => 'default', 'status' => TRUE]);
     }
     // And add our fancy field to that display:
     $entity_form_display->setComponent('field_fieldnote', ['type' => 'field_permission_example_widget'])->save();
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:34,代码来源:FieldNoteItemTest.php

示例5: setUp

 public function setUp()
 {
     parent::setUp();
     // Create an link field and instance for validation.
     entity_create('field_storage_config', array('name' => 'field_test', 'entity_type' => 'entity_test', 'type' => 'link'))->save();
     entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => 'field_test', 'bundle' => 'entity_test'))->save();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:7,代码来源:LinkItemTest.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->container->get('router.builder')->rebuild();
     $this->installEntitySchema('entity_test_rev');
     $this->createFieldWithStorage();
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:7,代码来源:FieldAttachOtherTest.php

示例7: setUp

 /**
  * Sets up the test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_string_id');
     $this->installEntitySchema('taxonomy_term');
     $this->installEntitySchema('node');
     $this->installEntitySchema('comment');
     $this->installEntitySchema('file');
     $this->installSchema('comment', ['comment_entity_statistics']);
     $this->installSchema('node', ['node_access']);
     $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->vocabulary->save();
     $this->term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'vid' => $this->vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->term->save();
     $this->entityStringId = EntityTestStringId::create(['id' => $this->randomMachineName()]);
     $this->entityStringId->save();
     // Use the util to create an instance.
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_taxonomy_term', 'Test content entity reference', 'taxonomy_term');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_entity_test_string_id', 'Test content entity reference with string ID', 'entity_test_string_id');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_taxonomy_vocabulary', 'Test config entity reference', 'taxonomy_vocabulary');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_node', 'Test node entity reference', 'node', 'default', [], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_user', 'Test user entity reference', 'user');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_comment', 'Test comment entity reference', 'comment');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_file', 'Test file entity reference', 'file');
 }
开发者ID:Wylbur,项目名称:gj,代码行数:28,代码来源:EntityReferenceItemTest.php

示例8: setUp

 function setUp()
 {
     parent::setUp();
     $this->fieldStorageDefinition = array('field_name' => Unicode::strtolower($this->randomMachineName()), 'entity_type' => 'entity_test', 'type' => 'test_field');
     $this->fieldStorage = entity_create('field_storage_config', $this->fieldStorageDefinition);
     $this->fieldStorage->save();
     $this->fieldDefinition = array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test');
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:8,代码来源:FieldCrudTest.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_rev');
     // Create the necessary formats.
     $this->installConfig(array('filter'));
     entity_create('filter_format', array('format' => 'no_filters', 'filters' => array()))->save();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:8,代码来源:TextWithSummaryItemTest.php

示例10: setUp

 public function setUp()
 {
     parent::setUp();
     // Create number fields and instances for validation.
     foreach (array('integer', 'float', 'decimal') as $type) {
         entity_create('field_storage_config', array('name' => 'field_' . $type, 'entity_type' => 'entity_test', 'type' => $type))->save();
         entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => 'field_' . $type, 'bundle' => 'entity_test'))->save();
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:9,代码来源:NumberItemTest.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     // Create a field with settings to validate.
     $field_storage = entity_create('field_storage_config', array('name' => 'field_datetime', 'type' => 'datetime', 'entity_type' => 'entity_test', 'settings' => array('datetime_type' => 'date')));
     $field_storage->save();
     $instance = entity_create('field_instance_config', array('field_storage' => $field_storage, 'bundle' => 'entity_test', 'settings' => array('default_value' => 'blank')));
     $instance->save();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:9,代码来源:DateTimeItemTest.php

示例12: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     entity_create('field_storage_config', ['field_name' => 'field_test', 'entity_type' => 'entity_test', 'type' => 'video_embed_field'])->save();
     entity_create('field_config', ['entity_type' => 'entity_test', 'field_name' => 'field_test', 'bundle' => 'entity_test'])->save();
     // Fake colorbox being enabled for the purposes of testing.
     $module_handler = \Drupal::moduleHandler();
     $module_handler->addModule('colorbox', NULL);
 }
开发者ID:C4AProjects,项目名称:c4apage,代码行数:12,代码来源:EmbedFieldTest.php

示例13: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create a boolean field and storage for validation.
     entity_create('field_storage_config', array('field_name' => 'field_boolean', 'entity_type' => 'entity_test', 'type' => 'boolean'))->save();
     entity_create('field_config', array('entity_type' => 'entity_test', 'field_name' => 'field_boolean', 'bundle' => 'entity_test'))->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent('field_boolean', array('type' => 'boolean_checkbox'))->save();
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:12,代码来源:BooleanItemTest.php

示例14: setUp

 public function setUp()
 {
     parent::setUp();
     // Create an email field and instance for validation.
     entity_create('field_storage_config', array('name' => 'field_email', 'entity_type' => 'entity_test', 'type' => 'email'))->save();
     entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => 'field_email', 'bundle' => 'entity_test'))->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent('field_email', array('type' => 'email_default'))->save();
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:9,代码来源:EmailItemTest.php

示例15: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->installSchema('system', array('router'));
     $this->fieldStorageDefinition = array('name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'list_integer', 'cardinality' => 1, 'settings' => array('allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three')));
     $this->fieldStorage = entity_create('field_storage_config', $this->fieldStorageDefinition);
     $this->fieldStorage->save();
     $this->instance = entity_create('field_instance_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test'));
     $this->instance->save();
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($this->fieldName, array('type' => 'options_buttons'))->save();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:14,代码来源:OptionsFieldUnitTestBase.php


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