Skip to content

Commit 85e0ebd

Browse files
committed
more unit tests added
1 parent 5033467 commit 85e0ebd

File tree

3 files changed

+75
-3
lines changed

3 files changed

+75
-3
lines changed

lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,15 +505,14 @@ public function testPaginateI18nConditionNotTitleWithLimit() {
505505
$Controller->Paginator->settings = array(
506506
'recursive' => 0,
507507
'conditions' => array(
508-
'NOT' => array('I18n__title.content' => ''),
508+
'NOT' => array('I18n__title.content' => ''),
509509
),
510510
'limit' => 2,
511511
);
512512
$result = $Controller->Paginator->paginate('TranslatedArticle');
513513
$this->assertEquals('Title (eng) #1', $result[0]['TranslatedArticle']['title']);
514514
$this->assertEquals('Title (eng) #2', $result[1]['TranslatedArticle']['title']);
515-
$this->assertEquals('Title (eng) #3', $result[2]['TranslatedArticle']['title']);
516-
$this->assertCount(3, $result);
515+
$this->assertCount(2, $result);
517516
}
518517

519518
/**

lib/Cake/Test/Case/Model/ModelReadTest.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6685,6 +6685,62 @@ public function testFindAllArrayConditions() {
66856685
$this->assertEquals($expected, $result);
66866686
}
66876687

6688+
public function testFindAllI18nConditions() {
6689+
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User');
6690+
$TestModel = new TranslatedArticle();
6691+
$TestModel->cacheQueries = false;
6692+
$TestModel->locale = 'eng';
6693+
$options = array(
6694+
'recursive' => 0,
6695+
'conditions' => array(
6696+
'NOT' => array('I18n__title.content' => ''),
6697+
),
6698+
'limit' => 2,
6699+
);
6700+
$result = $TestModel->find('all', $options);
6701+
$expected = array(
6702+
array(
6703+
'TranslatedArticle' => array(
6704+
'id' => '1',
6705+
'user_id' => '1',
6706+
'published' => 'Y',
6707+
'created' => '2007-03-18 10:39:23',
6708+
'updated' => '2007-03-18 10:41:31',
6709+
'locale' => 'eng',
6710+
'title' => 'Title (eng) #1',
6711+
'body' => 'Body (eng) #1',
6712+
),
6713+
'User' => array(
6714+
'id' => '1',
6715+
'user' => 'mariano',
6716+
'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
6717+
'created' => '2007-03-17 01:16:23',
6718+
'updated' => '2007-03-17 01:18:31',
6719+
),
6720+
),
6721+
array(
6722+
'TranslatedArticle' => array(
6723+
'id' => '2',
6724+
'user_id' => '3',
6725+
'published' => 'Y',
6726+
'created' => '2007-03-18 10:41:23',
6727+
'updated' => '2007-03-18 10:43:31',
6728+
'locale' => 'eng',
6729+
'title' => 'Title (eng) #2',
6730+
'body' => 'Body (eng) #2',
6731+
),
6732+
'User' => array(
6733+
'id' => '3',
6734+
'user' => 'larry',
6735+
'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
6736+
'created' => '2007-03-17 01:20:23',
6737+
'updated' => '2007-03-17 01:22:31',
6738+
),
6739+
),
6740+
);
6741+
$this->assertEquals($expected, $result);
6742+
}
6743+
66886744
/**
66896745
* test find('list') method
66906746
*
@@ -7118,6 +7174,22 @@ public function testFindCount() {
71187174
$this->assertEquals($expected, $result);
71197175
}
71207176

7177+
public function testFindCountI18nConditions() {
7178+
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User');
7179+
$TestModel = new TranslatedArticle();
7180+
$TestModel->cacheQueries = false;
7181+
$TestModel->locale = 'eng';
7182+
$options = array(
7183+
'recursive' => 0,
7184+
'conditions' => array(
7185+
'NOT' => array('I18n__title.content' => ''),
7186+
),
7187+
'limit' => 2,
7188+
);
7189+
$result = $TestModel->find('count', $options);
7190+
$this->assertEquals(2, $result);
7191+
}
7192+
71217193
/**
71227194
* Test that find('first') does not use the id set to the object.
71237195
*

lib/Cake/Test/Case/Model/ModelTestBase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ abstract class BaseModelTest extends CakeTestCase {
7373
'core.bidding', 'core.bidding_message', 'core.site', 'core.domain', 'core.domains_site',
7474
'core.uuidnativeitem', 'core.uuidnativeportfolio', 'core.uuidnativeitems_uuidnativeportfolio',
7575
'core.uuidnativeitems_uuidnativeportfolio_numericid',
76+
'core.translated_article', 'core.translate_article',
7677
);
7778

7879
/**

0 commit comments

Comments
 (0)