• 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/SnakeCaseApiTest.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
use ApiPlatform\Laravel\Test\ApiTestAssertionsTrait;
15
use Illuminate\Contracts\Config\Repository;
16
use Illuminate\Foundation\Application;
17
use Illuminate\Foundation\Testing\RefreshDatabase;
18
use Illuminate\Support\Str;
19
use Orchestra\Testbench\Concerns\WithWorkbench;
20
use Orchestra\Testbench\TestCase;
21

22
class SnakeCaseApiTest extends TestCase
23
{
24
    use ApiTestAssertionsTrait;
25
    use RefreshDatabase;
26
    use WithWorkbench;
27

28
    /**
29
     * @param Application $app
30
     */
31
    protected function defineEnvironment($app): void
32
    {
NEW
33
        tap($app['config'], function (Repository $config): void {
×
NEW
34
            $config->set('api-platform.name_converter', null);
×
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 testRelationIsHandledOnCreateWithNestedDataSnakeCase(): void
41
    {
NEW
42
        $cartData = [
×
NEW
43
            'product_sku' => 'SKU_TEST_001',
×
NEW
44
            'quantity' => 2,
×
NEW
45
            'price_at_addition' => '19.99',
×
NEW
46
            'shopping_cart' => [
×
NEW
47
                'user_identifier' => 'user-'.Str::uuid()->toString(),
×
NEW
48
                'status' => 'active',
×
NEW
49
            ],
×
NEW
50
        ];
×
51

NEW
52
        $response = $this->postJson('/api/cart_items', $cartData, ['accept' => 'application/ld+json', 'content-type' => 'application/ld+json']);
×
NEW
53
        $response->assertStatus(201);
×
54

NEW
55
        $response
×
NEW
56
            ->assertJson([
×
NEW
57
                '@context' => '/api/contexts/CartItem',
×
NEW
58
                '@id' => '/api/cart_items/1',
×
NEW
59
                '@type' => 'CartItem',
×
NEW
60
                'id' => 1,
×
NEW
61
                'product_sku' => 'SKU_TEST_001',
×
NEW
62
                'quantity' => 2,
×
NEW
63
                'price_at_addition' => 19.99,
×
NEW
64
                'shopping_cart' => [
×
NEW
65
                    '@id' => '/api/shopping_carts/1',
×
NEW
66
                    '@type' => 'ShoppingCart',
×
NEW
67
                    'user_identifier' => $cartData['shopping_cart']['user_identifier'],
×
NEW
68
                    'status' => 'active',
×
NEW
69
                ],
×
NEW
70
            ]);
×
71
    }
72

73
    public function testFailWithCamelCase(): void
74
    {
NEW
75
        $cartData = [
×
NEW
76
            'productSku' => 'SKU_TEST_001',
×
NEW
77
            'quantity' => 2,
×
NEW
78
            'priceAtAddition' => '19.99',
×
NEW
79
            'shoppingCart' => [
×
NEW
80
                'userIdentifier' => 'user-'.Str::uuid()->toString(),
×
NEW
81
                'status' => 'active',
×
NEW
82
            ],
×
NEW
83
        ];
×
84

NEW
85
        $response = $this->postJson('/api/cart_items', $cartData, ['accept' => 'application/ld+json', 'content-type' => 'application/ld+json']);
×
NEW
86
        $response->assertStatus(422);
×
87
    }
88
}
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