class TextFieldRdfaTest
Same name and namespace in other branches
- 8.9.x core/modules/rdf/tests/src/Kernel/Field/TextFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\TextFieldRdfaTest
Tests RDFa output by text field formatters.
@group rdf @group legacy
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\field\Kernel\FieldKernelTestBase implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\rdf\Kernel\Field\FieldRdfaTestBase uses \Drupal\Tests\rdf\Traits\RdfParsingTrait implements \Drupal\Tests\field\Kernel\FieldKernelTestBase
- class \Drupal\Tests\rdf\Kernel\Field\TextFieldRdfaTest implements \Drupal\Tests\rdf\Kernel\Field\FieldRdfaTestBase
- class \Drupal\Tests\rdf\Kernel\Field\FieldRdfaTestBase uses \Drupal\Tests\rdf\Traits\RdfParsingTrait implements \Drupal\Tests\field\Kernel\FieldKernelTestBase
- class \Drupal\Tests\field\Kernel\FieldKernelTestBase implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of TextFieldRdfaTest
File
-
core/
modules/ rdf/ tests/ src/ Kernel/ Field/ TextFieldRdfaTest.php, line 13
Namespace
Drupal\Tests\rdf\Kernel\FieldView source
class TextFieldRdfaTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
protected $fieldType = 'text';
/**
* The 'value' property value for testing.
*
* @var string
*/
protected $testValue = 'test_text_value';
/**
* The 'summary' property value for testing.
*
* @var string
*/
protected $testSummary = 'test_summary_value';
/**
* {@inheritdoc}
*/
protected static $modules = [
'text',
'filter',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installConfig([
'filter',
]);
$this->createTestField();
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
$mapping->setFieldMapping($this->fieldName, [
'properties' => [
'schema:text',
],
])
->save();
// Set up test entity.
$this->entity = EntityTest::create();
$this->entity->{$this->fieldName}->value = $this->testValue;
$this->entity->{$this->fieldName}->summary = $this->testSummary;
}
/**
* Tests all formatters.
*
* @todo Check for the summary mapping.
*/
public function testAllFormatters() {
$formatted_value = strip_tags($this->entity->{$this->fieldName}->processed);
// Tests the default formatter.
$this->assertFormatterRdfa([
'type' => 'text_default',
], 'http://schema.org/text', [
'value' => $formatted_value,
]);
// Tests the summary formatter.
$this->assertFormatterRdfa([
'type' => 'text_summary_or_trimmed',
], 'http://schema.org/text', [
'value' => $formatted_value,
]);
// Tests the trimmed formatter.
$this->assertFormatterRdfa([
'type' => 'text_trimmed',
], 'http://schema.org/text', [
'value' => $formatted_value,
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.