TextFieldRdfaTest.php in Drupal 10
File
core/modules/rdf/tests/src/Kernel/Field/TextFieldRdfaTest.php
View source
<?php
namespace Drupal\Tests\rdf\Kernel\Field;
use Drupal\entity_test\Entity\EntityTest;
class TextFieldRdfaTest extends FieldRdfaTestBase {
protected $fieldType = 'text';
protected $testValue = 'test_text_value';
protected $testSummary = 'test_summary_value';
protected static $modules = [
'text',
'filter',
];
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'filter',
]);
$this
->createTestField();
$mapping = rdf_get_mapping('entity_test', 'entity_test');
$mapping
->setFieldMapping($this->fieldName, [
'properties' => [
'schema:text',
],
])
->save();
$this->entity = EntityTest::create();
$this->entity->{$this->fieldName}->value = $this->testValue;
$this->entity->{$this->fieldName}->summary = $this->testSummary;
}
public function testAllFormatters() {
$formatted_value = strip_tags($this->entity->{$this->fieldName}->processed);
$this
->assertFormatterRdfa([
'type' => 'text_default',
], 'http://schema.org/text', [
'value' => $formatted_value,
]);
$this
->assertFormatterRdfa([
'type' => 'text_summary_or_trimmed',
], 'http://schema.org/text', [
'value' => $formatted_value,
]);
$this
->assertFormatterRdfa([
'type' => 'text_trimmed',
], 'http://schema.org/text', [
'value' => $formatted_value,
]);
}
}