當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tests\FieldUnitTestBase類代碼示例

本文整理匯總了PHP中Drupal\field\Tests\FieldUnitTestBase的典型用法代碼示例。如果您正苦於以下問題:PHP FieldUnitTestBase類的具體用法?PHP FieldUnitTestBase怎麽用?PHP FieldUnitTestBase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FieldUnitTestBase類的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類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。