Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Showing that formatResults on belongsToMany doesn't work
  • Loading branch information
jeremyharris committed Oct 20, 2016
1 parent aca66f9 commit 02f5af9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -1312,6 +1312,7 @@ public function testFormatResultsBelongsToMany()
->eventManager()
->attach(function ($event, $query) {
$query->formatResults(function ($results) {
$results->beforeFind = true;
return $results;
});
}, 'Model.beforeFind');
Expand All @@ -1335,6 +1336,7 @@ public function testFormatResultsBelongsToMany()
'_joinData' => ['article_id' => 1, 'tag_id' => 1],
'description' => 'A big description',
'created' => new Time('2016-01-01 00:00'),
'beforeFind' => true,
];
$this->assertEquals($expected, $first->tags[0]->toArray());
$this->assertInstanceOf(Time::class, $first->tags[0]->created);
Expand All @@ -1345,6 +1347,7 @@ public function testFormatResultsBelongsToMany()
'_joinData' => ['article_id' => 1, 'tag_id' => 2],
'description' => 'Another big description',
'created' => new Time('2016-01-01 00:00'),
'beforeFind' => true,
];
$this->assertEquals($expected, $first->tags[1]->toArray());
$this->assertInstanceOf(Time::class, $first->tags[0]->created);
Expand Down

0 comments on commit 02f5af9

Please sign in to comment.