Browse Source

Cleaning up test, but it'll probably still fail in postgres

Patrick Conroy 10 years ago
parent
commit
4b0379e5fe

+ 7 - 7
tests/Fixture/FeaturedTagsFixture.php

@@ -1,6 +1,6 @@
 <?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
@@ -8,8 +8,8 @@
  * 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;
@@ -17,7 +17,7 @@ namespace Cake\Test\Fixture;
 use Cake\TestSuite\Fixture\TestFixture;
 
 /**
- * Class TagFixture
+ * Class FeaturedTagsFixture
  *
  */
 class FeaturedTagsFixture extends TestFixture
@@ -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]
     ];
 }

+ 9 - 10
tests/Fixture/TagsTranslationsFixture.php

@@ -1,6 +1,6 @@
 <?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
@@ -8,8 +8,8 @@
  * 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;
@@ -17,7 +17,7 @@ namespace Cake\Test\Fixture;
 use Cake\TestSuite\Fixture\TestFixture;
 
 /**
- * Class TagFixture
+ * Class TagsTranslationsFixture
  *
  */
 class TagsTranslationsFixture extends TestFixture
@@ -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']]]
     ];
 
     /**
@@ -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']
     ];
 }

+ 5 - 26
tests/TestCase/ORM/QueryRegressionTest.php

@@ -545,8 +545,7 @@ class QueryRegressionTest extends TestCase
         $findViaSelect = $featuredTags
             ->find()
             ->where(['FeaturedTags.tag_id' => 2])
-            ->contain('Tags.TagsTranslations')
-            ->first();
+            ->contain('Tags.TagsTranslations');
 
         $tags->hasMany('TagsTranslations', [
             'foreignKey' => 'id',
@@ -555,32 +554,12 @@ class QueryRegressionTest extends TestCase
         $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());
     }
 
     /**