Skip to content

Commit

Permalink
Cleaning up test, but it'll probably still fail in postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Conroy authored and lorenzo committed Jun 14, 2015
1 parent 3d2ae62 commit 4b0379e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 43 deletions.
14 changes: 7 additions & 7 deletions tests/Fixture/FeaturedTagsFixture.php
@@ -1,23 +1,23 @@
<?php
/**
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* CakePHP(tm) Tests <http://book.cakephp.org/3.0/en/development/testing.html>
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @since 1.2.0
* @link http://book.cakephp.org/3.0/en/development/testing.html CakePHP(tm) Tests
* @since 3.0.7
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Test\Fixture;

use Cake\TestSuite\Fixture\TestFixture;

/**
* Class TagFixture
* Class FeaturedTagsFixture
*
*/
class FeaturedTagsFixture extends TestFixture
Expand All @@ -40,8 +40,8 @@ class FeaturedTagsFixture extends TestFixture
* @var array
*/
public $records = [
['tag_id' => 1, 'priority' => 1],
['tag_id' => 2, 'priority' => 2],
['tag_id' => 3, 'priority' => 3]
['priority' => 1],
['priority' => 2],
['priority' => 3]
];
}
19 changes: 9 additions & 10 deletions tests/Fixture/TagsTranslationsFixture.php
@@ -1,23 +1,23 @@
<?php
/**
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* CakePHP(tm) Tests <http://book.cakephp.org/3.0/en/development/testing.html>
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @since 1.2.0
* @link http://book.cakephp.org/3.0/en/development/testing.html CakePHP(tm) Tests
* @since 3.0.7
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Test\Fixture;

use Cake\TestSuite\Fixture\TestFixture;

/**
* Class TagFixture
* Class TagsTranslationsFixture
*
*/
class TagsTranslationsFixture extends TestFixture
Expand All @@ -29,10 +29,10 @@ class TagsTranslationsFixture extends TestFixture
* @var array
*/
public $fields = [
'id' => ['type' => 'integer', 'null' => false],
'id' => ['type' => 'integer', 'null' => false, 'autoIncrement' => false],
'locale' => ['type' => 'string', 'null' => false],
'name' => ['type' => 'string', 'null' => false],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'locale']]]
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
];

/**
Expand All @@ -41,9 +41,8 @@ class TagsTranslationsFixture extends TestFixture
* @var array
*/
public $records = [
['id' => '1', 'locale' => 'en_us', 'name' => 'tag 1 translated into en_us'],
['id' => '1', 'locale' => 'de_de', 'name' => 'tag 1 translated into de_de'],
['id' => '2', 'locale' => 'en_us', 'name' => 'tag 2 translated into en_us'],
['id' => '2', 'locale' => 'de_de', 'name' => 'tag 2 translated into de_de'],
['locale' => 'en_us', 'name' => 'tag 1 translated into en_us'],
['locale' => 'en_us', 'name' => 'tag 2 translated into en_us'],
['locale' => 'en_us', 'name' => 'tag 3 translated into en_us']
];
}
31 changes: 5 additions & 26 deletions tests/TestCase/ORM/QueryRegressionTest.php
Expand Up @@ -545,8 +545,7 @@ public function testDeepHasManyEitherStrategy()
$findViaSelect = $featuredTags
->find()
->where(['FeaturedTags.tag_id' => 2])
->contain('Tags.TagsTranslations')
->first();
->contain('Tags.TagsTranslations');

$tags->hasMany('TagsTranslations', [
'foreignKey' => 'id',
Expand All @@ -555,32 +554,12 @@ public function testDeepHasManyEitherStrategy()
$findViaSubquery = $featuredTags
->find()
->where(['FeaturedTags.tag_id' => 2])
->contain('Tags.TagsTranslations')
->first();
->contain('Tags.TagsTranslations');

$expected = [
'tag_id' => 2,
'priority' => 2,
'tag' => [
'id' => 2,
'name' => 'tag2',
'tags_translations' => [
[
'id' => 2,
'locale' => 'de_de',
'name' => 'tag 2 translated into de_de'
],
[
'id' => 2,
'locale' => 'en_us',
'name' => 'tag 2 translated into en_us'
]
]
]
];
$expected = [2 => 'tag 2 translated into en_us'];

$this->assertEquals($expected, $findViaSelect->toArray());
$this->assertEquals($expected, $findViaSubquery->toArray());
$this->assertEquals($expected, $findViaSelect->combine('tag_id', 'tag.tags_translations.0.name')->toArray());
$this->assertEquals($expected, $findViaSubquery->combine('tag_id', 'tag.tags_translations.0.name')->toArray());
}

/**
Expand Down

0 comments on commit 4b0379e

Please sign in to comment.