'Test the view class', 'description' => 'Tests some functionality of the view class', 'group' => 'Views', ); } /** * Test 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); // Manipulate the display variable to test a previous bug. $view = $this->view_test_destroy(); $view->preview(); unset($view->display); $view->destroy(); $this->assertViewDestroy(); } function assertViewDestroy($view) { $this->assertNull($view->display['default']->handler, 'Take sure all displays are destroyed.'); $this->assertNull($view->display['attachment_1']->handler, 'Take sure all displays are destroyed.'); $this->assertNull($view->filter, 'Take sure all handlers are destroyed'); $this->assertNull($view->field, 'Take sure all handlers are destroyed'); $this->assertNull($view->argument, 'Take sure all handlers are destroyed'); $this->assertNull($view->relationship, 'Take sure all handlers are destroyed'); $this->assertNull($view->sort, 'Take sure all handlers are destroyed'); $this->assertNull($view->area, 'Take 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->assertNull($view->{$key}, $key); } $this->assertEqual($view->build, FALSE); $this->assertEqual($view->executed, FALSE); $this->assertEqual($view->build_info, array()); $this->assertEqual($view->attachment_before, ''); $this->assertEqual($view->attachment_after, ''); } /** * 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; /* Edit this to true to make a default view disabled initially */ /* Display: Defaults */ $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'; /* Header: Global: Text area */ $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; /* Header: Global: Text area */ $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; /* Footer: Global: Text area */ $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; /* Footer: Global: Text area */ $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; /* Empty text: Global: Text area */ $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; /* Empty text: Global: Text area */ $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; /* Relationship: Comment: Node */ $handler->display->display_options['relationships']['nid']['id'] = 'nid'; $handler->display->display_options['relationships']['nid']['table'] = 'comments'; $handler->display->display_options['relationships']['nid']['field'] = 'nid'; /* Relationship: Comment: Parent comment */ $handler->display->display_options['relationships']['pid']['id'] = 'pid'; $handler->display->display_options['relationships']['pid']['table'] = 'comments'; $handler->display->display_options['relationships']['pid']['field'] = 'pid'; /* Relationship: Comment: User */ $handler->display->display_options['relationships']['uid']['id'] = 'uid'; $handler->display->display_options['relationships']['uid']['table'] = 'comments'; $handler->display->display_options['relationships']['uid']['field'] = 'uid'; /* Field: Node: Nid */ $handler->display->display_options['fields']['nid']['id'] = 'nid'; $handler->display->display_options['fields']['nid']['table'] = 'node'; $handler->display->display_options['fields']['nid']['field'] = 'nid'; /* Field: Node: Path */ $handler->display->display_options['fields']['path']['id'] = 'path'; $handler->display->display_options['fields']['path']['table'] = 'node'; $handler->display->display_options['fields']['path']['field'] = 'path'; /* Field: Node: Post date */ $handler->display->display_options['fields']['created']['id'] = 'created'; $handler->display->display_options['fields']['created']['table'] = 'node'; $handler->display->display_options['fields']['created']['field'] = 'created'; /* Sort criterion: Node: In moderation */ $handler->display->display_options['sorts']['moderate']['id'] = 'moderate'; $handler->display->display_options['sorts']['moderate']['table'] = 'node'; $handler->display->display_options['sorts']['moderate']['field'] = 'moderate'; /* Sort criterion: Node: Last comment author */ $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'; /* Sort criterion: Node: Last comment time */ $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'; /* Argument: Node: Created date */ $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'; /* Argument: Node: Created day */ $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'; /* Argument: Node: Created month */ $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'; /* Filter: Node: Nid */ $handler->display->display_options['filters']['nid']['id'] = 'nid'; $handler->display->display_options['filters']['nid']['table'] = 'node'; $handler->display->display_options['filters']['nid']['field'] = 'nid'; /* Filter: Node: Published */ $handler->display->display_options['filters']['status']['id'] = 'status'; $handler->display->display_options['filters']['status']['table'] = 'node'; $handler->display->display_options['filters']['status']['field'] = 'status'; /* Filter: Node: Title */ $handler->display->display_options['filters']['title']['id'] = 'title'; $handler->display->display_options['filters']['title']['table'] = 'node'; $handler->display->display_options['filters']['title']['field'] = 'title'; /* Display: Page */ $handler = $view->new_display('page', 'Page', 'page_1'); $handler->display->display_options['path'] = 'test_destroy'; /* Display: Attachment */ $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', ); /* Display: Attachment */ $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('Defaults'), 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('Node'), t('Parent comment'), t('User'), t('Nid'), t('Path'), t('Post date'), t('All'), t('Page'), t('Attachment'), ); return $view; } }