• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Entity\EntityUnitTestBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Drupal\system\Tests\Entity\EntityUnitTestBase的典型用法代码示例。如果您正苦于以下问题:PHP EntityUnitTestBase类的具体用法?PHP EntityUnitTestBase怎么用?PHP EntityUnitTestBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_rev');
     // Create a field.
     $this->createEntityReferenceField($this->entityType, $this->bundle, $this->fieldName, 'Field test', $this->referencedEntityType, 'default', array('target_bundles' => array($this->bundle)), FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:10,代码来源:EntityReferenceFieldTest.php


示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->languageManager = $this->container->get('language_manager');
     $this->installEntitySchema('entity_test_rev');
     $this->installEntitySchema('entity_test_mul');
     $this->installEntitySchema('entity_test_mulrev');
     $this->installConfig(array('language'));
     // Create the test field.
     entity_test_install();
     // Enable translations for the test entity type.
     $this->state->set('entity_test.translation', TRUE);
     // Create a translatable test field.
     $this->field_name = drupal_strtolower($this->randomMachineName() . '_field_name');
     // Create an untranslatable test field.
     $this->untranslatable_field_name = drupal_strtolower($this->randomMachineName() . '_field_name');
     // Create field fields in all entity variations.
     foreach (entity_test_entity_types() as $entity_type) {
         entity_create('field_storage_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
         entity_create('field_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE))->save();
         $this->field[$entity_type] = entity_load('field_config', $entity_type . '.' . $entity_type . '.' . $this->field_name);
         entity_create('field_storage_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
         entity_create('field_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE))->save();
     }
     // Create the default languages.
     $this->installConfig(array('language'));
     // Create test languages.
     $this->langcodes = array();
     for ($i = 0; $i < 3; ++$i) {
         $language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString(), 'weight' => $i));
         $this->langcodes[$i] = $language->getId();
         $language->save();
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:34,代码来源:EntityLanguageTestBase.php


示例3: setUp

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();

    $this->installSchema('search_api', array('search_api_item', 'search_api_task'));
    $this->installSchema('system', array('router'));
    $this->installSchema('user', array('users_data'));

    $this->setUpExampleStructure();

    $this->installConfig(array('search_api_test_db'));

    $this->insertExampleContent();

    // Create a test server.
    $this->server = Server::create(array(
      'name' => $this->randomString(),
      'id' => $this->randomMachineName(),
      'status' => 1,
      'backend' => 'search_api_test_backend',
    ));
    $this->server->save();

    $this->index = Index::load('database_search_index');
    $this->index->setServer($this->server);
  }
开发者ID:jkyto,项目名称:agolf,代码行数:28,代码来源:CustomDataTypesUnitTest.php


示例4: setUp

 /**
  * Set the default field storage backend for fields created during tests.
  */
 protected function setUp()
 {
     parent::setUp();
     // Create a node type for testing.
     $type = entity_create('node_type', array('type' => 'page', 'name' => 'page'));
     $type->save();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:NodeValidationTest.php


示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     // Use Classy theme for testing markup output.
     \Drupal::service('theme_handler')->install(['classy']);
     \Drupal::service('theme_handler')->setDefault('classy');
     // Grant the 'view test entity' permission.
     $this->installConfig(array('user'));
     Role::load(RoleInterface::ANONYMOUS_ID)->grantPermission('view test entity')->save();
     // The label formatter rendering generates links, so build the router.
     $this->container->get('router.builder')->rebuild();
     $this->createEntityReferenceField($this->entityType, $this->bundle, $this->fieldName, 'Field test', $this->entityType, 'default', array(), FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     // Set up a field, so that the entity that'll be referenced bubbles up a
     // cache tag when rendering it entirely.
     FieldStorageConfig::create(array('field_name' => 'body', 'entity_type' => $this->entityType, 'type' => 'text', 'settings' => array()))->save();
     FieldConfig::create(['entity_type' => $this->entityType, 'bundle' => $this->bundle, 'field_name' => 'body', 'label' => 'Body'])->save();
     entity_get_display($this->entityType, $this->bundle, 'default')->setComponent('body', array('type' => 'text_default', 'settings' => array()))->save();
     FilterFormat::create(array('format' => 'full_html', 'name' => 'Full HTML'))->save();
     // Create the entity to be referenced.
     $this->referencedEntity = $this->container->get('entity_type.manager')->getStorage($this->entityType)->create(array('name' => $this->randomMachineName()));
     $this->referencedEntity->body = array('value' => '<p>Hello, world!</p>', 'format' => 'full_html');
     $this->referencedEntity->save();
     // Create another entity to be referenced but do not save it.
     $this->unsavedReferencedEntity = $this->container->get('entity_type.manager')->getStorage($this->entityType)->create(array('name' => $this->randomMachineName()));
     $this->unsavedReferencedEntity->body = array('value' => '<p>Hello, unsaved world!</p>', 'format' => 'full_html');
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:26,代码来源:EntityReferenceFormatterTest.php


示例6: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $session = new Session();
     $request = Request::create('/');
     $request->setSession($session);
     /** @var RequestStack $stack */
     $stack = $this->container->get('request_stack');
     $stack->pop();
     $stack->push($request);
     // Set the current user to one that can access comments. Specifically, this
     // user does not have access to the 'administer comments' permission, to
     // ensure only published comments are visible to the end user.
     $current_user = $this->container->get('current_user');
     $current_user->setAccount($this->createUser(array(), array('access comments')));
     // Install tables and config needed to render comments.
     $this->installSchema('comment', array('comment_entity_statistics'));
     $this->installConfig(array('system', 'filter', 'comment'));
     // Comment rendering generates links, so build the router.
     $this->installSchema('system', array('router'));
     $this->container->get('router.builder')->rebuild();
     // Set up a field, so that the entity that'll be referenced bubbles up a
     // cache tag when rendering it entirely.
     $this->addDefaultCommentField('entity_test', 'entity_test');
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:28,代码来源:CommentDefaultFormatterCacheTagsTest.php


示例7: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     entity_create('filter_format', array('format' => 'my_text_format', 'name' => 'My text format', 'filters' => array('filter_autop' => array('module' => 'filter', 'status' => TRUE))))->save();
     entity_create('field_storage_config', array('field_name' => 'formatted_text', 'entity_type' => $this->entityType, 'type' => 'text', 'settings' => array()))->save();
     entity_create('field_config', array('entity_type' => $this->entityType, 'bundle' => $this->bundle, 'field_name' => 'formatted_text', 'label' => 'Filtered text'))->save();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:TextFormatterTest.php


示例8: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installConfig(array('user', 'entity_test'));
     // Give anonymous users permission to view test entities.
     Role::load(RoleInterface::ANONYMOUS_ID)->grantPermission('view test entity')->save();
 }
开发者ID:komejo,项目名称:article-test,代码行数:10,代码来源:EntityViewBuilderTest.php


示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_rev');
     $this->installEntitySchema('entity_test_mul');
     $this->installEntitySchema('entity_test_mulrev');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:7,代码来源:EntityApiTest.php


示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('taxonomy_term');
     // We want an entity reference field. It needs a vocabulary, terms, a field
     // storage and a field. First, create the vocabulary.
     $vocabulary = entity_create('taxonomy_vocabulary', array('vid' => Unicode::strtolower($this->randomMachineName())));
     $vocabulary->save();
     // Second, create the field.
     entity_test_create_bundle('test_bundle');
     $this->fieldName = strtolower($this->randomMachineName());
     $handler_settings = array('target_bundles' => array($vocabulary->id() => $vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('entity_test', 'test_bundle', $this->fieldName, NULL, 'taxonomy_term', 'default', $handler_settings);
     // Create two terms and also two accounts.
     for ($i = 0; $i <= 1; $i++) {
         $term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'vid' => $vocabulary->id()));
         $term->save();
         $this->terms[] = $term;
         $this->accounts[] = $this->createUser();
     }
     // Create three entity_test entities, the 0th entity will point to the
     // 0th account and 0th term, the 1st and 2nd entity will point to the
     // 1st account and 1st term.
     for ($i = 0; $i <= 2; $i++) {
         $entity = entity_create('entity_test', array('type' => 'test_bundle'));
         $entity->name->value = $this->randomMachineName();
         $index = $i ? 1 : 0;
         $entity->user_id->target_id = $this->accounts[$index]->id();
         $entity->{$this->fieldName}->target_id = $this->terms[$index]->id();
         $entity->save();
         $this->entities[] = $entity;
     }
     $this->factory = \Drupal::service('entity.query');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:34,代码来源:EntityQueryRelationshipTest.php


示例11: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Enable an additional language.
     ConfigurableLanguage::createFromLangcode('de')->save();
     $this->installEntitySchema('entity_test_mulrev');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:EntityRevisionTranslationTest.php


示例12: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installConfig(array('user'));
     $this->installEntitySchema('comment');
     $this->installSchema('comment', array('comment_entity_statistics'));
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:CommentFieldAccessTest.php


示例13: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('taxonomy_term');
     // We want a taxonomy term reference field. It needs a vocabulary, terms,
     // a field storage and a field. First, create the vocabulary.
     $vocabulary = entity_create('taxonomy_vocabulary', array('vid' => Unicode::strtolower($this->randomMachineName())));
     $vocabulary->save();
     // Second, create the field.
     $this->fieldName = strtolower($this->randomMachineName());
     entity_create('field_storage_config', array('field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', 'settings' => array('allowed_values' => array(array('vocabulary' => $vocabulary->id())))))->save();
     entity_test_create_bundle('test_bundle');
     // Third, create the instance.
     entity_create('field_config', array('entity_type' => 'entity_test', 'field_name' => $this->fieldName, 'bundle' => 'test_bundle'))->save();
     // Create two terms and also two accounts.
     for ($i = 0; $i <= 1; $i++) {
         $term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'vid' => $vocabulary->id()));
         $term->save();
         $this->terms[] = $term;
         $this->accounts[] = $this->createUser();
     }
     // Create three entity_test entities, the 0th entity will point to the
     // 0th account and 0th term, the 1st and 2nd entity will point to the
     // 1st account and 1st term.
     for ($i = 0; $i <= 2; $i++) {
         $entity = entity_create('entity_test', array('type' => 'test_bundle'));
         $entity->name->value = $this->randomMachineName();
         $index = $i ? 1 : 0;
         $entity->user_id->target_id = $this->accounts[$index]->id();
         $entity->{$this->fieldName}->target_id = $this->terms[$index]->id();
         $entity->save();
         $this->entities[] = $entity;
     }
     $this->factory = \Drupal::service('entity.query');
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:35,代码来源:EntityQueryRelationshipTest.php


示例14: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installConfig(array('user'));
     $this->user = $this->createUser();
     \Drupal::service('current_user')->setAccount($this->user);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:NodeFieldOverridesTest.php


示例15: setUp

 /**
  * Set the default field storage backend for fields created during tests.
  */
 protected function setUp()
 {
     parent::setUp();
     // Create a node type for testing.
     $type = NodeType::create(['type' => 'page', 'name' => 'page']);
     $type->save();
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:10,代码来源:NodeValidationTest.php


示例16: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('node');
     $this->installEntitySchema('comment');
     $this->installSchema('comment', array('comment_entity_statistics'));
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:CommentValidationTest.php


示例17: setUp

 public function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_rev');
     // Setup a field and instance.
     entity_reference_create_instance($this->entityType, $this->bundle, $this->fieldName, 'Field test', $this->referencedEntityType, 'default', array('target_bundles' => array($this->bundle)), FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:7,代码来源:EntityReferenceFieldTest.php


示例18: setUp

 public function setUp()
 {
     parent::setUp();
     // Install default system configuration.
     $this->installConfig(array('system'));
     $this->interfaceLanguage = \Drupal::languageManager()->getCurrentLanguage();
     $this->tokenService = \Drupal::token();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:8,代码来源:TokenReplaceUnitTestBase.php


示例19: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create the test field.
     entity_test_install();
     // Install required default configuration for filter module.
     $this->installConfig(array('system', 'filter'));
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:11,代码来源:EntityValidationTest.php


示例20: setUp

 /**
  * Set the default field storage backend for fields created during tests.
  */
 public function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('node');
     // Create a node type for testing.
     $type = entity_create('node_type', array('type' => 'page', 'name' => 'page'));
     $type->save();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:NodeValidationTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP taxonomy\VocabularyInterface类代码示例发布时间:2022-05-23
下一篇:
PHP simpletest\WebTestBase类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap