- <?php
- * @file
- * Tests for Views and Layout context.
- */
-
- require_once BACKDROP_ROOT . '/core/modules/views/tests/views_query.test';
-
- * Tests the interface for adding, removing, and moving blocks.
- */
- class ViewsLayoutsTest extends BackdropWebTestCase {
-
-
- * Function that handles the set-up of this test.
- */
- protected function setup() {
-
- parent::setup(
- 'views', 'views_ui', 'layout', 'block', 'user', 'contextual'
- );
- }
-
-
- * Tests that a contextual filter input can be passed in from a layout.
- */
- public function testViewsLayouts() {
- global $admin_user;
-
- $permissions = array(
- 'administer site configuration',
- 'administer views',
- 'administer blocks',
- 'bypass node access',
- 'access user profiles',
- 'view revisions',
- 'synchronize configuration',
- 'administer layouts',
- 'administer flexible templates',
- );
-
-
- $admin_user = $this->backdropCreateUser($permissions);
- $this->backdropLogin($admin_user);
-
-
- $this->backdropGet('admin/structure/views/add');
-
-
- $layout_context_view = array();
- $layout_context_view['human_name'] = 'Layout Context Test (User account)';
- $layout_context_view['name'] = 'layout_context_test_ua';
- $layout_context_view['show[wizard_key]'] = 'users';
- $layout_context_view['description'] = 'This view will allow a a layout to reference contextually';
- $layout_context_view['page[create]'] = FALSE;
- $layout_context_view['block[create]'] = 1;
- $layout_context_view['block[title]'] = 'block';
- $layout_context_view['block[style][row_plugin]'] = 'fields';
-
- $this->backdropPost('admin/structure/views/add', $layout_context_view, t('Save view'));
- $this->assertText(t('Your view was saved. You may configure it from the list below.'));
-
-
-
- $this->backdropGet('admin/structure/views/nojs/add-item/layout_context_test_ua/block/field');
-
- $fields = array(
- 'name[fields][users.uid]' => 1,
- );
-
- $this->backdropPost(NULL, $fields, t('Add and configure fields'));
- $this->backdropPost(NULL, NULL, t('Apply'));
-
-
- $this->backdropGet('admin/structure/views/nojs/add-item/layout_context_test_ua/block/argument');
- $this->backdropPost(NULL, array('name[fields][users.uid]' => 1), t('Add and configure contextual filters'));
- $this->backdropPost(NULL, NULL, t('Apply'));
-
-
- $this->backdropGet('admin/structure/views/nojs/display/layout_context_test_ua/block/argument_input');
-
-
- $context = array(
- 'argument_input[uid][type]' => 'layout',
- 'argument_input[uid][layout]' => 'user',
- );
-
- $this->backdropPost(NULL, $context, 'Apply');
-
-
- $this->backdropPost(NULL, NULL, 'Save');
-
-
- $this->pass('View setup has finished');
-
-
- $this->backdropGet('admin/structure/layouts/add');
-
- $layout = array(
- 'title' => 'Test_Context_Layout',
- 'name' => 'test_context_layout',
- 'layout_template' => 'boxton',
- 'path' => 'test/%',
- );
-
-
- $this->backdropPost(NULL, $layout, t('Check path'));
-
-
- $edit = array(
- 'context[required][1][plugin]' => 'user',
- );
-
- $this->backdropPost(NULL, $edit, t('Check path'));
- $this->backdropPost(NULL, NULL, 'Create layout');
-
-
- $this->backdropGet('admin/structure/layouts/manage/test_context_layout/add-block/editor/content');
- $this->clickLink('View: Layout Context Test (User account) (Block)');
- $this->backdropPost(NULL, array(), 'Add block');
-
-
- $this->backdropPost(NULL, NULL, 'Save layout');
- $this->pass('Layout setup has finished');
-
-
- $this->backdropGet('test/' . $admin_user->uid);
- $this->assertText($admin_user->name);
- $this->assertRaw('<a href="/accounts/' . strtolower($admin_user->name) . '">' . $admin_user->uid . '</a>');
- }
- }