mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
more unit tests
This commit is contained in:
parent
85e0ebd7fd
commit
76ab1f4537
1 changed files with 138 additions and 0 deletions
|
@ -6425,6 +6425,144 @@ class ModelReadTest extends BaseModelTest {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testBuildQueryAllI18nConditions() {
|
||||
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User');
|
||||
$TestModel = new TranslatedArticle();
|
||||
$TestModel->cacheQueries = false;
|
||||
$TestModel->locale = 'eng';
|
||||
$expected = array(
|
||||
'conditions' => array(
|
||||
'NOT' => array('I18n__title.content' => ''),
|
||||
),
|
||||
'fields' => null,
|
||||
'joins' => array(
|
||||
array(
|
||||
'type' => 'INNER',
|
||||
'alias' => 'I18n__title',
|
||||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'test',
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
'type' => 'identifier',
|
||||
'value' => 'I18n__title.foreign_key',
|
||||
),
|
||||
'I18n__title.model' => 'TranslatedArticle',
|
||||
'I18n__title.field' => 'title',
|
||||
'I18n__title.locale' => 'eng',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'INNER',
|
||||
'alias' => 'I18n__body',
|
||||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'test',
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
'type' => 'identifier',
|
||||
'value' => 'I18n__body.foreign_key',
|
||||
),
|
||||
'I18n__body.model' => 'TranslatedArticle',
|
||||
'I18n__body.field' => 'body',
|
||||
'I18n__body.locale' => 'eng',
|
||||
),
|
||||
),
|
||||
),
|
||||
'limit' => 2,
|
||||
'offset' => null,
|
||||
'order' => array(
|
||||
'TranslatedArticle.id' => 'ASC',
|
||||
),
|
||||
'page' => 1,
|
||||
'group' => null,
|
||||
'callbacks' => true,
|
||||
'recursive' => 0,
|
||||
);
|
||||
$query= array(
|
||||
'recursive' => 0,
|
||||
'conditions' => array(
|
||||
'NOT' => array('I18n__title.content' => ''),
|
||||
),
|
||||
'limit' => 2,
|
||||
);
|
||||
$result = $TestModel->buildQuery('all', $query);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testBuildQueryCountI18nConditions() {
|
||||
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User');
|
||||
$TestModel = new TranslatedArticle();
|
||||
$TestModel->cacheQueries = false;
|
||||
$TestModel->locale = 'eng';
|
||||
$expected = array(
|
||||
'conditions' => array(
|
||||
'NOT' => array('I18n__title.content' => ''),
|
||||
),
|
||||
'fields' => 'COUNT(DISTINCT(`TranslatedArticle`.`id`)) AS count',
|
||||
'joins' => array(
|
||||
array(
|
||||
'type' => 'INNER',
|
||||
'alias' => 'I18n__title',
|
||||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'test',
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
'type' => 'identifier',
|
||||
'value' => 'I18n__title.foreign_key',
|
||||
),
|
||||
'I18n__title.model' => 'TranslatedArticle',
|
||||
'I18n__title.field' => 'title',
|
||||
'I18n__title.locale' => 'eng',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'INNER',
|
||||
'alias' => 'I18n__body',
|
||||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'test',
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
'type' => 'identifier',
|
||||
'value' => 'I18n__body.foreign_key',
|
||||
),
|
||||
'I18n__body.model' => 'TranslatedArticle',
|
||||
'I18n__body.field' => 'body',
|
||||
'I18n__body.locale' => 'eng',
|
||||
),
|
||||
),
|
||||
),
|
||||
'limit' => 2,
|
||||
'offset' => null,
|
||||
'order' => array(
|
||||
0 => false,
|
||||
),
|
||||
'page' => 1,
|
||||
'group' => null,
|
||||
'callbacks' => true,
|
||||
'recursive' => 0,
|
||||
);
|
||||
$query= array(
|
||||
'recursive' => 0,
|
||||
'conditions' => array(
|
||||
'NOT' => array('I18n__title.content' => ''),
|
||||
),
|
||||
'limit' => 2,
|
||||
);
|
||||
$result = $TestModel->buildQuery('count', $query);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test find('all') method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue