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

api-platform / core / 10315659289

09 Aug 2024 07:49AM UTC coverage: 7.841% (-0.006%) from 7.847%
10315659289

push

github

soyuka
style: cs fixes

70 of 529 new or added lines in 176 files covered. (13.23%)

160 existing lines in 58 files now uncovered.

12688 of 161818 relevant lines covered (7.84%)

26.86 hits per line

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

0.0
/src/Metadata/Tests/Resource/Factory/ParameterResourceMetadataCollectionFactoryTests.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\Metadata\Tests\Resource\Factory;
15

16
use ApiPlatform\Metadata\FilterInterface;
17
use ApiPlatform\Metadata\Parameters;
18
use ApiPlatform\Metadata\QueryParameter;
19
use ApiPlatform\Metadata\Resource\Factory\AttributesResourceMetadataCollectionFactory;
20
use ApiPlatform\Metadata\Resource\Factory\ParameterResourceMetadataCollectionFactory;
21
use ApiPlatform\Metadata\Tests\Fixtures\ApiResource\WithParameter;
22
use ApiPlatform\OpenApi\Model\Parameter;
23
use PHPUnit\Framework\TestCase;
24
use Psr\Container\ContainerInterface;
25

26
class ParameterResourceMetadataCollectionFactoryTests extends TestCase
27
{
28
    public function testParameterFactory(): void
29
    {
30
        $filterLocator = $this->createStub(ContainerInterface::class);
×
31
        $filterLocator->method('has')->willReturn(true);
×
NEW
32
        $filterLocator->method('get')->willReturn(new class implements FilterInterface {
×
33
            public function getDescription(string $resourceClass): array
34
            {
35
                return [
×
36
                    'hydra' => [
×
37
                        'property' => 'hydra',
×
38
                        'type' => 'string',
×
39
                        'required' => false,
×
40
                        'schema' => ['type' => 'foo'],
×
41
                        'openapi' => new Parameter('test', 'query'),
×
42
                    ],
×
43
                    'everywhere' => [
×
44
                        'property' => 'everywhere',
×
45
                        'type' => 'string',
×
46
                        'required' => false,
×
47
                        'openapi' => ['allowEmptyValue' => true]],
×
48
                ];
×
49
            }
50
        });
×
51
        $parameter = new ParameterResourceMetadataCollectionFactory(new AttributesResourceMetadataCollectionFactory(), $filterLocator);
×
52
        $operation = $parameter->create(WithParameter::class)->getOperation('collection');
×
53
        $this->assertInstanceOf(Parameters::class, $parameters = $operation->getParameters());
×
54
        $hydraParameter = $parameters->get('hydra', QueryParameter::class);
×
55
        $this->assertEquals(['type' => 'foo'], $hydraParameter->getSchema());
×
56
        $this->assertEquals(new Parameter('test', 'query'), $hydraParameter->getOpenApi());
×
57
        $everywhere = $parameters->get('everywhere', QueryParameter::class);
×
58
        $this->assertEquals(new Parameter('everywhere', 'query', allowEmptyValue: true), $everywhere->getOpenApi());
×
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