Browse Source

Fix deprecated method use in Association & Table tests.

Mark Story 8 years ago
parent
commit
fe986588a8

+ 16 - 16
tests/TestCase/ORM/Association/BelongsToManyTest.php

@@ -49,7 +49,7 @@ class BelongsToManyTest extends TestCase
             ->setMethods(['find', 'delete'])
             ->setConstructorArgs([['alias' => 'Tags', 'table' => 'tags']])
             ->getMock();
-        $this->tag->schema([
+        $this->tag->setSchema([
             'id' => ['type' => 'integer'],
             'name' => ['type' => 'string'],
             '_constraints' => [
@@ -60,7 +60,7 @@ class BelongsToManyTest extends TestCase
             ->setMethods(['find', 'delete'])
             ->setConstructorArgs([['alias' => 'Articles', 'table' => 'articles']])
             ->getMock();
-        $this->article->schema([
+        $this->article->setSchema([
             'id' => ['type' => 'integer'],
             'name' => ['type' => 'string'],
             '_constraints' => [
@@ -188,8 +188,8 @@ class BelongsToManyTest extends TestCase
         ]);
         $junction = $assoc->junction();
         $this->assertInstanceOf(Table::class, $junction);
-        $this->assertEquals('ArticlesTags', $junction->alias());
-        $this->assertEquals('articles_tags', $junction->table());
+        $this->assertEquals('ArticlesTags', $junction->getAlias());
+        $this->assertEquals('articles_tags', $junction->getTable());
         $this->assertSame($this->article, $junction->getAssociation('Articles')->getTarget());
         $this->assertSame($this->tag, $junction->getAssociation('Tags')->getTarget());
 
@@ -227,7 +227,7 @@ class BelongsToManyTest extends TestCase
                 ->setConstructorArgs(['name' => 'other_source'])
                 ->getMock();
         ConnectionManager::setConfig('other_source', $mock);
-        $this->article->connection(ConnectionManager::get('other_source'));
+        $this->article->setConnection(ConnectionManager::get('other_source'));
 
         $assoc = new BelongsToMany('Test', [
             'sourceTable' => $this->article,
@@ -277,8 +277,8 @@ class BelongsToManyTest extends TestCase
             'joinTable' => 'tags_articles'
         ]);
         $junction = $assoc->junction();
-        $this->assertEquals('TagsArticles', $junction->alias());
-        $this->assertEquals('tags_articles', $junction->table());
+        $this->assertEquals('TagsArticles', $junction->getAlias());
+        $this->assertEquals('tags_articles', $junction->getTable());
     }
 
     /**
@@ -357,7 +357,7 @@ class BelongsToManyTest extends TestCase
         $association = new BelongsToMany('Tags', $config);
         $association->junction($articleTag);
         $this->article
-            ->getAssociation($articleTag->alias())
+            ->getAssociation($articleTag->getAlias())
             ->setConditions(['click_count' => 3]);
 
         $articleTag->expects($this->once())
@@ -390,7 +390,7 @@ class BelongsToManyTest extends TestCase
         $association = new BelongsToMany('Tags', $config);
         $association->junction($articleTag);
         $this->article
-            ->getAssociation($articleTag->alias())
+            ->getAssociation($articleTag->getAlias())
             ->setConditions(['click_count' => 3]);
 
         $articleTag->expects($this->never())
@@ -417,7 +417,7 @@ class BelongsToManyTest extends TestCase
         ];
         $association = new BelongsToMany('Tag', $config);
         $association->junction($articleTag);
-        $this->article->getAssociation($articleTag->alias());
+        $this->article->getAssociation($articleTag->getAlias());
 
         $counter = $this->getMockBuilder('StdClass')
             ->setMethods(['__invoke'])
@@ -909,7 +909,7 @@ class BelongsToManyTest extends TestCase
         $table = $this->getMockBuilder('Cake\ORM\Table')
             ->setMethods(['table'])
             ->getMock();
-        $table->schema([]);
+        $table->setSchema([]);
         $assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany')
             ->setMethods(['_saveTarget', 'replaceLinks'])
             ->setConstructorArgs(['tags', ['sourceTable' => $table]])
@@ -938,7 +938,7 @@ class BelongsToManyTest extends TestCase
         $table = $this->getMockBuilder('Cake\ORM\Table')
             ->setMethods(['table'])
             ->getMock();
-        $table->schema([]);
+        $table->setSchema([]);
         $assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany')
             ->setMethods(['_saveTarget', 'replaceLinks'])
             ->setConstructorArgs(['tags', ['sourceTable' => $table]])
@@ -970,7 +970,7 @@ class BelongsToManyTest extends TestCase
         $table = $this->getMockBuilder('Cake\ORM\Table')
             ->setMethods(['table'])
             ->getMock();
-        $table->schema([]);
+        $table->setSchema([]);
         $assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany')
             ->setMethods(['replaceLinks'])
             ->setConstructorArgs(['tags', ['sourceTable' => $table]])
@@ -1000,7 +1000,7 @@ class BelongsToManyTest extends TestCase
         $table = $this->getMockBuilder('Cake\ORM\Table')
             ->setMethods(['table'])
             ->getMock();
-        $table->schema([]);
+        $table->setSchema([]);
         $assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany')
             ->setMethods(['replaceLinks'])
             ->setConstructorArgs(['tags', ['sourceTable' => $table]])
@@ -1032,7 +1032,7 @@ class BelongsToManyTest extends TestCase
             ->setMethods(['saveAssociated', 'schema'])
             ->setConstructorArgs([['table' => 'tags', 'connection' => $connection]])
             ->getMock();
-        $mock->primaryKey('id');
+        $mock->setPrimaryKey('id');
 
         $config = [
             'sourceTable' => $this->article,
@@ -1214,7 +1214,7 @@ class BelongsToManyTest extends TestCase
         $this->expectExceptionMessage('The "tags" table does not define a primary key');
         $table = TableRegistry::get('Articles');
         $tags = TableRegistry::get('Tags');
-        $tags->schema()->dropConstraint('primary');
+        $tags->getSchema()->dropConstraint('primary');
 
         $table->belongsToMany('Tags');
         $table->find()->contain('Tags')->first();

+ 4 - 4
tests/TestCase/ORM/Association/BelongsToTest.php

@@ -125,8 +125,8 @@ class BelongsToTest extends TestCase
      */
     public function testForeignKeyIgnoreDatabaseName()
     {
-        $this->company->table('schema.companies');
-        $this->client->table('schema.clients');
+        $this->company->setTable('schema.companies');
+        $this->client->setTable('schema.clients');
         $assoc = new BelongsTo('Companies', [
             'sourceTable' => $this->client,
             'targetTable' => $this->company,
@@ -237,7 +237,7 @@ class BelongsToTest extends TestCase
      */
     public function testAttachToMultiPrimaryKey()
     {
-        $this->company->primaryKey(['id', 'tenant_id']);
+        $this->company->setPrimaryKey(['id', 'tenant_id']);
         $config = [
             'foreignKey' => ['company_id', 'company_tenant_id'],
             'sourceTable' => $this->client,
@@ -280,7 +280,7 @@ class BelongsToTest extends TestCase
     {
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionMessage('Cannot match provided foreignKey for "Companies", got "(company_id)" but expected foreign key for "(id, tenant_id)"');
-        $this->company->primaryKey(['id', 'tenant_id']);
+        $this->company->setPrimaryKey(['id', 'tenant_id']);
         $query = $this->client->query();
         $config = [
             'foreignKey' => 'company_id',

+ 7 - 4
tests/TestCase/ORM/Association/HasManyTest.php

@@ -60,7 +60,7 @@ class HasManyTest extends TestCase
             ->setMethods(['find', 'deleteAll', 'delete'])
             ->setConstructorArgs([['alias' => 'Articles', 'table' => 'articles', 'connection' => $connection]])
             ->getMock();
-        $this->article->schema([
+        $this->article->setSchema([
             'id' => ['type' => 'integer'],
             'title' => ['type' => 'string'],
             'author_id' => ['type' => 'integer'],
@@ -134,7 +134,7 @@ class HasManyTest extends TestCase
      */
     public function testForeignKeyIgnoreDatabaseName()
     {
-        $this->author->table('schema.authors');
+        $this->author->setTable('schema.authors');
         $assoc = new HasMany('Articles', [
             'sourceTable' => $this->author
         ]);
@@ -432,7 +432,7 @@ class HasManyTest extends TestCase
             'foreignKey' => ['author_id', 'site_id']
         ];
 
-        $this->author->primaryKey(['id', 'site_id']);
+        $this->author->setPrimaryKey(['id', 'site_id']);
         $association = new HasMany('Articles', $config);
         $keys = [[1, 10], [2, 20], [3, 30], [4, 40]];
         $query = $this->getMockBuilder('Cake\ORM\Query')
@@ -763,7 +763,10 @@ class HasManyTest extends TestCase
 
         // Ensure that after each model is saved, we are still within a transaction.
         $listenerAfterSave = function ($e, $entity, $options) use ($articles) {
-            $this->assertTrue($articles->connection()->inTransaction(), 'Multiple transactions used to save associated models.');
+            $this->assertTrue(
+                $articles->getConnection()->inTransaction(),
+                'Multiple transactions used to save associated models.'
+            );
         };
         $articles->getEventManager()->on('Model.afterSave', $listenerAfterSave);
 

+ 2 - 2
tests/TestCase/ORM/Association/HasOneTest.php

@@ -182,7 +182,7 @@ class HasOneTest extends TestCase
             'foreignKey' => ['user_id', 'user_site_id']
         ];
 
-        $this->user->primaryKey(['id', 'site_id']);
+        $this->user->setPrimaryKey(['id', 'site_id']);
         $association = new HasOne('Profiles', $config);
 
         $query = $this->getMockBuilder('\Cake\ORM\Query')
@@ -224,7 +224,7 @@ class HasOneTest extends TestCase
             'targetTable' => $this->profile,
             'conditions' => ['Profiles.is_active' => true],
         ];
-        $this->user->primaryKey(['id', 'site_id']);
+        $this->user->setPrimaryKey(['id', 'site_id']);
         $association = new HasOne('Profiles', $config);
         $association->attachTo($query, ['includeFields' => false]);
     }

+ 168 - 50
tests/TestCase/ORM/TableTest.php

@@ -138,51 +138,80 @@ class TableTest extends TestCase
     public function testTableMethod()
     {
         $table = new Table(['table' => 'users']);
-        $this->assertEquals('users', $table->table());
+        $this->assertEquals('users', $table->getTable());
 
         $table = new UsersTable;
-        $this->assertEquals('users', $table->table());
+        $this->assertEquals('users', $table->getTable());
 
         $table = $this->getMockBuilder('\Cake\ORM\Table')
             ->setMethods(['find'])
             ->setMockClassName('SpecialThingsTable')
             ->getMock();
-        $this->assertEquals('special_things', $table->table());
+        $this->assertEquals('special_things', $table->getTable());
 
         $table = new Table(['alias' => 'LoveBoats']);
-        $this->assertEquals('love_boats', $table->table());
+        $this->assertEquals('love_boats', $table->getTable());
 
-        $table->table('other');
-        $this->assertEquals('other', $table->table());
+        $table->setTable('other');
+        $this->assertEquals('other', $table->getTable());
 
-        $table->table('database.other');
-        $this->assertEquals('database.other', $table->table());
+        $table->setTable('database.other');
+        $this->assertEquals('database.other', $table->getTable());
     }
 
     /**
      * Tests the alias method
      *
+     * @group deprecated
      * @return void
      */
     public function testAliasMethod()
     {
+        $this->deprecated(function () {
+            $table = new Table(['alias' => 'users']);
+            $this->assertEquals('users', $table->alias());
+
+            $table = new Table(['table' => 'stuffs']);
+            $this->assertEquals('stuffs', $table->alias());
+
+            $table = new UsersTable;
+            $this->assertEquals('Users', $table->alias());
+
+            $table = $this->getMockBuilder('\Cake\ORM\Table')
+                ->setMethods(['find'])
+                ->setMockClassName('SpecialThingTable')
+                ->getMock();
+            $this->assertEquals('SpecialThing', $table->alias());
+
+            $table->alias('AnotherOne');
+            $this->assertEquals('AnotherOne', $table->alias());
+        });
+    }
+
+    /**
+     * Tests the setAlias method
+     *
+     * @return void
+     */
+    public function testSetAlias()
+    {
         $table = new Table(['alias' => 'users']);
-        $this->assertEquals('users', $table->alias());
+        $this->assertEquals('users', $table->getAlias());
 
         $table = new Table(['table' => 'stuffs']);
-        $this->assertEquals('stuffs', $table->alias());
+        $this->assertEquals('stuffs', $table->getAlias());
 
         $table = new UsersTable;
-        $this->assertEquals('Users', $table->alias());
+        $this->assertEquals('Users', $table->getAlias());
 
         $table = $this->getMockBuilder('\Cake\ORM\Table')
             ->setMethods(['find'])
             ->setMockClassName('SpecialThingTable')
             ->getMock();
-        $this->assertEquals('SpecialThing', $table->alias());
+        $this->assertEquals('SpecialThing', $table->getAlias());
 
-        $table->alias('AnotherOne');
-        $this->assertEquals('AnotherOne', $table->alias());
+        $table->setAlias('AnotherOne');
+        $this->assertEquals('AnotherOne', $table->getAlias());
     }
 
     /**
@@ -201,23 +230,64 @@ class TableTest extends TestCase
     /**
      * Tests connection method
      *
+     * @group deprecated
      * @return void
      */
     public function testConnection()
     {
+        $this->deprecated(function () {
+            $table = new Table(['table' => 'users']);
+            $this->assertNull($table->connection());
+            $table->connection($this->connection);
+            $this->assertSame($this->connection, $table->connection());
+        });
+    }
+
+    /**
+     * Tests setConnection method
+     *
+     * @return void
+     */
+    public function testSetConnection()
+    {
         $table = new Table(['table' => 'users']);
-        $this->assertNull($table->connection());
-        $table->connection($this->connection);
-        $this->assertSame($this->connection, $table->connection());
+        $this->assertNull($table->getConnection());
+        $this->assertSame($table, $table->setConnection($this->connection));
+        $this->assertSame($this->connection, $table->getConnection());
     }
 
     /**
      * Tests primaryKey method
      *
+     * @group deprecated
      * @return void
      */
     public function testPrimaryKey()
     {
+        $this->deprecated(function () {
+            $table = new Table([
+                'table' => 'users',
+                'schema' => [
+                    'id' => ['type' => 'integer'],
+                    '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
+                ]
+            ]);
+            $this->assertEquals('id', $table->primaryKey());
+            $table->primaryKey('thingID');
+            $this->assertEquals('thingID', $table->primaryKey());
+
+            $table->primaryKey(['thingID', 'user_id']);
+            $this->assertEquals(['thingID', 'user_id'], $table->primaryKey());
+        });
+    }
+
+    /**
+     * Tests primaryKey method
+     *
+     * @return void
+     */
+    public function testSetPrimaryKey()
+    {
         $table = new Table([
             'table' => 'users',
             'schema' => [
@@ -225,12 +295,12 @@ class TableTest extends TestCase
                 '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
             ]
         ]);
-        $this->assertEquals('id', $table->primaryKey());
-        $table->primaryKey('thingID');
-        $this->assertEquals('thingID', $table->primaryKey());
+        $this->assertEquals('id', $table->getPrimaryKey());
+        $this->assertSame($table, $table->setPrimaryKey('thingID'));
+        $this->assertEquals('thingID', $table->getPrimaryKey());
 
-        $table->primaryKey(['thingID', 'user_id']);
-        $this->assertEquals(['thingID', 'user_id'], $table->primaryKey());
+        $table->setPrimaryKey(['thingID', 'user_id']);
+        $this->assertEquals(['thingID', 'user_id'], $table->getPrimaryKey());
     }
 
     /**
@@ -247,7 +317,7 @@ class TableTest extends TestCase
                 'name' => ['type' => 'string']
             ]
         ]);
-        $this->assertEquals('name', $table->displayField());
+        $this->assertEquals('name', $table->getDisplayField());
     }
 
     /**
@@ -264,7 +334,7 @@ class TableTest extends TestCase
                 'title' => ['type' => 'string']
             ]
         ]);
-        $this->assertEquals('title', $table->displayField());
+        $this->assertEquals('title', $table->getDisplayField());
     }
 
     /**
@@ -282,7 +352,7 @@ class TableTest extends TestCase
                 '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
             ]
         ]);
-        $this->assertEquals('id', $table->displayField());
+        $this->assertEquals('id', $table->getDisplayField());
     }
 
     /**
@@ -300,35 +370,65 @@ class TableTest extends TestCase
                 '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
             ]
         ]);
-        $this->assertEquals('id', $table->displayField());
-        $table->displayField('foo');
-        $this->assertEquals('foo', $table->displayField());
+        $this->assertEquals('id', $table->getDisplayField());
+        $table->setDisplayField('foo');
+        $this->assertEquals('foo', $table->getDisplayField());
     }
 
     /**
      * Tests schema method
      *
+     * @group deprecated
      * @return void
      */
     public function testSchema()
     {
+        $this->deprecated(function () {
+            $schema = $this->connection->getSchemaCollection()->describe('users');
+            $table = new Table([
+                'table' => 'users',
+                'connection' => $this->connection,
+            ]);
+            $this->assertEquals($schema, $table->schema());
+
+            $table = new Table(['table' => 'stuff']);
+            $table->schema($schema);
+            $this->assertSame($schema, $table->schema());
+
+            $table = new Table(['table' => 'another']);
+            $schema = ['id' => ['type' => 'integer']];
+            $table->schema($schema);
+            $this->assertEquals(
+                new TableSchema('another', $schema),
+                $table->schema()
+            );
+        });
+    }
+
+    /**
+     * Tests schema method
+     *
+     * @return void
+     */
+    public function testSetSchema()
+    {
         $schema = $this->connection->getSchemaCollection()->describe('users');
         $table = new Table([
             'table' => 'users',
             'connection' => $this->connection,
         ]);
-        $this->assertEquals($schema, $table->schema());
+        $this->assertEquals($schema, $table->getSchema());
 
         $table = new Table(['table' => 'stuff']);
-        $table->schema($schema);
-        $this->assertSame($schema, $table->schema());
+        $table->setSchema($schema);
+        $this->assertSame($schema, $table->getSchema());
 
         $table = new Table(['table' => 'another']);
         $schema = ['id' => ['type' => 'integer']];
-        $table->schema($schema);
+        $table->setSchema($schema);
         $this->assertEquals(
             new TableSchema('another', $schema),
-            $table->schema()
+            $table->getSchema()
         );
     }
 
@@ -352,10 +452,10 @@ class TableTest extends TestCase
 
                 return $schema;
             }));
-        $result = $table->schema();
+        $result = $table->getSchema();
         $schema->setColumnType('username', 'integer');
         $this->assertEquals($schema, $result);
-        $this->assertEquals($schema, $table->schema(), '_initializeSchema should be called once');
+        $this->assertEquals($schema, $table->getSchema(), '_initializeSchema should be called once');
     }
 
     /**
@@ -1035,7 +1135,7 @@ class TableTest extends TestCase
             'table' => 'users',
             'connection' => $this->connection,
         ]);
-        $table->displayField('username');
+        $table->setDisplayField('username');
         $query = $table->find('list')
             ->enableHydration(false)
             ->order('id');
@@ -1218,7 +1318,7 @@ class TableTest extends TestCase
             'table' => 'users',
             'connection' => $this->connection,
         ]);
-        $table->displayField('username');
+        $table->setDisplayField('username');
         $query = $table
             ->find('list', ['fields' => ['id', 'username']])
             ->order('id');
@@ -1258,7 +1358,7 @@ class TableTest extends TestCase
             'table' => 'users',
             'connection' => $this->connection,
         ]);
-        $table->displayField('username');
+        $table->setDisplayField('username');
 
         $query = $table->find('list');
         $expected = ['id', 'username'];
@@ -1310,7 +1410,7 @@ class TableTest extends TestCase
             'connection' => $this->connection,
             'entityClass' => '\TestApp\Model\Entity\VirtualUser'
         ]);
-        $table->displayField('bonus');
+        $table->setDisplayField('bonus');
 
         $query = $table
             ->find('list')
@@ -1363,7 +1463,7 @@ class TableTest extends TestCase
     public function testEntityClassDefault()
     {
         $table = new Table();
-        $this->assertEquals('\Cake\ORM\Entity', $table->entityClass());
+        $this->assertEquals('\Cake\ORM\Entity', $table->getEntityClass());
     }
 
     /**
@@ -1381,7 +1481,8 @@ class TableTest extends TestCase
         }
 
         $table = new Table();
-        $this->assertEquals('TestApp\Model\Entity\TestUser', $table->entityClass('TestUser'));
+        $this->assertSame($table, $table->setEntityClass('TestUser'));
+        $this->assertEquals('TestApp\Model\Entity\TestUser', $table->getEntityClass());
     }
 
     /**
@@ -1399,9 +1500,10 @@ class TableTest extends TestCase
         }
 
         $table = new Table();
+        $this->assertSame($table, $table->setEntityClass('MyPlugin.SuperUser'));
         $this->assertEquals(
             'MyPlugin\Model\Entity\SuperUser',
-            $table->entityClass('MyPlugin.SuperUser')
+            $table->getEntityClass()
         );
     }
 
@@ -1416,7 +1518,7 @@ class TableTest extends TestCase
         $this->expectException(\Cake\ORM\Exception\MissingEntityException::class);
         $this->expectExceptionMessage('Entity class FooUser could not be found.');
         $table = new Table;
-        $this->assertFalse($table->entityClass('FooUser'));
+        $table->setEntityClass('FooUser');
     }
 
     /**
@@ -1428,7 +1530,23 @@ class TableTest extends TestCase
     public function testTableClassConventionForAPP()
     {
         $table = new \TestApp\Model\Table\ArticlesTable;
-        $this->assertEquals('TestApp\Model\Entity\Article', $table->entityClass());
+        $this->assertEquals('TestApp\Model\Entity\Article', $table->getEntityClass());
+    }
+
+    /**
+     * Tests setting a entity class object using the setter method
+     *
+     * @group deprecated
+     * @return void
+     */
+    public function testEntityClass()
+    {
+        $this->deprecated(function () {
+            $table = new Table;
+            $class = '\\' . $this->getMockClass('\Cake\ORM\Entity');
+            $table->entityClass($class);
+            $this->assertEquals($class, $table->getEntityClass());
+        });
     }
 
     /**
@@ -1440,8 +1558,8 @@ class TableTest extends TestCase
     {
         $table = new Table;
         $class = '\\' . $this->getMockClass('\Cake\ORM\Entity');
-        $table->entityClass($class);
-        $this->assertEquals($class, $table->entityClass());
+        $this->assertSame($table, $table->setEntityClass($class));
+        $this->assertEquals($class, $table->getEntityClass());
     }
 
     /**
@@ -5502,7 +5620,7 @@ class TableTest extends TestCase
             ->will($this->returnValue($query));
 
         $query->expects($this->once())->method('where')
-            ->with([$table->alias() . '.bar' => 10])
+            ->with([$table->getAlias() . '.bar' => 10])
             ->will($this->returnSelf());
         $query->expects($this->never())->method('cache');
         $query->expects($this->once())->method('firstOrFail')
@@ -5552,7 +5670,7 @@ class TableTest extends TestCase
             ->will($this->returnValue($query));
 
         $query->expects($this->once())->method('where')
-            ->with([$table->alias() . '.bar' => 10])
+            ->with([$table->getAlias() . '.bar' => 10])
             ->will($this->returnSelf());
         $query->expects($this->never())->method('cache');
         $query->expects($this->once())->method('firstOrFail')
@@ -5597,7 +5715,7 @@ class TableTest extends TestCase
                 ]
             ]])
             ->getMock();
-        $table->table('table_name');
+        $table->setTable('table_name');
 
         $query = $this->getMockBuilder('\Cake\ORM\Query')
             ->setMethods(['addDefaultTypes', 'firstOrFail', 'where', 'cache'])
@@ -5612,7 +5730,7 @@ class TableTest extends TestCase
             ->will($this->returnValue($query));
 
         $query->expects($this->once())->method('where')
-            ->with([$table->alias() . '.bar' => 10])
+            ->with([$table->getAlias() . '.bar' => 10])
             ->will($this->returnSelf());
         $query->expects($this->once())->method('cache')
             ->with($cacheKey, $cacheConfig)