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

api-platform / core / 14445694100

14 Apr 2025 12:30PM UTC coverage: 8.189% (+0.9%) from 7.281%
14445694100

push

github

soyuka
Reapply "fix(jsonld): duplicate error fields when prefix is enabled (#7021)" (#7074)

This reverts commit dfca9bf60.

2 of 8 new or added lines in 4 files covered. (25.0%)

3068 existing lines in 349 files now uncovered.

12931 of 157906 relevant lines covered (8.19%)

13.59 hits per line

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

0.0
/tests/Functional/ErrorTest.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\Tests\Functional;
15

16
use ApiPlatform\State\ApiResource\Error;
17
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
18
use ApiPlatform\Tests\SetupClassResourcesTrait;
19
use PHPUnit\Framework\Attributes\DataProvider;
20

21
final class ErrorTest extends ApiTestCase
22
{
23
    use SetupClassResourcesTrait;
24

25
    protected static ?bool $alwaysBootKernel = false;
26

27
    /**
28
     * @return class-string[]
29
     */
30
    public static function getResources(): array
31
    {
32
        return [Error::class];
×
33
    }
34

35
    #[DataProvider('formatsProvider')]
36
    public function testRetrieveError(string $format, string $status, $expected): void
37
    {
38
        self::createClient()->request('GET', '/errors/'.$status, ['headers' => ['accept' => $format]]);
×
39
        $this->assertJsonContains($expected);
×
40
    }
41

42
    public function testRetrieveErrorHtml(): void
43
    {
44
        $response = self::createClient()->request('GET', '/errors/403', ['headers' => ['accept' => 'text/html']]);
×
45
        $this->assertEquals('<!DOCTYPE html>
×
46
<html>
47
<head>
48
  <meta charset="UTF-8" />
49
  <title>Error 403</title>
50
    </head>
51
    <body><h1>Error 403</h1>Forbidden</body>
52
</html>', $response->getContent());
×
53
    }
54

55
    public static function formatsProvider(): array
56
    {
57
        return [
×
58
            [
×
59
                'application/vnd.api+json',
×
60
                '401',
×
61
                [
×
62
                    'errors' => [['id' => '/errors/401', 'detail' => 'Unauthorized']],
×
63
                ],
×
64
            ],
×
65
            [
×
66
                'application/ld+json',
×
67
                '401',
×
68
                [
×
69
                    '@type' => 'hydra:Error',
×
NEW
70
                    'hydra:description' => 'Unauthorized',
×
71
                ],
×
72
            ],
×
73
            [
×
74
                'application/json',
×
75
                '401',
×
76
                [
×
77
                    'detail' => 'Unauthorized',
×
78
                ],
×
79
            ],
×
80
        ];
×
81
    }
82
}
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