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());
 }
Esempio n. 2
0
 private function incrementCounter(int $tryCounter, UniqueValue $value, int $limit) : int
 {
     ++$tryCounter;
     if ($tryCounter > $limit) {
         throw UniqueValueGenerationLimitReachedExceptionFactory::create($value, $limit);
     }
     return $tryCounter;
 }