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

api-platform / core / 15775135891

20 Jun 2025 08:42AM UTC coverage: 22.065% (+0.2%) from 21.876%
15775135891

push

github

soyuka
Merge 4.1

13 of 103 new or added lines in 10 files covered. (12.62%)

868 existing lines in 35 files now uncovered.

11487 of 52060 relevant lines covered (22.06%)

21.72 hits per line

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

0.0
/src/Laravel/Tests/ValidationTest.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\Laravel\Tests;
15

16
use ApiPlatform\Laravel\Test\ApiTestAssertionsTrait;
17
use Illuminate\Contracts\Config\Repository;
18
use Illuminate\Foundation\Application;
19
use Illuminate\Foundation\Testing\RefreshDatabase;
20
use Orchestra\Testbench\Concerns\WithWorkbench;
21
use Orchestra\Testbench\TestCase;
22

23
class ValidationTest extends TestCase
24
{
25
    use ApiTestAssertionsTrait;
26
    use RefreshDatabase;
27
    use WithWorkbench;
28

29
    /**
30
     * @param Application $app
31
     */
32
    protected function defineEnvironment($app): void
33
    {
34
        tap($app['config'], function (Repository $config): void {
×
35
            $config->set('api-platform.formats', ['jsonld' => ['application/ld+json']]);
×
36
            $config->set('api-platform.docs_formats', ['jsonld' => ['application/ld+json']]);
×
37
        });
×
38
    }
39

40
    public function testValidationCamelCase(): void
41
    {
42
        $data = [
×
43
            'surName' => '',
×
44
        ];
×
45

46
        $response = $this->postJson('/api/issue_6932', $data, ['accept' => 'application/ld+json', 'content-type' => 'application/ld+json']);
×
47
        $response->assertJsonFragment(['violations' => [['propertyPath' => 'surName', 'message' => 'The sur name field is required.']]]); // validate that the name has been converted
×
48
        $response->assertStatus(422);
×
49
    }
50

51
    public function testValidationSnakeCase(): void
52
    {
53
        $data = [
×
54
            'sur_name' => 'test',
×
55
        ];
×
56

57
        $response = $this->postJson('/api/issue_6932', $data, ['accept' => 'application/ld+json', 'content-type' => 'application/ld+json']);
×
58
        $response->assertStatus(422);
×
59
    }
60

61
    public function testRouteWithRequirements(): void
62
    {
UNCOV
63
        $response = $this->get('api/issue_7194_requirements/test', ['accept' => 'application/ld+json']);
×
UNCOV
64
        $response->assertStatus(404);
×
UNCOV
65
        $response = $this->get('api/issue_7194_requirements/1', ['accept' => 'application/ld+json']);
×
UNCOV
66
        $response->assertStatus(200);
×
67
    }
68
}
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