UuidBuilderTest.php 910 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. declare(strict_types=1);
  3. namespace Ramsey\Uuid\Test\Nonstandard;
  4. use Mockery;
  5. use Ramsey\Uuid\Codec\CodecInterface;
  6. use Ramsey\Uuid\Exception\UnableToBuildUuidException;
  7. use Ramsey\Uuid\Nonstandard\UuidBuilder;
  8. use Ramsey\Uuid\Test\TestCase;
  9. use RuntimeException;
  10. class UuidBuilderTest extends TestCase
  11. {
  12. public function testBuildThrowsException(): void
  13. {
  14. $codec = Mockery::mock(CodecInterface::class);
  15. $builder = Mockery::mock(UuidBuilder::class);
  16. $builder->shouldAllowMockingProtectedMethods();
  17. $builder->shouldReceive('buildFields')->andThrow(
  18. RuntimeException::class,
  19. 'exception thrown'
  20. );
  21. $builder->shouldReceive('build')->passthru();
  22. $this->expectException(UnableToBuildUuidException::class);
  23. $this->expectExceptionMessage('exception thrown');
  24. $builder->build($codec, 'foobar');
  25. }
  26. }