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

api-platform / core / 15255731762

26 May 2025 01:55PM UTC coverage: 0.0% (-26.5%) from 26.526%
15255731762

Pull #7176

github

web-flow
Merge 66f6cf4d2 into 79edced67
Pull Request #7176: Merge 4.1

0 of 387 new or added lines in 28 files covered. (0.0%)

11394 existing lines in 372 files now uncovered.

0 of 51334 relevant lines covered (0.0%)

0.0 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
    {
NEW
34
        tap($app['config'], function (Repository $config): void {
×
NEW
35
            $config->set('api-platform.formats', ['jsonld' => ['application/ld+json']]);
×
NEW
36
            $config->set('api-platform.docs_formats', ['jsonld' => ['application/ld+json']]);
×
NEW
37
        });
×
38
    }
39

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

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

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

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