function FieldConfigEntityUnitTest::testOnDependencyRemoval

Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldConfigEntityUnitTest::testOnDependencyRemoval()
  2. 10 core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldConfigEntityUnitTest::testOnDependencyRemoval()
  3. 11.x core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldConfigEntityUnitTest::testOnDependencyRemoval()

@covers ::onDependencyRemoval

File

core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php, line 218

Class

FieldConfigEntityUnitTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21field%21src%21Entity%21FieldConfig.php/class/FieldConfig/8.9.x" title="Defines the Field entity." class="local">\Drupal\field\Entity\FieldConfig</a> @group field

Namespace

Drupal\Tests\field\Unit

Code

public function testOnDependencyRemoval() {
    $this->fieldTypePluginManager
        ->expects($this->any())
        ->method('getDefinition')
        ->with('test_field')
        ->willReturn([
        'class' => '\\Drupal\\Tests\\field\\Unit\\DependencyFieldItem',
    ]);
    $field = new FieldConfig([
        'field_name' => $this->fieldStorage
            ->getName(),
        'entity_type' => 'test_entity_type',
        'bundle' => 'test_bundle',
        'field_type' => 'test_field',
        'dependencies' => [
            'module' => [
                'fruiter',
            ],
        ],
        'third_party_settings' => [
            'fruiter' => [
                'fruit' => 'apple',
            ],
        ],
    ]);
    $changed = $field->onDependencyRemoval([
        'module' => [
            'fruiter',
        ],
    ]);
    $this->assertTrue($changed);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.