Browse Source

Add basic tests for cleanCopy().

mark_story 11 years ago
parent
commit
8887c4aa28
1 changed files with 22 additions and 0 deletions
  1. 22 0
      tests/TestCase/ORM/QueryTest.php

+ 22 - 0
tests/TestCase/ORM/QueryTest.php

@@ -2089,4 +2089,26 @@ class QueryTest extends TestCase {
 		$this->assertEquals(3, $result);
 	}
 
+/**
+ * test that cleanCopy makes a cleaned up clone.
+ *
+ * @return void
+ */
+	public function testCleanCopy() {
+		$table = TableRegistry::get('Articles');
+		$table->hasMany('Comments');
+
+		$query = $table->find();
+		$query->offset(10)
+			->limit(1)
+			->order(['Articles.id' => 'DESC'])
+			->contain(['Comments']);
+		$copy = $query->cleanCopy();
+
+		$this->assertNotSame($copy, $query);
+		$this->assertNull($copy->clause('offset'));
+		$this->assertNull($copy->clause('limit'));
+		$this->assertNull($copy->clause('order'));
+	}
+
 }