You are here

public function FieldUninstallValidatorTest::testValidateDeleted in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 55
Contains \Drupal\Tests\field\Unit\FieldUninstallValidatorTest.

Class

FieldUninstallValidatorTest
@coversDefaultClass \Drupal\field\FieldUninstallValidator @group field

Namespace

Drupal\Tests\field\Unit

Code

public function testValidateDeleted() {
  $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
    ->assertSame($expected, $this
    ->castSafeStrings($reasons));
}