/** * @param \Dvs\UUIDGenerator\Interfaces\UUIDGenerator $uuidGenerator * @param \Dvs\FileBundle\Storage\Resource\Storageable $storageable */ public function it_should_throw_an_exception_if_name_can_not_be_generated($uuidGenerator, $storageable) { //given $uuidGenerator->generateUnique()->willThrow(new UUIDGeneratorException('Message')); //then $this->shouldThrow(NameGenerationException::notGenerated())->during('generate', [$storageable]); }
/** * @param Storageable $storageable * @return string */ public function generate(Storageable $storageable) : string { try { return $this->uuidGenerator->generateUnique(); } catch (UUIDGeneratorException $e) { throw NameGenerationException::notGenerated(); } }