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 dd55cdb..a2d8278 100644
--- a/views_php.info
+++ b/views_php.info
@@ -14,3 +14,5 @@ files[] = plugins/views/views_php_plugin_cache.inc
 files[] = plugins/views/views_php_plugin_pager.inc
 files[] = plugins/views/views_php_plugin_query.inc
 files[] = plugins/views/views_php_plugin_wrapper.inc
+
+files[] = views_php.test
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 @@
+<?php
+/**
+ * @file
+ * views_php.test
+ * This file contains the testing code for this module
+ */
+
+/**
+ * The test case
+ */
+class ViewsPHPTestCase extends DrupalWebTestCase {
+  /**
+   * Info for this test case.
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 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('<ul class="pager">', 'A pager is present when PHP views is used for a field in views');
+  }
+}
