Skip to content

Commit

Permalink
Moving test case to another file
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Dec 31, 2015
1 parent 2e5e830 commit c003498
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
22 changes: 22 additions & 0 deletions tests/TestCase/ORM/Association/BelongsToManyTest.php
Expand Up @@ -913,4 +913,26 @@ public function testPropertyNoPlugin()
$association = new BelongsToMany('Contacts.Tags', $config);
$this->assertEquals('tags', $association->property());
}

/**
* Tests that fetching belongsToMany association will not force
* all fields being returned, but intead will honor the select() clause
*
* @see https://github.com/cakephp/cakephp/issues/7916
* @return void
*/
public function testEagerLoadingBelongsToManyLimitedFields()
{
$table = TableRegistry::get('Articles');
$table->belongsToMany('Tags');
$result = $table
->find()
->contain(['Tags' => function ($q) {
return $q->select(['id']);
}])
->first();

$this->assertNotEmpty($result->tags[0]->id);
$this->assertEmpty($result->tags[0]->name);
}
}
22 changes: 0 additions & 22 deletions tests/TestCase/ORM/QueryRegressionTest.php
Expand Up @@ -1236,26 +1236,4 @@ public function testCountWithComplexOrderBy()
// Not executing the query first, just getting the count
$this->assertEquals(3, $query->count());
}

/**
* Tests that fetching belongsToMany association will not force
* all fields being returned, but intead will honor the select() clause
*
* @see https://github.com/cakephp/cakephp/issues/7913
* @return void
*/
public function testEagerLoadingBelongsToManyLimitedFields()
{
$table = TableRegistry::get('Articles');
$table->belongsToMany('Tags');
$result = $table
->find()
->contain(['Tags' => function ($q) {
return $q->select(['id']);
}])
->first();

$this->assertNotEmpty($result->tags[0]->id);
$this->assertEmpty($result->tags[0]->name);
}
}

0 comments on commit c003498

Please sign in to comment.