Error message

  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).

function TmgmtEntityTestTrait::createNodeType

Creates node type with several text fields with different cardinality.

Internally it calls TMGMTEntityTestCaseUtility::attachFields() to create and attach fields to newly created bundle. You can than use $this->field_names['node']['YOUR_BUNDLE_NAME'] to access them.

Parameters

string $machine_name: Machine name of the node type.

string $human_name: Human readable name of the node type.

bool $translation: TRUE if translation for this enitty type should be enabled. pparam bool $attach_fields (optional) If fields with the same translatability should automatically be attached to the node type.

12 calls to TmgmtEntityTestTrait::createNodeType()
ConfigSourceUiTest::setUp in sources/tmgmt_config/tests/src/Functional/ConfigSourceUiTest.php
Overrides DrupalWebTestCase::setUp()
ContentEntitySourceContentModerationTest::setUp in sources/content/tests/src/Functional/ContentEntitySourceContentModerationTest.php
Overrides DrupalWebTestCase::setUp()
ContentEntitySourceContentModerationTest::testModerationWithUntranslatableCompositeEntityReference in sources/content/tests/src/Functional/ContentEntitySourceContentModerationTest.php
Tests content moderation translations with untranslatable composites.
ContentTmgmtEntitySourceListTest::setUp in sources/content/tests/src/Functional/ContentTmgmtEntitySourceListTest.php
Overrides DrupalWebTestCase::setUp()
ContentTmgmtEntitySourceUiTest::setUp in sources/content/tests/src/Functional/ContentTmgmtEntitySourceUiTest.php
Overrides DrupalWebTestCase::setUp()

... See full list

File

tests/src/Functional/TmgmtEntityTestTrait.php, line 43

Class

TmgmtEntityTestTrait
Utility test case class with helper methods to create entities and their fields with populated translatable content. Extend this class if you create tests in which you need Drupal entities and/or fields.

Namespace

Drupal\Tests\tmgmt\Functional

Code

function createNodeType($machine_name, $human_name, $translation = FALSE, $attach_fields = TRUE) {
  $type = $this
    ->drupalCreateContentType(array(
    'type' => $machine_name,
    'name' => $human_name,
  ));

  // Push in also the body field.
  $this->field_names['node'][$machine_name][] = 'body';
  if (\Drupal::hasService('content_translation.manager') && $translation) {
    $content_translation_manager = \Drupal::service('content_translation.manager');
    $content_translation_manager
      ->setEnabled('node', $machine_name, TRUE);
  }
  if ($attach_fields) {
    $this
      ->attachFields('node', $machine_name, $translation);
  }
  else {

    // Change body field to be translatable.
    $body = FieldConfig::loadByName('node', $machine_name, 'body');
    $body
      ->setTranslatable(TRUE);
    $body
      ->save();
  }
}