Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Make expectations more realistic
Browse files Browse the repository at this point in the history
Return types have been added upstream, so returning ['violation1'] is
no longer realistic, it has to be an object.
  • Loading branch information
greg0ire authored and OskarStark committed Nov 24, 2019
1 parent ca5d1f3 commit 6132401
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/Component/Form/BasketValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Sonata\Component\Product\Pool;
use Sonata\Component\Product\ProductProviderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\ConstraintViolationInterface;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\ContainerConstraintValidatorFactory;
use Symfony\Component\Validator\Context\ExecutionContext;
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
Expand Down Expand Up @@ -47,7 +49,11 @@ public function testValidate(): void
$violationBuilder->expects($this->once())->method('addViolation');

$context = $this->createMock(ExecutionContext::class);
$context->expects($this->once())->method('getViolations')->willReturn(['violation1']);
$context->expects($this->once())
->method('getViolations')
->willReturn(new ConstraintViolationList([
$this->createMock(ConstraintViolationInterface::class),
]));
$context->expects($this->once())->method('buildViolation')->willReturn($violationBuilder);

$validator = new BasketValidator($pool, $consValFact);
Expand Down

0 comments on commit 6132401

Please sign in to comment.