BarcodeValidatorSpec::it_validates()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\Loevgaard\SyliusBarcodePlugin\Validator;
6
7
use Loevgaard\SyliusBarcodePlugin\Validator\BarcodeValidator;
8
use Loevgaard\SyliusBarcodePlugin\Validator\Constraint\Barcode;
9
use PhpSpec\ObjectBehavior;
10
use Prophecy\Argument;
11
use Symfony\Component\Validator\Constraint;
12
use Symfony\Component\Validator\Context\ExecutionContextInterface;
13
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
14
15
class BarcodeValidatorSpec extends ObjectBehavior
16
{
17
    public function let(ExecutionContextInterface $executionContext): void
18
    {
19
        $this->initialize($executionContext);
0 ignored issues
show
Bug introduced by
The method initialize() does not exist on spec\Loevgaard\SyliusBar...or\BarcodeValidatorSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $this->/** @scrutinizer ignore-call */ 
20
               initialize($executionContext);
Loading history...
20
    }
21
22
    public function it_is_initializable(): void
23
    {
24
        $this->shouldHaveType(BarcodeValidator::class);
25
    }
26
27
    public function it_extends_constraint(): void
28
    {
29
        $this->beAnInstanceOf(Constraint::class);
30
    }
31
32
    public function it_validates(ExecutionContextInterface $executionContext): void
33
    {
34
        $executionContext->buildViolation(Argument::any())->shouldNotBeCalled();
0 ignored issues
show
Bug introduced by
The method shouldNotBeCalled() does not exist on Symfony\Component\Valida...olationBuilderInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        $executionContext->buildViolation(Argument::any())->/** @scrutinizer ignore-call */ shouldNotBeCalled();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
        $this->validate('4006381333931', new Barcode());
0 ignored issues
show
Bug introduced by
The method validate() does not exist on spec\Loevgaard\SyliusBar...or\BarcodeValidatorSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        $this->/** @scrutinizer ignore-call */ 
36
               validate('4006381333931', new Barcode());
Loading history...
36
    }
37
38
    public function it_invalidates(ExecutionContextInterface $executionContext, ConstraintViolationBuilderInterface $constraintViolationBuilder): void
39
    {
40
        $value = 'invalid';
41
42
        $constraintViolationBuilder->setParameter('{{ string }}', $value)->willReturn($constraintViolationBuilder)->shouldBeCalled();
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Symfony\Component\Valida...olationBuilderInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        $constraintViolationBuilder->setParameter('{{ string }}', $value)->/** @scrutinizer ignore-call */ willReturn($constraintViolationBuilder)->shouldBeCalled();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
        $constraintViolationBuilder->addViolation()->shouldBeCalled();
44
45
        $constraint = new Barcode();
46
        $executionContext->buildViolation($constraint->message)->willReturn($constraintViolationBuilder)->shouldBeCalled();
47
        $this->validate($value, $constraint);
48
    }
49
}
50