protected function BlazyCreationTestTrait::setUpContentTypeTest in Blazy 8.2
Same name and namespace in other branches
- 8 tests/src/Traits/BlazyCreationTestTrait.php \Drupal\Tests\blazy\Traits\BlazyCreationTestTrait::setUpContentTypeTest()
Build dummy content types.
Parameters
string $bundle: The bundle name.
array $settings: (Optional) configurable settings.
8 calls to BlazyCreationTestTrait::setUpContentTypeTest()
- BlazyBlazyJavaScriptTest::testFormatterDisplay in tests/
src/ FunctionalJavascript/ BlazyBlazyJavaScriptTest.php - Test the Blazy element from loading to loaded states.
- BlazyCreationTestTrait::setUpContentWithEntityReference in tests/
src/ Traits/ BlazyCreationTestTrait.php - Build dummy contents with entity references.
- BlazyEntityTest::setUp in tests/
src/ Kernel/ BlazyEntityTest.php - Set the default field storage backend for fields created during tests.
- BlazyFilterJavaScriptTest::testFilterDisplay in tests/
src/ FunctionalJavascript/ BlazyFilterJavaScriptTest.php - Test the Blazy filter has media-wrapper--blazy for IMG and IFRAME elements.
- BlazyFormatterTest::setUp in tests/
src/ Kernel/ BlazyFormatterTest.php - Set the default field storage backend for fields created during tests.
File
- tests/
src/ Traits/ BlazyCreationTestTrait.php, line 144
Class
- BlazyCreationTestTrait
- A Trait common for Blazy tests.
Namespace
Drupal\Tests\blazy\TraitsCode
protected function setUpContentTypeTest($bundle = '', array $settings = []) {
$node_type = NodeType::load($bundle);
$full_html = $this->blazyManager
->entityLoad('full_html', 'filter_format');
$restricted_html = $this->blazyManager
->entityLoad('restricted_html', 'filter_format');
if (empty($node_type)) {
$node_type = NodeType::create([
'type' => $bundle,
'name' => $bundle,
]);
$node_type
->save();
}
if (!$restricted_html && is_null($this->filterFormatRestricted)) {
$this->filterFormatRestricted = FilterFormat::create([
'format' => 'restricted_html',
'name' => 'Basic HML',
'weight' => 2,
'filters' => [],
])
->save();
}
else {
$this->filterFormatRestricted = $restricted_html;
}
if (!$full_html && is_null($this->filterFormatFull)) {
$this->filterFormatFull = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HML',
'weight' => 3,
])
->save();
}
else {
$this->filterFormatFull = $full_html;
}
node_add_body_field($node_type);
if (!empty($this->testFieldName)) {
$settings['fields'][$this->testFieldName] = empty($this->testFieldType) ? 'image' : $this->testFieldType;
}
if (!empty($settings['field_name']) && !empty($settings['field_type'])) {
$settings['fields'][$settings['field_name']] = $settings['field_type'];
}
$data = [];
if (!empty($settings['fields'])) {
foreach ($settings['fields'] as $field_name => $field_type) {
$data['field_name'] = $field_name;
$data['field_type'] = $field_type;
$this
->setUpFieldConfig($bundle, $data);
}
}
$node_type
->save();
return $node_type;
}