Browse Source

Merge remote-tracking branch 'origin/master' into 3.2

Jose Lorenzo Rodriguez 10 years ago
parent
commit
5e8043dfb9

+ 2 - 0
.travis.yml

@@ -63,6 +63,8 @@ before_script:
   - sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi"
 
   - sh -c "if [ '$HHVM' != '1' ]; then echo 'extension = memcached.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
+  - sh -c "if [ '$HHVM' != '1' ]; then echo 'extension = redis.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
+  - sh -c "if [ '$HHVM' != '1' ]; then echo 'extension = apc.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
   - sh -c "if [ '$HHVM' = '1' ]; then composer require lorenzo/multiple-iterator=~1.0; fi"
 
   - phpenv rehash

+ 0 - 1
phpunit.xml.dist

@@ -36,7 +36,6 @@
     <filter>
         <whitelist>
             <directory suffix=".php">./src/</directory>
-            <directory suffix=".ctp">./src/</directory>
         </whitelist>
     </filter>
 

+ 2 - 0
src/Database/Type.php

@@ -259,6 +259,7 @@ class Type
      *
      * @param mixed $value The value to convert to a boolean.
      * @return bool
+     * @deprecated 3.1.8 This method is now unused.
      */
     public static function boolval($value)
     {
@@ -275,6 +276,7 @@ class Type
      *
      * @param mixed $value The value to convert to a string.
      * @return bool
+     * @deprecated 3.1.8 This method is now unused.
      */
     public static function strval($value)
     {

+ 1 - 1
src/Database/Type/UuidType.php

@@ -59,7 +59,7 @@ class UuidType extends StringType
      */
     public function marshal($value)
     {
-        if ($value === null || $value === '') {
+        if ($value === null || $value === '' || is_array($value)) {
             return null;
         }
         return (string)$value;

+ 4 - 1
src/Network/Exception/HttpException.php

@@ -19,7 +19,10 @@ use Cake\Core\Exception\Exception;
  * All HTTP status/error related exceptions should extend this class so
  * catch blocks can be specifically typed.
  *
+ * You may also use this as a meaningful bridge to Cake\Core\Exception\Exception, e.g.:
+ * throw new \Cake\Network\Exception\HttpException('HTTP Version Not Supported', 505);
+ *
  */
-abstract class HttpException extends Exception
+class HttpException extends Exception
 {
 }

+ 0 - 1
src/ORM/Association/BelongsToMany.php

@@ -626,7 +626,6 @@ class BelongsToMany extends Association
             if (!$joint || !($joint instanceof EntityInterface)) {
                 $joint = new $entityClass([], ['markNew' => true, 'source' => $junctionAlias]);
             }
-
             $sourceKeys = array_combine($foreignKey, $sourceEntity->extract($bindingKey));
             $targetKeys = array_combine($assocForeignKey, $e->extract($targetPrimaryKey));
 

+ 1 - 1
src/ORM/Marshaller.php

@@ -664,7 +664,7 @@ class Marshaller
             return [];
         }
 
-        if (!in_array('_joinData', $associated) && !isset($associated['_joinData'])) {
+        if (!empty($associated) && !in_array('_joinData', $associated) && !isset($associated['_joinData'])) {
             return $this->mergeMany($original, $value, $options);
         }
 

+ 14 - 9
src/TestSuite/Fixture/TestFixture.php

@@ -20,6 +20,7 @@ use Cake\Datasource\ConnectionInterface;
 use Cake\Datasource\ConnectionManager;
 use Cake\Datasource\FixtureInterface;
 use Cake\Log\Log;
+use Cake\ORM\TableRegistry;
 use Cake\Utility\Inflector;
 use Exception;
 
@@ -58,11 +59,11 @@ class TestFixture implements FixtureInterface
     /**
      * Configuration for importing fixture schema
      *
-     * Accepts a `connection` and `table` key, to define
+     * Accepts a `connection` and `model` or `table` key, to define
      * which table and which connection contain the schema to be
      * imported.
      *
-     * @var array
+     * @var array|null
      */
     public $import = null;
 
@@ -100,7 +101,7 @@ class TestFixture implements FixtureInterface
                 $message = sprintf(
                     'Invalid datasource name "%s" for "%s" fixture. Fixture datasource names must begin with "test".',
                     $connection,
-                    $this->name
+                    $this->table
                 );
                 throw new CakeException($message);
             }
@@ -196,17 +197,21 @@ class TestFixture implements FixtureInterface
         if (!is_array($this->import)) {
             return;
         }
-        $import = array_merge(
-            ['connection' => 'default', 'table' => null],
-            $this->import
-        );
+        $import = $this->import + ['connection' => 'default', 'table' => null, 'model' => null];
+
+        if (!empty($import['model'])) {
+            if (!empty($import['table'])) {
+                throw new CakeException('You cannot define both table and model.');
+            }
+            $import['table'] = TableRegistry::get($import['model'])->table();
+        }
 
         if (empty($import['table'])) {
             throw new CakeException('Cannot import from undefined table.');
-        } else {
-            $this->table = $import['table'];
         }
 
+        $this->table = $import['table'];
+
         $db = ConnectionManager::get($import['connection'], false);
         $schemaCollection = $db->schemaCollection();
         $table = $schemaCollection->describe($import['table']);

+ 32 - 0
tests/TestCase/Cache/CacheTest.php

@@ -96,6 +96,38 @@ class CacheTest extends TestCase
     }
 
     /**
+     * Test configuring an invalid class fails
+     *
+     * @expectedException \RuntimeException
+     * @expectedExceptionMessage Cache engines must use Cake\Cache\CacheEngine
+     * @return void
+     */
+    public function testConfigInvalidClassType()
+    {
+        Cache::config('tests', [
+            'className' => '\StdClass'
+        ]);
+        Cache::engine('tests');
+    }
+
+    /**
+     * Test engine init failing causes an error
+     *
+     * @expectedException \RuntimeException
+     * @expectedExceptionMessage not properly configured
+     * @return void
+     */
+    public function testConfigFailedInit()
+    {
+        $mock = $this->getMockForAbstractClass('Cake\Cache\CacheEngine', [], '', true, true, true, ['init']);
+        $mock->method('init')->will($this->returnValue(false));
+        Cache::config('tests', [
+            'engine' => $mock
+        ]);
+        Cache::engine('tests');
+    }
+
+    /**
      * test configuring CacheEngines in App/libs
      *
      * @return void

+ 1 - 0
tests/TestCase/Database/QueryTest.php

@@ -261,6 +261,7 @@ class QueryTest extends TestCase
      */
     public function testSelectAliasedJoins()
     {
+        $this->skipIf(version_compare(PHP_VERSION, '5.6.0', '<'), 'This test fails on travis for older PHP.');
         $query = new Query($this->connection);
         $result = $query
             ->select(['title', 'name'])

+ 132 - 0
tests/TestCase/Database/Type/BoolTypeTest.php

@@ -0,0 +1,132 @@
+<?php
+/**
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
+ * 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://cakephp.org CakePHP(tm) Project
+ * @since         3.1.7
+ * @license       http://www.opensource.org/licenses/mit-license.php MIT License
+ */
+namespace Cake\Test\TestCase\Database\Type;
+
+use Cake\Database\Type;
+use Cake\TestSuite\TestCase;
+use \PDO;
+
+/**
+ * Test for the Boolean type.
+ */
+class BoolTypeTest extends TestCase
+{
+
+    /**
+     * Setup
+     *
+     * @return void
+     */
+    public function setUp()
+    {
+        parent::setUp();
+        $this->type = Type::build('boolean');
+        $this->driver = $this->getMock('Cake\Database\Driver');
+    }
+
+    /**
+     * Test converting to database format
+     *
+     * @return void
+     */
+    public function testToDatabase()
+    {
+        $this->assertNull($this->type->toDatabase(null, $this->driver));
+        $this->assertTrue($this->type->toDatabase(true, $this->driver));
+        $this->assertFalse($this->type->toDatabase(false, $this->driver));
+        $this->assertTrue($this->type->toDatabase(1, $this->driver));
+        $this->assertFalse($this->type->toDatabase(0, $this->driver));
+        $this->assertTrue($this->type->toDatabase('1', $this->driver));
+        $this->assertFalse($this->type->toDatabase('0', $this->driver));
+    }
+
+    /**
+     * Test converting an array to boolean results in an exception
+     *
+     * @expectedException InvalidArgumentException
+     * @return void
+     */
+    public function testToDatabaseInvalid()
+    {
+        $this->type->toDatabase([1, 2], $this->driver);
+    }
+
+
+    /**
+     * Tests that passing an invalid value will throw an exception
+     *
+     * @expectedException InvalidArgumentException
+     * @return void
+     */
+    public function testToDatabaseInvalidArray()
+    {
+        $this->type->toDatabase([1, 2, 3], $this->driver);
+    }
+
+    /**
+     * Test convertring string booleans to PHP values.
+     *
+     * @return void
+     */
+    public function testToPHP()
+    {
+        $this->assertNull($this->type->toPHP(null, $this->driver));
+        $this->assertTrue($this->type->toPHP(true, $this->driver));
+        $this->assertTrue($this->type->toPHP(1, $this->driver));
+        $this->assertTrue($this->type->toPHP('1', $this->driver));
+        $this->assertTrue($this->type->toPHP('TRUE', $this->driver));
+        $this->assertTrue($this->type->toPHP('true', $this->driver));
+
+        $this->assertFalse($this->type->toPHP(false, $this->driver));
+        $this->assertFalse($this->type->toPHP(0, $this->driver));
+        $this->assertFalse($this->type->toPHP('0', $this->driver));
+        $this->assertFalse($this->type->toPHP('FALSE', $this->driver));
+        $this->assertFalse($this->type->toPHP('false', $this->driver));
+        $this->assertTrue($this->type->toPHP(['2', '3'], $this->driver));
+    }
+
+    /**
+     * Test marshalling booleans
+     *
+     * @return void
+     */
+    public function testMarshal()
+    {
+        $this->assertNull($this->type->marshal(null));
+        $this->assertTrue($this->type->marshal(true));
+        $this->assertTrue($this->type->marshal(1));
+        $this->assertTrue($this->type->marshal('1'));
+        $this->assertTrue($this->type->marshal('true'));
+
+        $this->assertFalse($this->type->marshal('false'));
+        $this->assertFalse($this->type->marshal('0'));
+        $this->assertFalse($this->type->marshal(0));
+        $this->assertFalse($this->type->marshal(''));
+        $this->assertTrue($this->type->marshal('not empty'));
+        $this->assertTrue($this->type->marshal(['2', '3']));
+    }
+
+    /**
+     * Test convertring booleans to PDO types.
+     *
+     * @return void
+     */
+    public function testToStatement()
+    {
+        $this->assertEquals(PDO::PARAM_NULL, $this->type->toStatement(null, $this->driver));
+        $this->assertEquals(PDO::PARAM_BOOL, $this->type->toStatement(true, $this->driver));
+        $this->assertEquals(PDO::PARAM_BOOL, $this->type->toStatement(false, $this->driver));
+    }
+}

+ 17 - 0
tests/TestCase/Database/Type/DateTimeTypeTest.php

@@ -207,6 +207,23 @@ class DateTimeTypeTest extends TestCase
     }
 
     /**
+     * Test that useLocaleParser() can disable locale parsing.
+     *
+     * @return void
+     */
+    public function testLocaleParserDisable()
+    {
+        $expected = new Time('13-10-2013 23:28:00');
+        $this->type->useLocaleParser();
+        $result = $this->type->marshal('10/13/2013 11:28pm');
+        $this->assertEquals($expected, $result);
+
+        $this->type->useLocaleParser(false);
+        $result = $this->type->marshal('10/13/2013 11:28pm');
+        $this->assertNotEquals($expected, $result);
+    }
+
+    /**
      * Tests marshalling dates using the locale aware parser
      *
      * @return void

+ 2 - 0
tests/TestCase/Database/Type/IntegerTypeTest.php

@@ -69,6 +69,8 @@ class IntegerTypeTest extends TestCase
      */
     public function testToDatabase()
     {
+        $this->assertNull($this->type->toDatabase(null, $this->driver));
+
         $result = $this->type->toDatabase('some data', $this->driver);
         $this->assertSame(0, $result);
 

+ 100 - 0
tests/TestCase/Database/Type/StringTypeTest.php

@@ -0,0 +1,100 @@
+<?php
+/**
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
+ * 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://cakephp.org CakePHP(tm) Project
+ * @since         3.1.7
+ * @license       http://www.opensource.org/licenses/mit-license.php MIT License
+ */
+namespace Cake\Test\TestCase\Database\Type;
+
+use Cake\Database\Type;
+use Cake\TestSuite\TestCase;
+use \PDO;
+
+/**
+ * Test for the String type.
+ */
+class StringTypeTest extends TestCase
+{
+
+    /**
+     * Setup
+     *
+     * @return void
+     */
+    public function setUp()
+    {
+        parent::setUp();
+        $this->type = Type::build('string');
+        $this->driver = $this->getMock('Cake\Database\Driver');
+    }
+
+    /**
+     * Test toPHP
+     *
+     * @return void
+     */
+    public function testToPHP()
+    {
+        $this->assertNull($this->type->toPHP(null, $this->driver));
+        $this->assertSame('word', $this->type->toPHP('word', $this->driver));
+        $this->assertSame('2.123', $this->type->toPHP(2.123, $this->driver));
+    }
+
+    /**
+     * Test converting to database format
+     *
+     * @return void
+     */
+    public function testToDatabase()
+    {
+        $obj = $this->getMock('StdClass', ['__toString']);
+        $obj->method('__toString')->will($this->returnValue('toString called'));
+
+        $this->assertNull($this->type->toDatabase(null, $this->driver));
+        $this->assertSame('word', $this->type->toDatabase('word', $this->driver));
+        $this->assertSame('2.123', $this->type->toDatabase(2.123, $this->driver));
+        $this->assertSame('toString called', $this->type->toDatabase($obj, $this->driver));
+    }
+
+    /**
+     * Tests that passing an invalid value will throw an exception
+     *
+     * @expectedException InvalidArgumentException
+     * @return void
+     */
+    public function testToDatabaseInvalidArray()
+    {
+        $this->type->toDatabase([1, 2, 3], $this->driver);
+    }
+
+    /**
+     * Test marshalling
+     *
+     * @return void
+     */
+    public function testMarshal()
+    {
+        $this->assertNull($this->type->marshal(null));
+        $this->assertSame('word', $this->type->marshal('word'));
+        $this->assertSame('2.123', $this->type->marshal(2.123));
+        $this->assertSame('', $this->type->marshal([1, 2, 3]));
+    }
+
+    /**
+     * Test that the PDO binding type is correct.
+     *
+     * @return void
+     */
+    public function testToStatement()
+    {
+        $this->assertEquals(PDO::PARAM_STR, $this->type->toStatement('', $this->driver));
+    }
+}

+ 10 - 1
tests/TestCase/Database/Type/UuidTypeTest.php

@@ -65,6 +65,12 @@ class UuidTypeTest extends TestCase
 
         $result = $this->type->toDatabase(2, $this->driver);
         $this->assertSame('2', $result);
+
+        $result = $this->type->toDatabase(null, $this->driver);
+        $this->assertNull($result);
+
+        $result = $this->type->toDatabase('', $this->driver);
+        $this->assertNull($result);
     }
 
     /**
@@ -97,8 +103,11 @@ class UuidTypeTest extends TestCase
      *
      * @return void
      */
-    public function testMarshalEmptyString()
+    public function testMarshal()
     {
         $this->assertNull($this->type->marshal(''));
+        $this->assertSame('2', $this->type->marshal(2));
+        $this->assertSame('word', $this->type->marshal('word'));
+        $this->assertNull($this->type->marshal([1, 2]));
     }
 }

+ 0 - 190
tests/TestCase/Database/TypeTest.php

@@ -91,7 +91,6 @@ class TypeTest extends TestCase
         return [
             ['string'],
             ['text'],
-            ['boolean']
         ];
     }
 
