public function PictureAdminUITest::setUp

Drupal\simpletest\WebTestBase\setUp().

Overrides WebTestBase::setUp

File

drupal/core/modules/picture/lib/Drupal/picture/Tests/PictureAdminUITest.php, line 39
Definition of Drupal\picture\Tests\PictureAdminUITest.

Class

PictureAdminUITest
Tests for breakpoint sets admin interface.

Namespace

Drupal\picture\Tests

Code

public function setUp() {
  parent::setUp();

  // Create user.
  $this->admin_user = $this
    ->drupalCreateUser(array(
    'administer pictures',
  ));
  $this
    ->drupalLogin($this->admin_user);

  // Add breakpoint_group and breakpoints.
  $breakpoint_group = entity_create('breakpoint_group', array(
    'id' => 'atestset',
    'label' => 'A test set',
    'sourceType' => Breakpoint::SOURCE_TYPE_USER_DEFINED,
  ));
  $breakpoints = array();
  $breakpoint_names = array(
    'small',
    'medium',
    'large',
  );
  for ($i = 0; $i < 3; $i++) {
    $width = ($i + 1) * 200;
    $breakpoint = entity_create('breakpoint', array(
      'name' => $breakpoint_names[$i],
      'mediaQuery' => "(min-width: {$width}px)",
      'source' => 'user',
      'sourceType' => Breakpoint::SOURCE_TYPE_USER_DEFINED,
      'multipliers' => array(
        '1.5x' => 0,
        '2x' => '2x',
      ),
    ));
    $breakpoint
      ->save();
    $breakpoint_group->breakpoints[$breakpoint
      ->id()] = $breakpoint;
  }
  $breakpoint_group
    ->save();
}