Skip to content

Commit c003498

Browse files
committed
Moving test case to another file
1 parent 2e5e830 commit c003498

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

tests/TestCase/ORM/Association/BelongsToManyTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,4 +913,26 @@ public function testPropertyNoPlugin()
913913
$association = new BelongsToMany('Contacts.Tags', $config);
914914
$this->assertEquals('tags', $association->property());
915915
}
916+
917+
/**
918+
* Tests that fetching belongsToMany association will not force
919+
* all fields being returned, but intead will honor the select() clause
920+
*
921+
* @see https://github.com/cakephp/cakephp/issues/7916
922+
* @return void
923+
*/
924+
public function testEagerLoadingBelongsToManyLimitedFields()
925+
{
926+
$table = TableRegistry::get('Articles');
927+
$table->belongsToMany('Tags');
928+
$result = $table
929+
->find()
930+
->contain(['Tags' => function ($q) {
931+
return $q->select(['id']);
932+
}])
933+
->first();
934+
935+
$this->assertNotEmpty($result->tags[0]->id);
936+
$this->assertEmpty($result->tags[0]->name);
937+
}
916938
}

tests/TestCase/ORM/QueryRegressionTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,26 +1236,4 @@ public function testCountWithComplexOrderBy()
12361236
// Not executing the query first, just getting the count
12371237
$this->assertEquals(3, $query->count());
12381238
}
1239-
1240-
/**
1241-
* Tests that fetching belongsToMany association will not force
1242-
* all fields being returned, but intead will honor the select() clause
1243-
*
1244-
* @see https://github.com/cakephp/cakephp/issues/7913
1245-
* @return void
1246-
*/
1247-
public function testEagerLoadingBelongsToManyLimitedFields()
1248-
{
1249-
$table = TableRegistry::get('Articles');
1250-
$table->belongsToMany('Tags');
1251-
$result = $table
1252-
->find()
1253-
->contain(['Tags' => function ($q) {
1254-
return $q->select(['id']);
1255-
}])
1256-
->first();
1257-
1258-
$this->assertNotEmpty($result->tags[0]->id);
1259-
$this->assertEmpty($result->tags[0]->name);
1260-
}
12611239
}

0 commit comments

Comments
 (0)