public function testTestCreateNewExceptionWithFactory()
 {
     $exception = UniqueValueGenerationLimitReachedExceptionFactory::create(new UniqueValue('unique_id', new \stdClass()), 10);
     $this->assertEquals('Could not generate a unique value after 10 attempts for "unique_id".', $exception->getMessage());
     $this->assertEquals(0, $exception->getCode());
     $this->assertNull($exception->getPrevious());
 }
コード例 #2
0
ファイル: UniqueValueResolver.php プロジェクト: nelmio/alice
 private function incrementCounter(int $tryCounter, UniqueValue $value, int $limit) : int
 {
     ++$tryCounter;
     if ($tryCounter > $limit) {
         throw UniqueValueGenerationLimitReachedExceptionFactory::create($value, $limit);
     }
     return $tryCounter;
 }