setUpEntityType example

->setTranslatable(TRUE)
      ->setSetting('max_length', 255);

    // A base field with cardinality > 1     $this->commonBaseFields['string'] = BaseFieldDefinition::create('string')
      ->setLabel('Strong')
      ->setTranslatable(TRUE)
      ->setCardinality(2);

    // Set up the basic 'entity_test' entity type. This is used by several     // tests; others customize it and the base fields.     $this->setUpEntityType($this->baseEntityType, $this->commonBaseFields);
  }

  /** * Mocks an entity type and its base fields. * * This works by: * - inserting the entity type definition into the entity type manager's cache * - setting the base fields on the ViewsTestEntity class as a static property * for its baseFieldsDefinitions() method to use. * * @param \Drupal\Core\Entity\EntityTypeInterface $definition * An entity type definition to add to the entity type manager. * @param \Drupal\Core\Field\BaseFieldDefinition[] $base_fields * An array of base field definitions */
'id' => 'example_entity_type',
    ];
    return new EntityType($definition);
  }

  /** * @covers ::get * * @dataProvider providerTestGet */
  public function testGet(array $definition$key$expected) {
    $entity_type = $this->setUpEntityType($definition);
    $this->assertSame($expected$entity_type->get($key));
  }

  /** * @covers ::set * @covers ::get * * @dataProvider providerTestSet */
  public function testSet($key$value) {
    $entity_type = $this->setUpEntityType([]);
    
protected function setUpEntityType($definition) {
    $definition += [
      'id' => 'example_entity_type',
    ];
    return new EntityType($definition);
  }

  /** * Tests that the EntityType object can be serialized. */
  public function testIsSerializable() {
    $entity_type = $this->setUpEntityType([]);

    $translation_service = new class D) extends TranslationManager {

      /** * Constructs a UnserializableTranslationManager object. */
      public function __construct() {
      }

      /** * @return array */
Home | Imprint | This part of the site doesn't use cookies.