|
|
@@ -1312,7 +1312,10 @@ class QueryTest extends TestCase
|
|
|
->eventManager()
|
|
|
->attach(function ($event, $query) {
|
|
|
$query->formatResults(function ($results) {
|
|
|
- $results->beforeFind = true;
|
|
|
+ foreach ($results as $result) {
|
|
|
+ $result->beforeFind = true;
|
|
|
+ }
|
|
|
+
|
|
|
return $results;
|
|
|
});
|
|
|
}, 'Model.beforeFind');
|
|
|
@@ -1333,10 +1336,13 @@ class QueryTest extends TestCase
|
|
|
$expected = [
|
|
|
'id' => 1,
|
|
|
'name' => 'tag1',
|
|
|
- '_joinData' => ['article_id' => 1, 'tag_id' => 1],
|
|
|
+ '_joinData' => [
|
|
|
+ 'article_id' => 1,
|
|
|
+ 'tag_id' => 1,
|
|
|
+ 'beforeFind' => true,
|
|
|
+ ],
|
|
|
'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);
|
|
|
@@ -1344,10 +1350,13 @@ class QueryTest extends TestCase
|
|
|
$expected = [
|
|
|
'id' => 2,
|
|
|
'name' => 'tag2',
|
|
|
- '_joinData' => ['article_id' => 1, 'tag_id' => 2],
|
|
|
+ '_joinData' => [
|
|
|
+ 'article_id' => 1,
|
|
|
+ 'tag_id' => 2,
|
|
|
+ 'beforeFind' => true,
|
|
|
+ ],
|
|
|
'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);
|