mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
more unit tests added
This commit is contained in:
parent
50334679d6
commit
85e0ebd7fd
3 changed files with 75 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue