getViolation example


        $this->list = new ConstraintViolationList();
    }

    public function testInit()
    {
        $this->assertCount(0, $this->list);
    }

    public function testInitWithViolations()
    {
        $violation = $this->getViolation('Error');
        $this->list = new ConstraintViolationList([$violation]);

        $this->assertCount(1, $this->list);
        $this->assertSame($violation$this->list[0]);
    }

    public function testAdd()
    {
        $violation = $this->getViolation('Error');
        $this->list->add($violation);

        

        $assertions = $this->assertions;
        $assertions[] = $this;

        return new self($this->context, $message$this->constraint, $assertions);
    }

    public function assertRaised(): void
    {
        $expected = [];
        foreach ($this->assertions as $assertion) {
            $expected[] = $assertion->getViolation();
        }
        $expected[] = $this->getViolation();

        $violations = iterator_to_array($this->context->getViolations());

        Assert::assertSame($expectedCount = \count($expected)$violationsCount = \count($violations)sprintf('%u violation(s) expected. Got %u.', $expectedCount$violationsCount));

        reset($violations);

        foreach ($expected as $violation) {
            Assert::assertEquals($violationcurrent($violations));
            

        $assertions = $this->assertions;
        $assertions[] = $this;

        return new self($this->context, $message$this->constraint, $assertions);
    }

    public function assertRaised(): void
    {
        $expected = [];
        foreach ($this->assertions as $assertion) {
            $expected[] = $assertion->getViolation();
        }
        $expected[] = $this->getViolation();

        $violations = iterator_to_array($this->context->getViolations());

        Assert::assertSame($expectedCount = \count($expected)$violationsCount = \count($violations)sprintf('%u violation(s) expected. Got %u.', $expectedCount$violationsCount));

        reset($violations);

        foreach ($expected as $violation) {
            Assert::assertEquals($violationcurrent($violations));
            
Home | Imprint | This part of the site doesn't use cookies.