Files
php-uuid/tests/Nonstandard/UuidBuilderTest.php
T
Brandon Morrison aa18ce15d5 Fix pure annotations (#605)
Coming from https://github.com/ramsey/uuid/pull/603, this is an attempt
to fix the errors raised by the current phpstan settings.

I went through each of the errors raised by phpstan with the following
approach.

- If a method is part of an `@immutable` class, we can consider it pure,
  assuming it only affects internal variables.
- If a potentially pure method is calling a class's method that is only
  swapped during testing (and not during normal usage), then we can
  consider the calling method pure.
- If a class is marked deprecated, don't bother with attempting to mark
  it pure or immutable.
2025-06-25 08:24:36 -05:00

35 lines
961 B
PHP

<?php
declare(strict_types=1);
namespace Ramsey\Uuid\Test\Nonstandard;
use Mockery;
use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Exception\UnableToBuildUuidException;
use Ramsey\Uuid\Nonstandard\UuidBuilder;
use Ramsey\Uuid\Test\TestCase;
use RuntimeException;
class UuidBuilderTest extends TestCase
{
public function testBuildThrowsException(): void
{
$codec = Mockery::mock(CodecInterface::class);
$builder = Mockery::mock(UuidBuilder::class);
$builder->shouldAllowMockingProtectedMethods();
$builder->shouldReceive('buildFields')->andThrow(
RuntimeException::class,
'exception thrown'
);
$builder->shouldReceive('build')->passthru();
$this->expectException(UnableToBuildUuidException::class);
$this->expectExceptionMessage('exception thrown');
/** @phpstan-ignore method.resultUnused */
$builder->build($codec, 'foobar');
}
}