function FieldUninstallValidatorTest::testValidateDeleted

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

@covers ::validate

File

core/modules/field/tests/src/Unit/FieldUninstallValidatorTest.php, line 56

Class

FieldUninstallValidatorTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21field%21src%21FieldUninstallValidator.php/class/FieldUninstallValidator/11.x" title="Prevents uninstallation of modules providing active field storage." class="local">\Drupal\field\FieldUninstallValidator</a> @group field

Namespace

Drupal\Tests\field\Unit

Code

public function testValidateDeleted() : void {
    $field_storage = $this->getMockBuilder('Drupal\\field\\Entity\\FieldStorageConfig')
        ->disableOriginalConstructor()
        ->getMock();
    $field_storage->expects($this->once())
        ->method('isDeleted')
        ->willReturn(TRUE);
    $this->fieldUninstallValidator
        ->expects($this->once())
        ->method('getFieldStoragesByModule')
        ->willReturn([
        $field_storage,
    ]);
    $module = $this->randomMachineName();
    $expected = [
        'Fields pending deletion',
    ];
    $reasons = $this->fieldUninstallValidator
        ->validate($module);
    $this->assertEquals($expected, $reasons);
}

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