trait MediaFunctionalTestTrait

Same name in other branches
  1. 8.9.x core/modules/media/tests/src/Functional/MediaFunctionalTestTrait.php \Drupal\Tests\media\Functional\MediaFunctionalTestTrait
  2. 10 core/modules/media/tests/src/Functional/MediaFunctionalTestTrait.php \Drupal\Tests\media\Functional\MediaFunctionalTestTrait
  3. 11.x core/modules/media/tests/src/Functional/MediaFunctionalTestTrait.php \Drupal\Tests\media\Functional\MediaFunctionalTestTrait

Trait with helpers for Media functional tests.

Hierarchy

1 file declares its use of MediaFunctionalTestTrait
MediaJavascriptTestBase.php in core/modules/media/tests/src/FunctionalJavascript/MediaJavascriptTestBase.php

File

core/modules/media/tests/src/Functional/MediaFunctionalTestTrait.php, line 8

Namespace

Drupal\Tests\media\Functional
View source
trait MediaFunctionalTestTrait {
    
    /**
     * Permissions for the admin user that will be logged-in for test.
     *
     * @var array
     */
    protected static $adminUserPermissions = [
        // Media module permissions.
'access media overview',
        'administer media',
        'administer media fields',
        'administer media form display',
        'administer media display',
        'administer media types',
        'view media',
        // Other permissions.
'administer views',
        'access content overview',
        'view all revisions',
        'administer content types',
        'administer node fields',
        'administer node form display',
        'administer node display',
        'bypass node access',
    ];
    
    /**
     * An admin test user account.
     *
     * @var \Drupal\Core\Session\AccountInterface
     */
    protected $adminUser;
    
    /**
     * A non-admin test user account.
     *
     * @var \Drupal\user\UserInterface
     */
    protected $nonAdminUser;
    
    /**
     * The storage service.
     *
     * @var \Drupal\Core\Entity\EntityStorageInterface
     */
    protected $storage;
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() {
        parent::setUp();
        // Have two users ready to be used in tests.
        $this->adminUser = $this->drupalCreateUser(static::$adminUserPermissions);
        $this->nonAdminUser = $this->drupalCreateUser([]);
        // Start off logged in as admin.
        $this->drupalLogin($this->adminUser);
        $this->storage = $this->container
            ->get('entity_type.manager')
            ->getStorage('media');
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
MediaFunctionalTestTrait::$adminUser protected property An admin test user account.
MediaFunctionalTestTrait::$adminUserPermissions protected static property Permissions for the admin user that will be logged-in for test.
MediaFunctionalTestTrait::$nonAdminUser protected property A non-admin test user account.
MediaFunctionalTestTrait::$storage protected property The storage service.
MediaFunctionalTestTrait::setUp protected function 13

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