@@ -220,45 +220,20 @@ public function __invoke(Builder $query, $descending, string $property): Builder
220220 $ this ->assertEquals ($ usingSortFirst , $ usingFilterFirst );
221221 }
222222
223- /** @test */
224- public function it_can_get_a_query_from_a_relationship ()
225- {
226- $ this ->markTestIncomplete ('This test proves that there \'s something wrong with Eloquent \'s getQuery() ' );
227-
228- $ testModel = TestModel::create (['id ' => 321 , 'name ' => 'John Doe ' ]);
229- $ relatedThroughPivotModel = RelatedThroughPivotModel::create (['id ' => 789 , 'name ' => 'The related model ' ]);
230-
231- $ testModel ->relatedThroughPivotModels ()->attach ($ relatedThroughPivotModel );
232-
233- // Passes
234- $ this ->assertEquals (
235- $ relatedThroughPivotModel ->id ,
236- $ testModel ->relatedThroughPivotModels ()->first ()->id
237- );
238-
239- // Fails
240- $ this ->assertEquals (
241- $ relatedThroughPivotModel ->id ,
242- $ testModel ->relatedThroughPivotModels ()->getQuery ()->first ()->id
243- );
244- }
245-
246223 /** @test */
247224 public function it_queries_the_correct_data_for_a_relationship_query ()
248225 {
249- $ this ->markTestIncomplete ('Currently broken due to Eloquent. See the above test. ' );
250-
251226 $ testModel = TestModel::create (['id ' => 321 , 'name ' => 'John Doe ' ]);
252227 $ relatedThroughPivotModel = RelatedThroughPivotModel::create (['id ' => 789 , 'name ' => 'The related model ' ]);
253228
254229 $ testModel ->relatedThroughPivotModels ()->attach ($ relatedThroughPivotModel );
255230
256- $ baseQuery = $ testModel ->relatedThroughPivotModels ()->getQuery ( );
231+ $ relationship = $ testModel ->relatedThroughPivotModels ()->with ( ' testModels ' );
257232
258- $ queryBuilderResult = QueryBuilder::for ($ baseQuery )->first ();
233+ $ queryBuilderResult = QueryBuilder::for ($ relationship )->first ();
259234
260235 $ this ->assertEquals (789 , $ queryBuilderResult ->id );
261- $ this ->assertEquals (123 , $ queryBuilderResult ->testModel ->id );
236+ $ this ->assertEquals (321 , $ queryBuilderResult ->testModels -> first () ->id );
262237 }
263238
264239 /** @test */
0 commit comments