Newer
Older
<?php
/**
* @file
* Contains \Drupal\views_ui\Tests\UITestBase.
namespace Drupal\views_ui\Tests;
use Drupal\views\Tests\ViewTestBase;
/**
* Provides a base class for testing the Views UI.
*/
abstract class UITestBase extends ViewTestBase {
Alex Pott
committed
/**
* An admin user with the 'administer views' permission.
*
Jennifer Hodgdon
committed
* @var \Drupal\user\UserInterface
Alex Pott
committed
*/
protected $adminUser;
/**
* An admin user with administrative permissions for views, blocks, and nodes.
*
Jennifer Hodgdon
committed
* @var \Drupal\user\UserInterface
Alex Pott
committed
*/
protected $fullAdminUser;
Tim Plunkett
committed
/**
* Modules to enable.
*
* @var array
*/
Alex Pott
committed
public static $modules = array('node', 'views_ui', 'block');
protected function setUp() {
parent::setUp();
$this->enableViewsTestModule();
$this->adminUser = $this->drupalCreateUser(array('administer views'));
Alex Pott
committed
$this->fullAdminUser = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions'));
$this->drupalLogin($this->fullAdminUser);
Angie Byron
committed
/**
* A helper method which creates a random view.
*/
public function randomView(array $view = array()) {
// Create a new view in the UI.
$default = array();
Alex Pott
committed
$default['label'] = $this->randomMachineName(16);
$default['id'] = strtolower($this->randomMachineName(16));
$default['description'] = $this->randomMachineName(16);
Angie Byron
committed
$default['page[create]'] = TRUE;
$default['page[path]'] = $default['id'];
$view += $default;
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
return $default;
}