/** * @param HHPnet\Core\Domain\Albums\Album $album * @param MongoDB\UpdateResult $upsert_result */ public function it_fails_when_was_not_possible_to_save_album(Album $album, \MongoDB\UpdateResult $upsert_result) { $upsert_result->getUpsertedCount()->willReturn(0); $this->collection->updateOne(Argument::any(), Argument::any(), Argument::any())->willReturn($upsert_result); $album->getIterator()->willReturn(new \ArrayIterator(['id' => 1, 'group_id' => 1, 'name' => 'name_test', 'description' => 'description_test', 'release_year' => 2001])); $this->shouldThrow('\\DomainException')->during('save', array($album)); }