/**
  * @test
  */
 function it_creates_deeply_nested_structure_of_all_new_models()
 {
     // allow creating authors through posts
     $this->app['config']->set('nestedmodelupdater.relations.' . Post::class . '.authors', ['link-only' => false]);
     $data = ['title' => 'new title', 'body' => 'new body', 'genre' => ['name' => 'new genre'], 'comments' => [['title' => 'title 1', 'body' => 'body 1', 'author' => ['name' => 'Author B']], ['title' => 'title 2', 'body' => 'body 2', 'author' => ['name' => 'Author C']]], 'authors' => [['name' => 'Author A', 'gender' => 'f']]];
     $updater = new ModelUpdater(Post::class);
     $updater->create($data);
     // check the whole structure
     $post = Post::latest()->first();
     $this->assertInstanceOf(Post::class, $post);
     $genre = Genre::latest()->first();
     $this->assertInstanceOf(Genre::class, $genre);
     $commentAuthorB = Author::where('name', 'Author B')->first();
     $this->assertInstanceOf(Author::class, $commentAuthorB);
     $commentAuthorC = Author::where('name', 'Author C')->first();
     $this->assertInstanceOf(Author::class, $commentAuthorC);
     $this->seeInDatabase('posts', ['id' => $post->id, 'title' => 'new title', 'body' => 'new body', 'genre_id' => $genre->id]);
     $this->seeInDatabase('genres', ['id' => $genre->id, 'name' => 'new genre']);
     $this->seeInDatabase('comments', ['title' => 'title 1', 'body' => 'body 1', 'author_id' => $commentAuthorB->id]);
     $this->seeInDatabase('comments', ['title' => 'title 2', 'body' => 'body 2', 'author_id' => $commentAuthorC->id]);
     $this->seeInDatabase('authors', ['name' => 'Author A']);
 }