protected function EntityDefaultLanguageTest::createNode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/language/src/Tests/EntityDefaultLanguageTest.php \Drupal\language\Tests\EntityDefaultLanguageTest::createNode()
Creates a new node of given type and language using Entity API.
Parameters
$type: The node content type.
$langcode: (optional) Language code to pass to entity create.
Return value
\Drupal\node\NodeInterface The node created.
1 call to EntityDefaultLanguageTest::createNode()
- EntityDefaultLanguageTest::testEntityTranslationDefaultLanguageViaCode in core/
modules/ language/ src/ Tests/ EntityDefaultLanguageTest.php - Tests that default language code is properly set for new nodes.
File
- core/
modules/ language/ src/ Tests/ EntityDefaultLanguageTest.php, line 134 - Contains \Drupal\language\Tests\EntityDefaultLanguageTest.
Class
- EntityDefaultLanguageTest
- Tests default language code is properly generated for entities.
Namespace
Drupal\language\TestsCode
protected function createNode($type, $langcode = NULL) {
$values = array(
'type' => $type,
'title' => $this
->randomString(),
);
if (!empty($langcode)) {
$values['langcode'] = $langcode;
}
$node = $this->container
->get('entity.manager')
->getStorage('node')
->create($values);
return $node;
}