Passed
Push — master ( 17ea33...1a0634 )
by Steevan
01:30
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\{
10
    Exception\InvalidOptionsException,
11
    Exception\MissingOptionsException
12
};
13
14 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...
15
{
16
    public function testValid(): void
17
    {
18
        $this
19
            ->createOptionsResolver()
20
            ->resolve(['foo' => 'bar']);
21
22
        static::addToAssertionCount(1);
23
    }
24
25
    public function testInvalidType(): void
26
    {
27
        $optionsResolver = $this->createOptionsResolver();
28
29
        static::expectException(InvalidOptionsException::class);
30
        $optionsResolver->resolve(['foo' => 1]);
31
    }
32
33
    public function testInvalidAllowedValue(): void
34
    {
35
        $optionsResolver = $this->createOptionsResolver();
36
37
        static::expectException(InvalidOptionsException::class);
38
        $optionsResolver->resolve(['foo' => 'baz']);
39
    }
40
41
    public function testRequiredOption(): void
42
    {
43
        $optionsResolver = $this->createOptionsResolver();
44
45
        static::expectException(MissingOptionsException::class);
46
        $optionsResolver->resolve([]);
47
    }
48
49
    private function createOptionsResolver(): OptionsResolver
50
    {
51
        return (new OptionsResolver())
52
            ->configureRequiredOption('foo', ['string'], ['bar']);
53
    }
54
}
55