ContentEntityType example



  /** * Tests applying single updates. */
  public function testSingleActionCalls() {
    $db_schema = $this->database->schema();

    // Ensure that a non-existing entity type cannot be installed.     $message = 'A non-existing entity type cannot be installed';
    try {
      $this->entityDefinitionUpdateManager->installEntityType(new ContentEntityType(['id' => 'foo']));
      $this->fail($message);
    }
    catch (PluginNotFoundException $e) {
      // Expected exception; just continue testing.     }

    // Ensure that a field cannot be installed on non-existing entity type.     $message = 'A field cannot be installed on a non-existing entity type';
    try {
      $storage_definition = BaseFieldDefinition::create('string')
        ->setLabel(t('A new revisionable base field'))
        

  public function testGetSchemaBase() {
    $this->entityType = new ContentEntityType([
      'id' => 'entity_test',
      'entity_keys' => ['id' => 'id'],
    ]);

    // Add a field with a 'length' constraint.     $this->setUpStorageDefinition('name', [
      'columns' => [
        'value' => [
          'type' => 'varchar',
          'length' => 255,
        ],
      ],
$this->assertTrue($moderation_information->isModeratedEntityType($moderated_entity_type->reveal()));
    $this->assertFalse($moderation_information->isModeratedEntityType($unmoderated_entity_type->reveal()));
  }

  /** * @dataProvider providerWorkflow * @covers ::isModeratedEntity */
  public function testIsModeratedEntity($workflow$expected) {
    $moderation_information = new ModerationInformation($this->getEntityTypeManager()$this->setupModerationBundleInfo('test_bundle', $workflow));

    $entity_type = new ContentEntityType([
      'id' => 'test_entity_type',
      'bundle_entity_type' => 'entity_test_bundle',
      'handlers' => ['moderation' => ModerationHandler::class],
    ]);
    $entity = $this->prophesize(ContentEntityInterface::class);
    $entity->getEntityType()->willReturn($entity_type);
    $entity->getEntityTypeId()->willReturn($entity_type->id());
    $entity->bundle()->willReturn('test_bundle');

    $this->assertEquals($expected$moderation_information->isModeratedEntity($entity->reveal()));
  }

  
Home | Imprint | This part of the site doesn't use cookies.