Skip to content

Commit

Permalink
more unit tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
bancer committed Jul 5, 2017
1 parent 5033467 commit 85e0ebd
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 3 deletions.
Expand Up @@ -505,15 +505,14 @@ public function testPaginateI18nConditionNotTitleWithLimit() {
$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);
}

/**
Expand Down
72 changes: 72 additions & 0 deletions lib/Cake/Test/Case/Model/ModelReadTest.php
Expand Up @@ -6685,6 +6685,62 @@ public function testFindAllArrayConditions() {
$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
*
Expand Down Expand Up @@ -7118,6 +7174,22 @@ public function testFindCount() {
$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.
*
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Case/Model/ModelTestBase.php
Expand Up @@ -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',
);

/**
Expand Down

0 comments on commit 85e0ebd

Please sign in to comment.