Same name and namespace in other branches
  1. 8.x-1.x tests/src/Functional/EntityCloneFilterFormatTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneFilterFormatTest 1 comment

Create a filter format and test a clone.

@group entity_clone

Hierarchy

  • class \Drupal\Tests\entity_clone\Functional\EntityCloneFilterFormatTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait

Expanded class hierarchy of EntityCloneFilterFormatTest

File

tests/src/Functional/EntityCloneFilterFormatTest.php, line 14

Namespace

Drupal\Tests\entity_clone\Functional
View source
class EntityCloneFilterFormatTest extends BrowserTestBase {
    use StringTranslationTrait;
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    protected static $modules = [
        'entity_clone',
        'filter',
    ];
    
    /**
     * Theme to enable by default.
     *
     * @var string
     */
    protected $defaultTheme = 'claro';
    
    /**
     * Permissions to grant admin user.
     *
     * @var array
     */
    protected $permissions = [
        'clone filter_format entity',
        'administer filters',
    ];
    
    /**
     * An administrative user.
     *
     * With permission to configure filter formats settings.
     *
     * @var \Drupal\user\UserInterface
     */
    protected $adminUser;
    
    /**
     * Sets the test up.
     */
    protected function setUp() : void {
        parent::setUp();
        $this->adminUser = $this->drupalCreateUser($this->permissions);
        $this->drupalLogin($this->adminUser);
    }
    
    /**
     * Test filter format entity clone.
     */
    public function testFilterFormatEntityClone() {
        $edit = [
            'name' => 'Test filter format for clone',
            'format' => 'test_filter_format_for_clone',
        ];
        $this->drupalGet("admin/config/content/formats/add");
        $this->submitForm($edit, $this->t('Save configuration'));
        $filter_formats = \Drupal::entityTypeManager()->getStorage('filter_format')
            ->loadByProperties([
            'format' => $edit['format'],
        ]);
        $filter_format = reset($filter_formats);
        $edit = [
            'id' => 'test_filter_format_cloned',
            'label' => 'Test filter format cloned',
        ];
        $this->drupalGet('entity_clone/filter_format/' . $filter_format->id());
        $this->submitForm($edit, $this->t('Clone'));
        $filter_formats = \Drupal::entityTypeManager()->getStorage('filter_format')
            ->loadByProperties([
            'format' => $edit['id'],
        ]);
        $filter_format = reset($filter_formats);
        $this->assertInstanceOf(FilterFormat::class, $filter_format, 'Test filter format cloned found in database.');
    }

}

Members

Title Sort descending Modifiers Object type Summary
EntityCloneFilterFormatTest::$adminUser protected property An administrative user.
EntityCloneFilterFormatTest::$defaultTheme protected property Theme to enable by default.
EntityCloneFilterFormatTest::$modules protected static property Modules to enable.
EntityCloneFilterFormatTest::$permissions protected property Permissions to grant admin user.
EntityCloneFilterFormatTest::setUp protected function Sets the test up.
EntityCloneFilterFormatTest::testFilterFormatEntityClone public function Test filter format entity clone.