more unit tests added

This commit is contained in:
Val Bancer 2017-07-05 23:22:58 +02:00
parent 50334679d6
commit 85e0ebd7fd
3 changed files with 75 additions and 3 deletions

View file

@ -512,8 +512,7 @@ class PaginatorComponentTest extends CakeTestCase {
$result = $Controller->Paginator->paginate('TranslatedArticle'); $result = $Controller->Paginator->paginate('TranslatedArticle');
$this->assertEquals('Title (eng) #1', $result[0]['TranslatedArticle']['title']); $this->assertEquals('Title (eng) #1', $result[0]['TranslatedArticle']['title']);
$this->assertEquals('Title (eng) #2', $result[1]['TranslatedArticle']['title']); $this->assertEquals('Title (eng) #2', $result[1]['TranslatedArticle']['title']);
$this->assertEquals('Title (eng) #3', $result[2]['TranslatedArticle']['title']); $this->assertCount(2, $result);
$this->assertCount(3, $result);
} }
/** /**

View file

@ -6685,6 +6685,62 @@ class ModelReadTest extends BaseModelTest {
$this->assertEquals($expected, $result); $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 * test find('list') method
* *
@ -7118,6 +7174,22 @@ class ModelReadTest extends BaseModelTest {
$this->assertEquals($expected, $result); $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. * Test that find('first') does not use the id set to the object.
* *

View file

@ -73,6 +73,7 @@ abstract class BaseModelTest extends CakeTestCase {
'core.bidding', 'core.bidding_message', 'core.site', 'core.domain', 'core.domains_site', 'core.bidding', 'core.bidding_message', 'core.site', 'core.domain', 'core.domains_site',
'core.uuidnativeitem', 'core.uuidnativeportfolio', 'core.uuidnativeitems_uuidnativeportfolio', 'core.uuidnativeitem', 'core.uuidnativeportfolio', 'core.uuidnativeitems_uuidnativeportfolio',
'core.uuidnativeitems_uuidnativeportfolio_numericid', 'core.uuidnativeitems_uuidnativeportfolio_numericid',
'core.translated_article', 'core.translate_article',
); );
/** /**