protected function populateDatabase()
 {
     $country = new Models\Country(['name' => 'United Kingdom']);
     $country->save();
     $city = new Models\City(['name' => 'Newcastle', 'country_id' => 1]);
     $city->save();
     $book = new Models\Book(['name' => 'Book 1']);
     $this->createAuthor($book, $city);
     $this->createEditor();
     $this->createCategory();
 }
 public function test_does_add_required_fields_for_has_many_through_relation()
 {
     $this->populateDatabase();
     $model = new Models\Country();
     $query = $model->query()->with('authors');
     $modifier = $this->_getInstance($query, ['fields' => 'name']);
     $modifier->modify($query);
     $reqFields = $modifier->addRequiredFields(['name']);
     $this->assertEquals(2, count($reqFields));
     $this->assertContains('id', $reqFields);
     $this->assertContains('name', $reqFields);
     $this->assertEquals(1, count($query->find(1)->authors));
 }