/** * @test */ function it_creates_a_new_nested_model_related_as_belongs_to() { $post = $this->createPost(); $data = ['title' => 'updated aswell', 'genre' => ['name' => 'New Genre']]; $updater = new ModelUpdater(Post::class); $updater->update($data, $post); $this->seeInDatabase('posts', ['id' => $post->id, 'title' => 'updated aswell']); $post = Post::find($post->id); $this->assertEquals(1, $post->genre_id, "New Genre should be associated with Post"); $this->seeInDatabase('genres', ['name' => 'New Genre']); }