diff --git a/plugins/views/views_php_plugin_pager.inc b/plugins/views/views_php_plugin_pager.inc index 3a418e9..ad3f03e 100644 --- a/plugins/views/views_php_plugin_pager.inc +++ b/plugins/views/views_php_plugin_pager.inc @@ -10,7 +10,7 @@ class views_php_plugin_pager extends views_php_plugin_wrapper { /** * Perform any needed actions just prior to the query executing. */ - public function pre_execute($query) { + public function pre_execute(&$query) { $this->wrapped->pre_execute($query); foreach (array(/*'argument',*/ 'field', 'filter', 'sort', /*'relationship'*/) as $type) { @@ -37,14 +37,6 @@ class views_php_plugin_pager extends views_php_plugin_wrapper { } } - $this->wrapped->total_items = count($this->wrapped->view->result); - $this->wrapped->update_page_info(); - - $item_per_page = $this->wrapped->get_items_per_page(); - if ($item_per_page > 0) { - $offset = $this->wrapped->get_current_page() * $item_per_page + $this->wrapped->get_offset(); - $this->wrapped->view->result = array_slice($this->wrapped->view->result, $offset, $item_per_page); - } $this->wrapped->post_execute($result); } diff --git a/views_php.info b/views_php.info index d999ce1..3ad078a 100644 --- a/views_php.info +++ b/views_php.info @@ -3,6 +3,8 @@ description = Allows the usage of PHP to construct a view. package = Views core = 7.x dependencies[] = views +; Tests +files[] = views_php.test ; Views handlers files[] = plugins/views/views_php_handler_area.inc files[] = plugins/views/views_php_handler_field.inc diff --git a/views_php.test b/views_php.test new file mode 100644 index 0000000..94d884c --- /dev/null +++ b/views_php.test @@ -0,0 +1,57 @@ + t('Views PHP: basic test'), + 'description' => t('Test Views PHP functionality.'), + 'group' => 'Views PHP', + ); + } + + /* + * Enable your module + */ + public function setUp() { + // set up a new site with default core modules, mymodule, and + // dependencies. + parent::setUp('views_php', 'views_ui'); + } + + /* + * Test case for mymodule. + */ + public function testModule() { + $this->drupalLogin($this->drupalCreateUser(array('administer views'))); + $this->drupalCreateNode(array('type' => 'article')); + $this->drupalCreateNode(array('type' => 'article')); + $this->drupalCreateNode(array('type' => 'article')); + $edit = array( + 'human_name' => 'view', + 'name' => 'view_with_phpcode', + 'page[items_per_page]' => 2, + 'page[path]' => 'path', + 'page[style][row_plugin]' => 'fields', + ); + $this->drupalPost('admin/structure/views/add', $edit, 'Continue & edit'); + $edit = array( + 'name[views.php]' => 1, + ); + $this->drupalPost('admin/structure/views/nojs/add-item/view_with_phpcode/page/field', $edit, 'Add and configure fields'); + $this->drupalPost(NULL, array(), 'Apply'); + $this->drupalPost(NULL, array(), 'Save'); + $this->drupalGet('path'); + $this->assertRaw('