Index: tests/post/getPages.php
===================================================================
--- tests/post/getPages.php	(revision 0)
+++ tests/post/getPages.php	(revision 0)
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * @group post
+ */
+
+class Tests_Post_getPages extends WP_UnitTestCase {
+    function setUp() {
+		parent::setUp();
+    }
+
+	function test_get_pages_cache() {
+		global $wpdb;
+
+		$this->factory->post->create_many( 15, array( 'post_type' => 'page' ) );
+		$this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );
+
+		$pages = get_pages();
+		$this->assertEquals( 15, count( $pages ) );
+		$this->assertEquals( 1, wp_cache_get( 'last_changed', 'posts' ) );
+		$num_queries = $wpdb->num_queries;
+
+		// Again. num_queries and last_changed should remain the same.
+		$pages = get_pages();
+		$this->assertEquals( 15, count( $pages ) );
+		$this->assertEquals( 1, wp_cache_get( 'last_changed', 'posts' ) );
+		$this->assertEquals( $num_queries, $wpdb->num_queries );
+
+		// Again with different args. last_changed should not increment because of
+		// different args to get_pages(). num_queries should bump by 1.
+		$pages = get_pages( array( 'number' => 10 ) );
+		//debug_log( $wpdb );
+		$this->assertEquals( 10, count( $pages ) );
+		$this->assertEquals( 1, wp_cache_get( 'last_changed', 'posts' ) );
+		$this->assertEquals( $num_queries + 1, $wpdb->num_queries );
+
+		// Again. num_queries and last_changed should remain the same.
+		$pages = get_pages( array( 'number' => 10 ) );
+		$this->assertEquals( 10, count( $pages ) );
+		$this->assertEquals( 1, wp_cache_get( 'last_changed', 'posts' ) );
+		$this->assertEquals( $num_queries + 1, $wpdb->num_queries );
+
+		// Force last_changed to increment.
+		clean_post_cache( $pages[0]->ID );
+		$this->assertEquals( 2, wp_cache_get( 'last_changed', 'posts' ) );
+
+		// Last changed bumped so num_queries should increment.
+		$pages = get_pages( array( 'number' => 10 ) );
+		$this->assertEquals( 10, count( $pages ) );
+		$this->assertEquals( 2, wp_cache_get( 'last_changed', 'posts' ) );
+		$this->assertEquals( $num_queries + 2, $wpdb->num_queries );
+	}
+}
\ No newline at end of file

Property changes on: tests/post/getPages.php
___________________________________________________________________
Added: svn:eol-style
   + native

