You are here

protected function FieldValidationRuleBase::setupTestArticle in Field Validation 8

Sets up the test article on which rules are tested.

Parameters

string $fieldName: Field name to set.

Throws

\Drupal\Core\Entity\EntityStorageException

13 calls to FieldValidationRuleBase::setupTestArticle()
BlackListFieldValidationRuleTest::setUp in tests/src/Kernel/Plugin/FieldValidationRule/BlackListFieldValidationRuleTest.php
DateRangeFieldValidationRuleTest::setUp in tests/src/Kernel/Plugin/FieldValidationRule/DateRangeFieldValidationRuleTest.php
EmailFieldValidationRuleTest::setUp in tests/src/Kernel/Plugin/FieldValidationRule/EmailFieldValidationRuleTest.php
IntegerFieldValidationTest::setUp in tests/src/Kernel/Plugin/FieldValidationRule/IntegerFieldValidationTest.php
IpFieldValidationRuleTest::setUp in tests/src/Kernel/Plugin/FieldValidationRule/IpFieldValidationRuleTest.php

... See full list

File

tests/src/Kernel/Plugin/FieldValidationRule/FieldValidationRuleBase.php, line 185

Class

FieldValidationRuleBase
FieldValidationRuleBase class.

Namespace

Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRule

Code

protected function setupTestArticle(string $fieldName) {
  NodeType::create([
    'type' => 'article',
    'label' => 'Article',
  ])
    ->save();
  FieldStorageConfig::create([
    'entity_type' => 'node',
    'field_name' => $fieldName,
    'type' => 'text',
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => 'node',
    'field_name' => $fieldName,
    'bundle' => 'article',
  ])
    ->save();
}