class SkinrUIPluginViewsTestCase in Skinr 8.2
Same name and namespace in other branches
- 7.2 tests/skinr_ui.test \SkinrUIPluginViewsTestCase
Tests UI functionality for Block plugin.
Hierarchy
- class \SkinrUIPluginViewsTestCase extends \DrupalWebTestCase
Expanded class hierarchy of SkinrUIPluginViewsTestCase
File
- skinr_ui/
src/ Tests/ skinr_ui.test, line 698 - Tests for the Skinr UI module.
View source
class SkinrUIPluginViewsTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Plugins UI - Views',
'description' => 'Tests Skinr UI functionality for functionality plugin from Views.',
'dependencies' => array(
'views',
'views_ui',
),
'group' => 'Skinr',
);
}
function setUp() {
parent::setUp(array(
'views_ui',
'skinr_ui_test',
));
$this->admin_user = $this
->drupalCreateUser(array(
'administer views',
'access all views',
'access contextual links',
'administer skinr',
'edit skin settings',
'edit advanced skin settings',
));
$this
->drupalLogin($this->admin_user);
}
/**
* Asserts that a select option in the current page exists.
*
* @param $name
* Id of select field to assert.
* @param $option
* Option to assert.
* @param $message
* Message to display.
* @return
* TRUE on pass, FALSE on fail.
*/
protected function assertOptionExists($name, $option, $message = '') {
$elements = $this
->xpath('//select[@name=:name]//option[@value=:option]', array(
':name' => $name,
':option' => $option,
));
return $this
->assertTrue(isset($elements[0]), $message ? $message : t('Option @option for field @name exists.', array(
'@option' => $option,
'@name' => $name,
)), t('Browser'));
}
/**
* Tests views plugin.
*/
function testViews() {
$default_theme = variable_get('theme_default', 'bartik');
// Go to the view's page.
$this
->drupalGet('skinr-ui-test-view');
// Make sure our contextual link appears on the page.
$this
->assertLinkByHref('admin/structure/skinr/edit/views/skinr_ui_test__page/configure', 0, "Contexual link to edit view's skin configuration was found.");
// Make sure this view's options are returned.
$this
->drupalGet('admin/structure/skinr/add');
$this
->assertOptionExists('element', 'skinr_ui_test__default', 'Default display for our view was returned by views_skinr_ui_element_options().');
$this
->assertOptionExists('element', 'skinr_ui_test__page', 'Page display for our view was returned by views_skinr_ui_element_options().');
// Test the returned element title.
$skin = (object) array(
'theme' => $default_theme,
'module' => 'views',
'element' => 'skinr_ui_test__page',
'skin' => 'skinr_ui_test_bgcolor',
'options' => array(
'bgcolor_red',
),
'status' => 1,
);
skinr_skin_save($skin);
$title = skinr_invoke_all('skinr_ui_element_title', $skin->module, $skin->element, $skin->theme);
$title = reset($title);
$this
->assertEqual($title, 'Skinr UI Test', 'View title was returned.');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SkinrUIPluginViewsTestCase:: |
protected | function | Asserts that a select option in the current page exists. | |
SkinrUIPluginViewsTestCase:: |
public static | function | ||
SkinrUIPluginViewsTestCase:: |
function | |||
SkinrUIPluginViewsTestCase:: |
function | Tests views plugin. |