diff --git a/src/Tests/Classic/ParagraphsTypesTest.php b/src/Tests/Classic/ParagraphsTypesTest.php index f837306..8900e67 100644 --- a/src/Tests/Classic/ParagraphsTypesTest.php +++ b/src/Tests/Classic/ParagraphsTypesTest.php @@ -12,6 +12,15 @@ use Drupal\paragraphs\Entity\ParagraphsType; class ParagraphsTypesTest extends ParagraphsTestBase { /** + * Modules to enable. + * + * @var array + */ + public static $modules = [ + 'views', + ]; + + /** * Tests the deletion of Paragraphs types. */ public function testRemoveTypesWithContent() { @@ -45,7 +54,10 @@ class ParagraphsTypesTest extends ParagraphsTestBase { * Tests the paragraph type icon settings. */ public function testParagraphTypeIcon() { - $admin_user = $this->drupalCreateUser(['administer paragraphs types']); + $admin_user = $this->drupalCreateUser([ + 'administer paragraphs types', + 'access files overview', + ]); $this->drupalLogin($admin_user); // Add the paragraph type with icon. $this->drupalGet('admin/structure/paragraphs_type/add'); @@ -60,6 +72,12 @@ class ParagraphsTypesTest extends ParagraphsTestBase { $this->drupalPostForm(NULL, $edit, t('Save and manage fields')); $this->assertText('Saved the Test paragraph type Paragraphs type.'); + // Check that the icon file usage has been registered. + $this->drupalGet('admin/content/files'); + $this->assertLink('image-test.png'); + $this->clickLink('1 place'); + $this->assertLink('Test paragraph type'); + // Check if the icon has been saved. $this->drupalGet('admin/structure/paragraphs_type'); $this->assertRaw('image-test.png'); @@ -71,6 +89,18 @@ class ParagraphsTypesTest extends ParagraphsTestBase { $dependencies = $paragraph_type->getDependencies(); $dependencies_uuid[] = explode(':', $dependencies['content'][0]); $this->assertEqual($paragraph_type->get('icon_uuid'), $dependencies_uuid[0][2]); + + // Delete the icon. + $this->drupalGet('admin/structure/paragraphs_type/test_paragraph_type_icon'); + $this->drupalPostAjaxForm(NULL, [], 'icon_file_remove_button'); + $this->drupalPostForm(NULL, [], t('Save')); + + // Check that the icon file usage has been deregistered. + $this->drupalGet('admin/content/files'); + $this->assertLink('image-test.png'); + $this->clickLink('0 places'); + $this->assertText('File usage information for image-test.png'); + $this->assertNoText('Test paragraph type'); } }