Test Setup Failed
Pull Request — master (#1)
by Steevan
01:18
created

testValid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace steevanb\SymfonyOptionsResolver\Tests;
6
7
use PHPUnit\Framework\TestCase;
8
use steevanb\SymfonyOptionsResolver\OptionsResolver;
9
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
10
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
11
12 View Code Duplication
final class OptionsResolverConfigureRequiredOptionTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    public function testValid(): void
15
    {
16
        $this
17
            ->createOptionsResolver()
18
            ->resolve(['foo' => 'bar']);
19
20
        static::addToAssertionCount(1);
21
    }
22
23
    public function testInvalidType(): void
24
    {
25
        $optionsResolver = $this->createOptionsResolver();
26
27
        static::expectException(InvalidOptionsException::class);
28
        $optionsResolver->resolve(['foo' => 1]);
29
    }
30
31
    public function testInvalidAllowedValue(): void
32
    {
33
        $optionsResolver = $this->createOptionsResolver();
34
35
        static::expectException(InvalidOptionsException::class);
36
        $optionsResolver->resolve(['foo' => 'baz']);
37
    }
38
39
    public function testRequiredOption(): void
40
    {
41
        $optionsResolver = $this->createOptionsResolver();
42
43
        static::expectException(MissingOptionsException::class);
44
        $optionsResolver->resolve([]);
45
    }
46
47
    private function createOptionsResolver(): OptionsResolver
48
    {
49
        return (new OptionsResolver())
50
            ->configureRequiredOption('foo', ['string'], ['bar']);
51
    }
52
}
53