protected function WebTestBase::drupalCreateContentType in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::drupalCreateContentType()
Creates a custom content type based on default settings.
Parameters
array $values: An array of settings to change from the defaults. Example: 'type' => 'foo'.
Return value
\Drupal\node\Entity\NodeType Created content type.
162 calls to WebTestBase::drupalCreateContentType()
- AggregatorTestBase::setUp in core/
modules/ aggregator/ src/ Tests/ AggregatorTestBase.php - Sets up a Drupal site for running functional and integration tests.
- BasicTest::testViewsWizardAndListing in core/
modules/ views/ src/ Tests/ Wizard/ BasicTest.php - BasicTest::testWizardForm in core/
modules/ views/ src/ Tests/ Wizard/ BasicTest.php - Tests the actual wizard form.
- BookTest::testBookNavigationCacheContext in core/
modules/ book/ src/ Tests/ BookTest.php - Tests the book navigation cache context.
- BooleanFormatterSettingsTest::setUp in core/
modules/ field/ src/ Tests/ Boolean/ BooleanFormatterSettingsTest.php - Sets up a Drupal site for running functional and integration tests.
File
- core/
modules/ simpletest/ src/ WebTestBase.php, line 311 - Contains \Drupal\simpletest\WebTestBase.
Class
- WebTestBase
- Test case for typical Drupal tests.
Namespace
Drupal\simpletestCode
protected function drupalCreateContentType(array $values = array()) {
// Find a non-existent random type name.
if (!isset($values['type'])) {
do {
$id = strtolower($this
->randomMachineName(8));
} while (NodeType::load($id));
}
else {
$id = $values['type'];
}
$values += array(
'type' => $id,
'name' => $id,
);
$type = entity_create('node_type', $values);
$status = $type
->save();
node_add_body_field($type);
\Drupal::service('router.builder')
->rebuild();
$this
->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created content type %type.', array(
'%type' => $type
->id(),
)));
return $type;
}