From 85e0ebd7fd65e1e44cd0349daf589797f5445185 Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Wed, 5 Jul 2017 23:22:58 +0200 Subject: [PATCH] more unit tests added --- .../Component/PaginatorComponentTest.php | 5 +- lib/Cake/Test/Case/Model/ModelReadTest.php | 72 +++++++++++++++++++ lib/Cake/Test/Case/Model/ModelTestBase.php | 1 + 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index 6bc0a1e4c..4a980630b 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -505,15 +505,14 @@ class PaginatorComponentTest extends CakeTestCase { $Controller->Paginator->settings = array( 'recursive' => 0, 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), + 'NOT' => array('I18n__title.content' => ''), ), 'limit' => 2, ); $result = $Controller->Paginator->paginate('TranslatedArticle'); $this->assertEquals('Title (eng) #1', $result[0]['TranslatedArticle']['title']); $this->assertEquals('Title (eng) #2', $result[1]['TranslatedArticle']['title']); - $this->assertEquals('Title (eng) #3', $result[2]['TranslatedArticle']['title']); - $this->assertCount(3, $result); + $this->assertCount(2, $result); } /** diff --git a/lib/Cake/Test/Case/Model/ModelReadTest.php b/lib/Cake/Test/Case/Model/ModelReadTest.php index 11e9ffa90..bac344d04 100644 --- a/lib/Cake/Test/Case/Model/ModelReadTest.php +++ b/lib/Cake/Test/Case/Model/ModelReadTest.php @@ -6685,6 +6685,62 @@ class ModelReadTest extends BaseModelTest { $this->assertEquals($expected, $result); } + public function testFindAllI18nConditions() { + $this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User'); + $TestModel = new TranslatedArticle(); + $TestModel->cacheQueries = false; + $TestModel->locale = 'eng'; + $options = array( + 'recursive' => 0, + 'conditions' => array( + 'NOT' => array('I18n__title.content' => ''), + ), + 'limit' => 2, + ); + $result = $TestModel->find('all', $options); + $expected = array( + array( + 'TranslatedArticle' => array( + 'id' => '1', + 'user_id' => '1', + 'published' => 'Y', + 'created' => '2007-03-18 10:39:23', + 'updated' => '2007-03-18 10:41:31', + 'locale' => 'eng', + 'title' => 'Title (eng) #1', + 'body' => 'Body (eng) #1', + ), + 'User' => array( + 'id' => '1', + 'user' => 'mariano', + 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', + 'created' => '2007-03-17 01:16:23', + 'updated' => '2007-03-17 01:18:31', + ), + ), + array( + 'TranslatedArticle' => array( + 'id' => '2', + 'user_id' => '3', + 'published' => 'Y', + 'created' => '2007-03-18 10:41:23', + 'updated' => '2007-03-18 10:43:31', + 'locale' => 'eng', + 'title' => 'Title (eng) #2', + 'body' => 'Body (eng) #2', + ), + 'User' => array( + 'id' => '3', + 'user' => 'larry', + 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', + 'created' => '2007-03-17 01:20:23', + 'updated' => '2007-03-17 01:22:31', + ), + ), + ); + $this->assertEquals($expected, $result); + } + /** * test find('list') method * @@ -7118,6 +7174,22 @@ class ModelReadTest extends BaseModelTest { $this->assertEquals($expected, $result); } + public function testFindCountI18nConditions() { + $this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User'); + $TestModel = new TranslatedArticle(); + $TestModel->cacheQueries = false; + $TestModel->locale = 'eng'; + $options = array( + 'recursive' => 0, + 'conditions' => array( + 'NOT' => array('I18n__title.content' => ''), + ), + 'limit' => 2, + ); + $result = $TestModel->find('count', $options); + $this->assertEquals(2, $result); + } + /** * Test that find('first') does not use the id set to the object. * diff --git a/lib/Cake/Test/Case/Model/ModelTestBase.php b/lib/Cake/Test/Case/Model/ModelTestBase.php index 59f3353c3..f0f75a912 100644 --- a/lib/Cake/Test/Case/Model/ModelTestBase.php +++ b/lib/Cake/Test/Case/Model/ModelTestBase.php @@ -73,6 +73,7 @@ abstract class BaseModelTest extends CakeTestCase { 'core.bidding', 'core.bidding_message', 'core.site', 'core.domain', 'core.domains_site', 'core.uuidnativeitem', 'core.uuidnativeportfolio', 'core.uuidnativeitems_uuidnativeportfolio', 'core.uuidnativeitems_uuidnativeportfolio_numericid', + 'core.translated_article', 'core.translate_article', ); /**