• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 13203378522

07 Feb 2025 03:56PM UTC coverage: 8.501% (+0.7%) from 7.837%
13203378522

push

github

soyuka
Merge 4.1

111 of 490 new or added lines in 51 files covered. (22.65%)

5590 existing lines in 163 files now uncovered.

13345 of 156987 relevant lines covered (8.5%)

22.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Validator/Tests/Exception/ValidationExceptionTest.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Validator\Tests\Exception;
15

16
use ApiPlatform\Metadata\Exception\RuntimeException;
17
use ApiPlatform\Validator\Exception\ValidationException;
18
use PHPUnit\Framework\TestCase;
19
use Symfony\Component\Validator\ConstraintViolation;
20
use Symfony\Component\Validator\ConstraintViolationList;
21

22
/**
23
 * @author Kévin Dunglas <dunglas@gmail.com>
24
 */
25
class ValidationExceptionTest extends TestCase
26
{
27
    public function testToString(): void
28
    {
29
        $e = new ValidationException(new ConstraintViolationList([
×
30
            new ConstraintViolation('message 1', '', [], '', '', 'invalid'),
×
31
            new ConstraintViolation('message 2', '', [], '', 'foo', 'invalid'),
×
32
        ]));
×
33
        $this->assertInstanceOf(RuntimeException::class, $e);
×
34
        $this->assertInstanceOf(\RuntimeException::class, $e);
×
35

36
        $this->assertSame(str_replace(\PHP_EOL, "\n", <<<TXT
×
37
message 1
38
foo: message 2
39
TXT
×
40
        ), $e->__toString());
×
41
    }
42

43
    public function testWithPrevious(): void
44
    {
UNCOV
45
        $previous = new \Exception();
×
UNCOV
46
        $e = new ValidationException(new ConstraintViolationList([
×
UNCOV
47
            new ConstraintViolation('message 1', '', [], '', '', 'invalid'),
×
UNCOV
48
        ]), null, $previous);
×
UNCOV
49
        $this->assertInstanceOf(\RuntimeException::class, $e);
×
50

UNCOV
51
        $this->assertSame(str_replace(\PHP_EOL, "\n", <<<TXT
×
52
message 1
UNCOV
53
TXT
×
UNCOV
54
        ), $e->__toString());
×
UNCOV
55
        $this->assertSame($previous, $e->getPrevious());
×
56
    }
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc