- <?php
- * @file
- * Definition of ViewsViewTest.
- */
-
- require_once BACKDROP_ROOT . '/core/modules/views/tests/views_query.test';
-
- * Views class tests.
- */
- class ViewsViewTest extends ViewsSqlTest {
-
- * Tests the deconstructor to be sure that every kind of heavy objects are removed.
- */
- function testDestroy() {
- $view = $this->view_test_destroy();
-
- $view->preview();
- $view->destroy();
-
- $this->assertViewDestroy($view);
-
-
- $view = $this->view_test_destroy();
- $view->preview();
-
- $view->destroy();
- $this->assertViewDestroy($view);
- }
-
- function assertViewDestroy($view) {
- $this->assertFalse(isset($view->display['default']->handler), 'Make sure all displays are destroyed.');
- $this->assertFalse(isset($view->display['attachment_1']->handler), 'Make sure all displays are destroyed.');
-
- $this->assertFalse(isset($view->filter), 'Make sure all handlers are destroyed');
- $this->assertFalse(isset($view->field), 'Make sure all handlers are destroyed');
- $this->assertFalse(isset($view->argument), 'Make sure all handlers are destroyed');
- $this->assertFalse(isset($view->relationship), 'Make sure all handlers are destroyed');
- $this->assertFalse(isset($view->sort), 'Make sure all handlers are destroyed');
- $this->assertFalse(isset($view->area), 'Make sure all handlers are destroyed');
-
- $keys = array('current_display', 'display_handler', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'result', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'many_to_one_tables');
- foreach ($keys as $key) {
- $this->assertFalse(isset($view->{$key}), $key);
- }
- $this->assertEqual($view->built, FALSE);
- $this->assertEqual($view->executed, FALSE);
- $this->assertEqual($view->build_info, array());
- $this->assertEqual($view->attachment_before, '');
- $this->assertEqual($view->attachment_after, '');
- }
-
- function testDelete() {
-
- $view = $this->view_test_delete();
- $view->save();
- $view = views_get_view($view->name);
- $view->delete();
-
- $view = views_get_view($view->name);
- $this->assertFalse($view, 'Make sure that the old view is removed from the static cache.');
- }
-
- function testValidate() {
-
-
-
- $view = $this->view_test_destroy();
- $view->set_display('page_1');
-
- $view->validate();
-
- $this->assertEqual('page_1', $view->current_display, "The display should be constant while validating");
-
-
-
-
-
- }
-
-
- * This view provides some filters, fields, arguments, relationships, sorts, areas and attachments.
- */
- function view_test_destroy() {
- $view = new view;
- $view->name = 'test_destroy';
- $view->description = '';
- $view->tag = '';
- $view->base_table = 'node';
- $view->human_name = '';
- $view->api_version = '3.0-alpha1';
- $view->disabled = FALSE;
-
-
- $handler = $view->new_display('default', 'Default', 'default');
- $handler->display->display_options['access']['type'] = 'none';
- $handler->display->display_options['cache']['type'] = 'none';
- $handler->display->display_options['query']['type'] = 'views_query';
- $handler->display->display_options['exposed_form']['type'] = 'basic';
- $handler->display->display_options['pager']['type'] = 'full';
- $handler->display->display_options['style_plugin'] = 'default';
- $handler->display->display_options['row_plugin'] = 'fields';
-
- $handler->display->display_options['header']['area']['id'] = 'area';
- $handler->display->display_options['header']['area']['table'] = 'views';
- $handler->display->display_options['header']['area']['field'] = 'area';
- $handler->display->display_options['header']['area']['empty'] = FALSE;
-
- $handler->display->display_options['header']['area_1']['id'] = 'area_1';
- $handler->display->display_options['header']['area_1']['table'] = 'views';
- $handler->display->display_options['header']['area_1']['field'] = 'area';
- $handler->display->display_options['header']['area_1']['empty'] = FALSE;
-
- $handler->display->display_options['footer']['area']['id'] = 'area';
- $handler->display->display_options['footer']['area']['table'] = 'views';
- $handler->display->display_options['footer']['area']['field'] = 'area';
- $handler->display->display_options['footer']['area']['empty'] = FALSE;
-
- $handler->display->display_options['footer']['area_1']['id'] = 'area_1';
- $handler->display->display_options['footer']['area_1']['table'] = 'views';
- $handler->display->display_options['footer']['area_1']['field'] = 'area';
- $handler->display->display_options['footer']['area_1']['empty'] = FALSE;
-
- $handler->display->display_options['empty']['area']['id'] = 'area';
- $handler->display->display_options['empty']['area']['table'] = 'views';
- $handler->display->display_options['empty']['area']['field'] = 'area';
- $handler->display->display_options['empty']['area']['empty'] = FALSE;
-
- $handler->display->display_options['empty']['area_1']['id'] = 'area_1';
- $handler->display->display_options['empty']['area_1']['table'] = 'views';
- $handler->display->display_options['empty']['area_1']['field'] = 'area';
- $handler->display->display_options['empty']['area_1']['empty'] = FALSE;
-
- $handler->display->display_options['relationships']['nid']['id'] = 'nid';
- $handler->display->display_options['relationships']['nid']['table'] = 'comments';
- $handler->display->display_options['relationships']['nid']['field'] = 'nid';
-
- $handler->display->display_options['relationships']['pid']['id'] = 'pid';
- $handler->display->display_options['relationships']['pid']['table'] = 'comments';
- $handler->display->display_options['relationships']['pid']['field'] = 'pid';
-
- $handler->display->display_options['relationships']['uid']['id'] = 'uid';
- $handler->display->display_options['relationships']['uid']['table'] = 'comments';
- $handler->display->display_options['relationships']['uid']['field'] = 'uid';
-
- $handler->display->display_options['fields']['nid']['id'] = 'nid';
- $handler->display->display_options['fields']['nid']['table'] = 'node';
- $handler->display->display_options['fields']['nid']['field'] = 'nid';
-
- $handler->display->display_options['fields']['path']['id'] = 'path';
- $handler->display->display_options['fields']['path']['table'] = 'node';
- $handler->display->display_options['fields']['path']['field'] = 'path';
-
- $handler->display->display_options['fields']['created']['id'] = 'created';
- $handler->display->display_options['fields']['created']['table'] = 'node';
- $handler->display->display_options['fields']['created']['field'] = 'created';
-
- $handler->display->display_options['sorts']['moderate']['id'] = 'moderate';
- $handler->display->display_options['sorts']['moderate']['table'] = 'node';
- $handler->display->display_options['sorts']['moderate']['field'] = 'moderate';
-
- $handler->display->display_options['sorts']['last_comment_name']['id'] = 'last_comment_name';
- $handler->display->display_options['sorts']['last_comment_name']['table'] = 'node_comment_statistics';
- $handler->display->display_options['sorts']['last_comment_name']['field'] = 'last_comment_name';
-
- $handler->display->display_options['sorts']['last_comment_timestamp']['id'] = 'last_comment_timestamp';
- $handler->display->display_options['sorts']['last_comment_timestamp']['table'] = 'node_comment_statistics';
- $handler->display->display_options['sorts']['last_comment_timestamp']['field'] = 'last_comment_timestamp';
-
- $handler->display->display_options['arguments']['created_fulldate']['id'] = 'created_fulldate';
- $handler->display->display_options['arguments']['created_fulldate']['table'] = 'node';
- $handler->display->display_options['arguments']['created_fulldate']['field'] = 'created_fulldate';
- $handler->display->display_options['arguments']['created_fulldate']['style_plugin'] = 'default_summary';
- $handler->display->display_options['arguments']['created_fulldate']['default_argument_type'] = 'fixed';
-
- $handler->display->display_options['arguments']['created_day']['id'] = 'created_day';
- $handler->display->display_options['arguments']['created_day']['table'] = 'node';
- $handler->display->display_options['arguments']['created_day']['field'] = 'created_day';
- $handler->display->display_options['arguments']['created_day']['style_plugin'] = 'default_summary';
- $handler->display->display_options['arguments']['created_day']['default_argument_type'] = 'fixed';
-
- $handler->display->display_options['arguments']['created_month']['id'] = 'created_month';
- $handler->display->display_options['arguments']['created_month']['table'] = 'node';
- $handler->display->display_options['arguments']['created_month']['field'] = 'created_month';
- $handler->display->display_options['arguments']['created_month']['style_plugin'] = 'default_summary';
- $handler->display->display_options['arguments']['created_month']['default_argument_type'] = 'fixed';
-
- $handler->display->display_options['filters']['nid']['id'] = 'nid';
- $handler->display->display_options['filters']['nid']['table'] = 'node';
- $handler->display->display_options['filters']['nid']['field'] = 'nid';
-
- $handler->display->display_options['filters']['status']['id'] = 'status';
- $handler->display->display_options['filters']['status']['table'] = 'node';
- $handler->display->display_options['filters']['status']['field'] = 'status';
-
- $handler->display->display_options['filters']['title']['id'] = 'title';
- $handler->display->display_options['filters']['title']['table'] = 'node';
- $handler->display->display_options['filters']['title']['field'] = 'title';
-
-
- $handler = $view->new_display('page', 'Page', 'page_1');
- $handler->display->display_options['path'] = 'test_destroy';
-
-
- $handler = $view->new_display('attachment', 'Attachment', 'attachment_1');
- $handler->display->display_options['pager']['type'] = 'some';
- $handler->display->display_options['displays'] = array(
- 'default' => 'default',
- 'page_1' => 'page_1',
- );
-
-
- $handler = $view->new_display('attachment', 'Attachment', 'attachment_2');
- $handler->display->display_options['pager']['type'] = 'some';
- $handler->display->display_options['displays'] = array(
- 'default' => 'default',
- 'page_1' => 'page_1',
- );
- $translatables['test_destroy'] = array(
- t('Default'),
- t('more'),
- t('Apply'),
- t('Reset'),
- t('Sort By'),
- t('Asc'),
- t('Desc'),
- t('Items per page'),
- t('- All -'),
- t('Offset'),
- t('Text area'),
- t('Content'),
- t('Parent comment'),
- t('User'),
- t('Nid'),
- t('Path'),
- t('Post date'),
- t('All'),
- t('Page'),
- t('Attachment'),
- );
-
- return $view;
- }
- function view_test_delete() {
- $view = new view;
- $view->name = 'test_view_delete';
- $view->description = '';
- $view->tag = '';
- $view->base_table = 'node';
- $view->human_name = 'test_view_delete';
- $view->core = 7;
- $view->api_version = '3.0-alpha1';
- $view->disabled = FALSE;
-
-
- $handler = $view->new_display('default', 'Defaults', 'default');
- $handler->display->display_options['access']['type'] = 'none';
- $handler->display->display_options['cache']['type'] = 'none';
- $handler->display->display_options['query']['type'] = 'views_query';
- $handler->display->display_options['exposed_form']['type'] = 'basic';
- $handler->display->display_options['pager']['type'] = 'full';
- $handler->display->display_options['style_plugin'] = 'default';
- $handler->display->display_options['row_plugin'] = 'fields';
- $translatables['test_view_delete'] = array(
- t('Defaults'),
- t('more'),
- t('Apply'),
- t('Reset'),
- t('Sort By'),
- t('Asc'),
- t('Desc'),
- t('Items per page'),
- t('- All -'),
- t('Offset'),
- );
-
- return $view;
- }
- }