protected function WebTestBase::drupalCreateContentType

Creates a custom content type based on default settings.

Parameters

$settings: An array of settings to change from the defaults. Example: 'type' => 'foo'.

Return value

Created content type.

59 calls to WebTestBase::drupalCreateContentType()
AggregatorTestBase::setUp in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
Sets up a Drupal site for running functional and integration tests.
AlterTest::setUp in drupal/core/modules/field_ui/lib/Drupal/field_ui/Tests/AlterTest.php
Sets up a Drupal site for running functional and integration tests.
BasicTest::testViewsWizardAndListing in drupal/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php
CascadingStylesheetsTest::testRenderInlineFullPage in drupal/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
Tests rendering inline stylesheets through a full page request.
CommentFieldsTest::testCommentDefaultFields in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php
Tests that the default 'comment_body' field is correctly added.

... See full list

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 298
Definition of Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalCreateContentType($settings = array()) {

  // Find a non-existent random type name.
  do {
    $name = strtolower($this
      ->randomName(8));
  } while (node_type_load($name));

  // Populate defaults array.
  $defaults = array(
    'type' => $name,
    'name' => $name,
    'base' => 'node_content',
    'description' => '',
    'help' => '',
    'title_label' => 'Title',
    'body_label' => 'Body',
    'has_title' => 1,
    'has_body' => 1,
  );

  // Imposed values for a custom type.
  $forced = array(
    'orig_type' => '',
    'old_type' => '',
    'module' => 'node',
    'custom' => 1,
    'modified' => 1,
    'locked' => 0,
  );
  $type = $forced + $settings + $defaults;
  $type = (object) $type;
  $saved_type = node_type_save($type);
  node_types_rebuild();
  menu_router_rebuild();
  node_add_body_field($type);
  $this
    ->assertEqual($saved_type, SAVED_NEW, t('Created content type %type.', array(
    '%type' => $type->type,
  )));

  // Reset permissions so that permissions for this content type are available.
  $this
    ->checkPermissions(array(), TRUE);
  return $type;
}