@@ -194,195 +193,6 @@ class TypeTest extends TestCase
     }
 
     /**
-     * Tests string from database are converted correctly to PHP
-     *
-     * @return void
-     */
-    public function testStringToPHP()
-    {
-        $type = Type::build('string');
-        $string = 'foo';
-        $driver = $this->getMock('\Cake\Database\Driver');
-        $this->assertEquals('foo', $type->toPHP($string, $driver));
-        $this->assertEquals('3', $type->toPHP(3, $driver));
-        $this->assertEquals('3.14159', $type->toPHP(3.14159, $driver));
-    }
-
-    /**
-     * Tests that passing a non-scalar value will thow an exception
-     *
-     * @expectedException InvalidArgumentException
-     * @return void
-     */
-    public function testStringToDatabaseNoScalar()
-    {
-        $type = Type::build('string');
-        $driver = $this->getMock('\Cake\Database\Driver');
-        $type->toDatabase(['123'], $driver);
-    }
-
-    /**
-     * Tests integers from PHP are converted correctly to statement value
-     *
-     * @return void
-     */
-    public function testStringToStatement()
-    {
-        $type = Type::build('string');
-        $string = '3';
-        $driver = $this->getMock('\Cake\Database\Driver');
-        $this->assertEquals(PDO::PARAM_STR, $type->toStatement($string, $driver));
-    }
-
-    /**
-     * Tests integers from database are converted correctly to PHP
-     *
-     * @return void
-     */
-    public function testTextToPHP()
-    {
-        $type = Type::build('string');
-        $string = 'foo';
-        $driver = $this->getMock('\Cake\Database\Driver');
-        $this->assertEquals('foo', $type->toPHP($string, $driver));
-        $this->assertEquals('3', $type->toPHP(3, $driver));
-        $this->assertEquals('3.14159', $type->toPHP(3.14159, $driver));
-    }
-
-    /**
-     * Tests integers from PHP are converted correctly to statement value
-     *
-     * @return void
-     */
-    public function testTextToStatement()
-    {
-        $type = Type::build('string');
-        $string = '3';
-        $driver = $this->getMock('\Cake\Database\Driver');
-        $this->assertEquals(PDO::PARAM_STR, $type->toStatement($string, $driver));
-    }
-
-    /**
-     * Test converting booleans to database types.
-     *
-     * @return void
-     */
-    public function testBooleanToDatabase()
-    {
-        $type = Type::build('boolean');
-        $driver = $this->getMock('\Cake\Database\Driver');
-
-        $this->assertNull($type->toDatabase(null, $driver));
-        $this->assertTrue($type->toDatabase(true, $driver));
-        $this->assertFalse($type->toDatabase(false, $driver));
-        $this->assertTrue($type->toDatabase(1, $driver));
-        $this->assertFalse($type->toDatabase(0, $driver));
-        $this->assertTrue($type->toDatabase('1', $driver));
-        $this->assertFalse($type->toDatabase('0', $driver));
-    }
-
-    /**
-     * Test converting an array to boolean results in an exception
-     *
-     * @expectedException InvalidArgumentException
-     * @return void
-     */
-    public function testBooleanToDatabaseError()
-    {
-        $type = Type::build('boolean');
-        $driver = $this->getMock('\Cake\Database\Driver');
-        $this->assertTrue($type->toDatabase([1, 2], $driver));
-    }
-
-    /**
-     * Test convertring booleans to PDO types.
-     *
-     * @return void
-     */
-    public function testBooleanToStatement()
-    {
-        $type = Type::build('boolean');
-        $driver = $this->getMock('\Cake\Database\Driver');
-
-        $this->assertEquals(PDO::PARAM_BOOL, $type->toStatement(true, $driver));
-        $this->assertEquals(PDO::PARAM_BOOL, $type->toStatement(false, $driver));
-    }
-
-    /**
-     * Test convertring string booleans to PHP values.
-     *
-     * @return void
-     */
-    public function testBooleanToPHP()
-    {
-        $type = Type::build('boolean');
-        $driver = $this->getMock('\Cake\Database\Driver');
-
-        $this->assertTrue($type->toPHP(true, $driver));
-        $this->assertTrue($type->toPHP(1, $driver));
-        $this->assertTrue($type->toPHP('1', $driver));
-        $this->assertTrue($type->toPHP('TRUE', $driver));
-        $this->assertTrue($type->toPHP('true', $driver));
-
-        $this->assertFalse($type->toPHP(false, $driver));
-        $this->assertFalse($type->toPHP(0, $driver));
-        $this->assertFalse($type->toPHP('0', $driver));
-        $this->assertFalse($type->toPHP('FALSE', $driver));
-        $this->assertFalse($type->toPHP('false', $driver));
-        $this->assertTrue($type->toPHP(['2', '3'], $driver));
-    }
-
-    /**
-     * Test marshalling booleans
-     *
-     * @return void
-     */
-    public function testBooleanMarshal()
-    {
-        $type = Type::build('boolean');
-        $this->assertTrue($type->marshal(true));
-        $this->assertTrue($type->marshal(1));
-        $this->assertTrue($type->marshal('1'));
-        $this->assertTrue($type->marshal('true'));
-
-        $this->assertFalse($type->marshal('false'));
-        $this->assertFalse($type->marshal('0'));
-        $this->assertFalse($type->marshal(0));
-        $this->assertFalse($type->marshal(''));
-        $this->assertTrue($type->marshal('not empty'));
-        $this->assertTrue($type->marshal(['2', '3']));
-    }
-
-
-    /**
-     * Tests uuid from database are converted correctly to PHP
-     *
-     * @return void
-     */
-    public function testUuidToPHP()
-    {
-        $type = Type::build('uuid');
-        $string = 'abc123-de456-fg789';
-        $driver = $this->getMock('\Cake\Database\Driver');
-        $this->assertEquals($string, $type->toPHP($string, $driver));
-        $this->assertEquals('3', $type->toPHP(3, $driver));
-        $this->assertEquals('3.14159', $type->toPHP(3.14159, $driver));
-    }
-
-    /**
-     * Tests integers from PHP are converted correctly to statement value
-     *
-     * @return void
-     */
-    public function testUuidToStatement()
-    {
-        $type = Type::build('uuid');
-        $string = 'abc123-def456-ghi789';
-        $driver = $this->getMock('\Cake\Database\Driver');
-        $this->assertEquals(PDO::PARAM_STR, $type->toStatement($string, $driver));
-    }
-
-    /**
      * Tests decimal from database are converted correctly to PHP
      *
      * @return void

+ 40 - 0
tests/TestCase/ORM/MarshallerTest.php

@@ -1731,6 +1731,46 @@ class MarshallerTest extends TestCase
     }
 
     /**
+     * Test that _joinData is marshalled consistently with both
+     * new and existing records
+     *
+     * @return void
+     */
+    public function testMergeBelongsToManyHandleJoinDataConsistently()
+    {
+        TableRegistry::clear();
+        $articles = TableRegistry::get('Articles');
+        $articles->belongsToMany('Tags', [
+            'through' => 'SpecialTags'
+        ]);
+
+        $entity = $articles->get(1);
+        $data = [
+            'title' => 'Haz data',
+            'tags' => [
+                ['id' => 3, 'tag' => 'Cake', '_joinData' => ['highlighted' => true]],
+            ]
+        ];
+        $marshall = new Marshaller($articles);
+        $result = $marshall->merge($entity, $data, ['associated' => 'Tags']);
+        $this->assertInstanceOf('Cake\ORM\Entity', $result->tags[0]->_joinData);
+        $this->assertTrue($result->tags[0]->_joinData->highlighted);
+
+        // Also ensure merge() overwrites existing data.
+        $entity = $articles->get(1, ['contain' => 'Tags']);
+        $data = [
+            'title' => 'Haz data',
+            'tags' => [
+                ['id' => 3, 'tag' => 'Cake', '_joinData' => ['highlighted' => true]],
+            ]
+        ];
+        $marshall = new Marshaller($articles);
+        $result = $marshall->merge($entity, $data, ['associated' => 'Tags']);
+        $this->assertInstanceOf('Cake\ORM\Entity', $result->tags[0]->_joinData);
+        $this->assertTrue($result->tags[0]->_joinData->highlighted);
+    }
+
+    /**
      * Test merging belongsToMany data doesn't create 'new' entities.
      *
      * @return void

+ 25 - 0
tests/TestCase/TestSuite/TestFixtureTest.php

@@ -213,6 +213,31 @@ class TestFixtureTest extends TestCase
     }
 
     /**
+     * test import fixture initialization
+     *
+     * @return void
+     */
+    public function testInitImportModel()
+    {
+        $fixture = new ImportsFixture();
+        $fixture->fields = $fixture->records = null;
+        $fixture->import = [
+            'model' => 'Posts',
+            'connection' => 'test',
+        ];
+        $fixture->init();
+
+        $expected = [
+            'id',
+            'author_id',
+            'title',
+            'body',
+            'published',
+        ];
+        $this->assertEquals($expected, $fixture->schema()->columns());
+    }
+
+    /**
      * test create method
      *
      * @return void