public function testRelatedCategoriesScope() { $entryId = 7; $entry = Title::entryId($entryId)->get()->first(); $expected = []; foreach ($entry->categories as $category) { $expected[] = $category->cat_id; } $this->assertThat(Title::relatedCategories($entryId)->get(), new CollectionNestedCollectionPropertyHasOneValueConstraint($expected, 'categories', 'cat_id')); }