shouldReceive('build') ->once() ->with($codec, $fields) ->andThrow(InvalidArgumentException::class); $builder2 = Mockery::mock(UuidBuilderInterface::class); $builder2 ->shouldReceive('build') ->once() ->with($codec, $fields) ->andThrow(InvalidArgumentException::class); $builder3 = Mockery::mock(UuidBuilderInterface::class); $builder3 ->shouldReceive('build') ->once() ->with($codec, $fields) ->andThrow(InvalidArgumentException::class); $fallbackBuilder = new FallbackBuilder([$builder1, $builder2, $builder3]); $this->expectException(BuilderNotFoundException::class); $this->expectExceptionMessage( 'Could not find a suitable builder for the provided codec and fields' ); $fallbackBuilder->build($codec, $fields); } }