From 64d49c8afc9b635afaa1ee2815c5be9ed026bdc5 Mon Sep 17 00:00:00 2001 From: "mariano.iglesias" Date: Sat, 21 Jun 2008 23:41:54 +0000 Subject: [PATCH] Adding test cases to Containable, disproves and closes #4934 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7229 3807eeeb-6ff5-0310-8944-8be069107fe0 --- .../libs/model/behaviors/containable.test.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cake/tests/cases/libs/model/behaviors/containable.test.php b/cake/tests/cases/libs/model/behaviors/containable.test.php index d666578da..7d2d9e351 100644 --- a/cake/tests/cases/libs/model/behaviors/containable.test.php +++ b/cake/tests/cases/libs/model/behaviors/containable.test.php @@ -3003,6 +3003,28 @@ class ContainableTest extends CakeTestCase { ) ); $this->assertEqual($result, $expected); + + $this->assertTrue(empty($this->User->Article->hasAndBelongsToMany['Tag']['conditions'])); + + $result = $this->User->find('all', array('contain' => array( + 'Article.Tag' => array('conditions' => array('created >=' => '2007-03-18 12:24')) + ))); + + $this->assertTrue(Set::matches('/User[id=1]', $result)); + $this->assertFalse(Set::matches('/Article[id=1]/Tag[id=1]', $result)); + $this->assertTrue(Set::matches('/Article[id=1]/Tag[id=2]', $result)); + $this->assertTrue(empty($this->User->Article->hasAndBelongsToMany['Tag']['conditions'])); + + $this->assertTrue(empty($this->User->Article->hasAndBelongsToMany['Tag']['order'])); + + $result = $this->User->find('all', array('contain' => array( + 'Article.Tag' => array('order' => 'created DESC') + ))); + + $this->assertTrue(Set::matches('/User[id=1]', $result)); + $this->assertTrue(Set::matches('/Article[id=1]/Tag[id=1]', $result)); + $this->assertTrue(Set::matches('/Article[id=1]/Tag[id=2]', $result)); + $this->assertTrue(empty($this->User->Article->hasAndBelongsToMany['Tag']['order'])); } /** * testOtherFinds method