Skip to content

feat(metadata) Load external PHP file resources #7017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/Metadata/Extractor/PhpFileResourceExtractor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace ApiPlatform\Metadata\Extractor;

use ApiPlatform\Metadata\ApiResource;

/**
* Extracts an array of metadata from a list of PHP files.
*
* @author Loïc Frémont <[email protected]>
*/
final class PhpFileResourceExtractor extends AbstractResourceExtractor
{
use ResourceExtractorTrait;

/**
* {@inheritdoc}
*/
protected function extractPath(string $path): void

Check warning on line 30 in src/Metadata/Extractor/PhpFileResourceExtractor.php

Codecov / codecov/patch

src/Metadata/Extractor/PhpFileResourceExtractor.php#L30

Added line #L30 was not covered by tests
{
$resource = $this->getPHPFileClosure($path)();

Check warning on line 32 in src/Metadata/Extractor/PhpFileResourceExtractor.php

Codecov / codecov/patch

src/Metadata/Extractor/PhpFileResourceExtractor.php#L32

Added line #L32 was not covered by tests

if (!$resource instanceof ApiResource) {
return;

Check warning on line 35 in src/Metadata/Extractor/PhpFileResourceExtractor.php

Codecov / codecov/patch

src/Metadata/Extractor/PhpFileResourceExtractor.php#L34-L35

Added lines #L34 - L35 were not covered by tests
}

$resourceReflection = new \ReflectionClass($resource);

Check warning on line 38 in src/Metadata/Extractor/PhpFileResourceExtractor.php

Codecov / codecov/patch

src/Metadata/Extractor/PhpFileResourceExtractor.php#L38

Added line #L38 was not covered by tests

foreach ($resourceReflection->getProperties() as $property) {
$property->setAccessible(true);
$resolvedValue = $this->resolve($property->getValue($resource));
$property->setValue($resource, $resolvedValue);

Check warning on line 43 in src/Metadata/Extractor/PhpFileResourceExtractor.php

Codecov / codecov/patch

src/Metadata/Extractor/PhpFileResourceExtractor.php#L40-L43

Added lines #L40 - L43 were not covered by tests
}

$this->resources = [$resource];

Check warning on line 46 in src/Metadata/Extractor/PhpFileResourceExtractor.php

Codecov / codecov/patch

src/Metadata/Extractor/PhpFileResourceExtractor.php#L46

Added line #L46 was not covered by tests
}

/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
private function getPHPFileClosure(string $filePath): \Closure

Check warning on line 54 in src/Metadata/Extractor/PhpFileResourceExtractor.php

Codecov / codecov/patch

src/Metadata/Extractor/PhpFileResourceExtractor.php#L54

Added line #L54 was not covered by tests
{
return \Closure::bind(function () use ($filePath): mixed {
return require $filePath;
}, null, null);

Check warning on line 58 in src/Metadata/Extractor/PhpFileResourceExtractor.php

Codecov / codecov/patch

src/Metadata/Extractor/PhpFileResourceExtractor.php#L56-L58

Added lines #L56 - L58 were not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace ApiPlatform\Metadata\Resource\Factory;

use ApiPlatform\Metadata\Extractor\ResourceExtractorInterface;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\Metadata\Operations;
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;

final class PhpFileResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface
{
use OperationDefaultsTrait;

public function __construct(
private readonly ResourceExtractorInterface $metadataExtractor,
private readonly ?ResourceMetadataCollectionFactoryInterface $decorated = null,
) {
}

/**
* {@inheritdoc}
*/
public function create(string $resourceClass): ResourceMetadataCollection
{
$resourceMetadataCollection = new ResourceMetadataCollection($resourceClass);
if ($this->decorated) {
$resourceMetadataCollection = $this->decorated->create($resourceClass);
}

foreach ($this->metadataExtractor->getResources() as $resource) {
if ($resourceClass !== $resource->getClass()) {
continue;

Check warning on line 43 in src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php

Codecov / codecov/patch

src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php#L42-L43

Added lines #L42 - L43 were not covered by tests
}

$shortName = (false !== $pos = strrpos($resourceClass, '\\')) ? substr($resourceClass, $pos + 1) : $resourceClass;
$resource = $this->getResourceWithDefaults($resourceClass, $shortName, $resource);

Check warning on line 47 in src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php

Codecov / codecov/patch

src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php#L46-L47

Added lines #L46 - L47 were not covered by tests

$operations = [];

Check warning on line 49 in src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php

Codecov / codecov/patch

src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php#L49

Added line #L49 was not covered by tests
/** @var Operation $operation */
foreach ($resource->getOperations() ?? new Operations() as $operation) {
[$key, $operation] = $this->getOperationWithDefaults($resource, $operation);
$operations[$key] = $operation;

Check warning on line 53 in src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php

Codecov / codecov/patch

src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php#L51-L53

Added lines #L51 - L53 were not covered by tests
}

if ($operations) {
$resource = $resource->withOperations(new Operations($operations));

Check warning on line 57 in src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php

Codecov / codecov/patch

src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php#L56-L57

Added lines #L56 - L57 were not covered by tests
}

$resourceMetadataCollection[] = $resource;

Check warning on line 60 in src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php

Codecov / codecov/patch

src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.php#L60

Added line #L60 was not covered by tests
}

return $resourceMetadataCollection;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace ApiPlatform\Metadata\Resource\Factory;

use ApiPlatform\Metadata\Extractor\ResourceExtractorInterface;
use ApiPlatform\Metadata\Resource\ResourceNameCollection;

/**
* @internal
*/
final class PhpFileResourceNameCollectionFactory implements ResourceNameCollectionFactoryInterface
{
public function __construct(
private readonly ResourceExtractorInterface $metadataExtractor,
private readonly ?ResourceNameCollectionFactoryInterface $decorated = null,
) {
}

/**
* {@inheritdoc}
*/
public function create(): ResourceNameCollection
{
$classes = [];

if ($this->decorated) {
foreach ($this->decorated->create() as $resourceClass) {
$classes[$resourceClass] = true;
}
}

foreach ($this->metadataExtractor->getResources() as $resource) {
$resourceClass = $resource->getClass();

Check warning on line 44 in src/Metadata/Resource/Factory/PhpFileResourceNameCollectionFactory.php

Codecov / codecov/patch

src/Metadata/Resource/Factory/PhpFileResourceNameCollectionFactory.php#L44

Added line #L44 was not covered by tests

if (null === $resourceClass) {
continue;

Check warning on line 47 in src/Metadata/Resource/Factory/PhpFileResourceNameCollectionFactory.php

Codecov / codecov/patch

src/Metadata/Resource/Factory/PhpFileResourceNameCollectionFactory.php#L46-L47

Added lines #L46 - L47 were not covered by tests
}

$classes[$resourceClass] = true;

Check warning on line 50 in src/Metadata/Resource/Factory/PhpFileResourceNameCollectionFactory.php

Codecov / codecov/patch

src/Metadata/Resource/Factory/PhpFileResourceNameCollectionFactory.php#L50

Added line #L50 was not covered by tests
}

return new ResourceNameCollection(array_keys($classes));
}
}
28 changes: 28 additions & 0 deletions src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace ApiPlatform\Metadata\Tests\Extractor;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Extractor\PhpFileResourceExtractor;
use PHPUnit\Framework\TestCase;

final class PhpFileResourceExtractorTest extends TestCase
{
public function testItGetsResourcesFromPhpFileThatReturnsAnApiResource(): void

Check warning on line 13 in src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php

Codecov / codecov/patch

src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php#L13

Added line #L13 was not covered by tests
{
$extractor = new PhpFileResourceExtractor([__DIR__ . '/php/valid_php_file.php']);

Check warning on line 15 in src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php

Codecov / codecov/patch

src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php#L15

Added line #L15 was not covered by tests

$expectedResource = new ApiResource(shortName: 'dummy');

Check warning on line 17 in src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php

Codecov / codecov/patch

src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php#L17

Added line #L17 was not covered by tests

$this->assertEquals([$expectedResource], $extractor->getResources());

Check warning on line 19 in src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php

Codecov / codecov/patch

src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php#L19

Added line #L19 was not covered by tests
}

public function testItExcludesResourcesFromPhpFileThatDoesNotReturnAnApiResource(): void

Check warning on line 22 in src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php

Codecov / codecov/patch

src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php#L22

Added line #L22 was not covered by tests
{
$extractor = new PhpFileResourceExtractor([__DIR__ . '/php/invalid_php_file.php']);

Check warning on line 24 in src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php

Codecov / codecov/patch

src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php#L24

Added line #L24 was not covered by tests

$this->assertEquals([], $extractor->getResources());

Check warning on line 26 in src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php

Codecov / codecov/patch

src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php#L26

Added line #L26 was not covered by tests
}
}
5 changes: 5 additions & 0 deletions src/Metadata/Tests/Extractor/php/invalid_php_file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

declare(strict_types=1);

return new \stdClass();

Check warning on line 5 in src/Metadata/Tests/Extractor/php/invalid_php_file.php

Codecov / codecov/patch

src/Metadata/Tests/Extractor/php/invalid_php_file.php#L5

Added line #L5 was not covered by tests
7 changes: 7 additions & 0 deletions src/Metadata/Tests/Extractor/php/valid_php_file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

use ApiPlatform\Metadata\ApiResource;

return new ApiResource(shortName: 'dummy');

Check warning on line 7 in src/Metadata/Tests/Extractor/php/valid_php_file.php

Codecov / codecov/patch

src/Metadata/Tests/Extractor/php/valid_php_file.php#L7

Added line #L7 was not covered by tests
34 changes: 31 additions & 3 deletions src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php
Original file line number Diff line number Diff line change
@@ -305,7 +305,7 @@

private function registerMetadataConfiguration(ContainerBuilder $container, array $config, XmlFileLoader $loader): void
{
[$xmlResources, $yamlResources] = $this->getResourcesToWatch($container, $config);
[$xmlResources, $yamlResources, $phpResources] = $this->getResourcesToWatch($container, $config);

$container->setParameter('api_platform.class_name_resources', $this->getClassNameResources());

@@ -320,6 +320,7 @@
}

// V3 metadata
$loader->load('metadata/php.xml');
$loader->load('metadata/xml.xml');
$loader->load('metadata/links.xml');
$loader->load('metadata/property.xml');
@@ -338,6 +339,8 @@
$container->getDefinition('api_platform.metadata.resource_extractor.yaml')->replaceArgument(0, $yamlResources);
$container->getDefinition('api_platform.metadata.property_extractor.yaml')->replaceArgument(0, $yamlResources);
}

$container->getDefinition('api_platform.metadata.resource_extractor.php_file')->replaceArgument(0, $phpResources);
}

private function getClassNameResources(): array
@@ -402,7 +405,32 @@
}
}

$resources = ['yml' => [], 'xml' => [], 'dir' => []];
$resources = ['yml' => [], 'xml' => [], 'php' => [], 'dir' => []];

foreach ($config['mapping']['imports'] ?? [] as $path) {
if (is_dir($path)) {
foreach (Finder::create()->followLinks()->files()->in($path)->name('/\.php$/')->sortByName() as $file) {
$resources[$file->getExtension()][] = $file->getRealPath();

Check warning on line 413 in src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Codecov / codecov/patch

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L411-L413

Added lines #L411 - L413 were not covered by tests
}

$resources['dir'][] = $path;
$container->addResource(new DirectoryResource($path, '/\.php$/'));

Check warning on line 417 in src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Codecov / codecov/patch

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L416-L417

Added lines #L416 - L417 were not covered by tests

continue;

Check warning on line 419 in src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Codecov / codecov/patch

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L419

Added line #L419 was not covered by tests
}

if ($container->fileExists($path, false)) {
if (!preg_match('/\.php$/', (string) $path, $matches)) {
throw new RuntimeException(\sprintf('Unsupported mapping type in "%s", supported type is PHP.', $path));

Check warning on line 424 in src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Codecov / codecov/patch

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L422-L424

Added lines #L422 - L424 were not covered by tests
}

$resources['php' === $matches[1]][] = $path;

Check failure on line 427 in src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

GitHub Actions / PHPStan (PHP 8.4)

Offset 1 does not exist on array{string}.

Check warning on line 427 in src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Codecov / codecov/patch

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L427

Added line #L427 was not covered by tests

continue;

Check warning on line 429 in src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Codecov / codecov/patch

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L429

Added line #L429 was not covered by tests
}

throw new RuntimeException(\sprintf('Could not open file or directory "%s".', $path));

Check warning on line 432 in src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Codecov / codecov/patch

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L432

Added line #L432 was not covered by tests
}

foreach ($paths as $path) {
if (is_dir($path)) {
@@ -431,7 +459,7 @@

$container->setParameter('api_platform.resource_class_directories', $resources['dir']);

return [$resources['xml'], $resources['yml']];
return [$resources['xml'], $resources['yml'], $resources['php']];
}

private function registerOAuthConfiguration(ContainerBuilder $container, array $config): void
3 changes: 3 additions & 0 deletions src/Symfony/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -134,6 +134,9 @@ public function getConfigTreeBuilder(): TreeBuilder
->arrayNode('mapping')
->addDefaultsIfNotSet()
->children()
->arrayNode('imports')
->prototype('scalar')->end()
->end()
->arrayNode('paths')
->prototype('scalar')->end()
->end()
13 changes: 13 additions & 0 deletions src/Symfony/Bundle/Resources/config/metadata/php.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="api_platform.metadata.resource_extractor.php_file" class="ApiPlatform\Metadata\Extractor\PhpFileResourceExtractor" public="false">
<argument type="collection" />
<argument type="service" id="service_container" />
</service>
</services>
</container>
6 changes: 6 additions & 0 deletions src/Symfony/Bundle/Resources/config/metadata/resource.xml
Original file line number Diff line number Diff line change
@@ -24,6 +24,12 @@
<argument>%api_platform.graphql.enabled%</argument>
</service>

<service id="api_platform.metadata.resource.metadata_collection_factory.php_file" class="ApiPlatform\Metadata\Resource\Factory\PhpFileResourceMetadataCollectionFactory" decorates="api_platform.metadata.resource.metadata_collection_factory" decoration-priority="800" public="false">
<argument type="service" id="api_platform.metadata.resource_extractor.php_file" />
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory.php_file.inner" />
<argument type="service" id="service_container" on-invalid="null" />
</service>

<service id="api_platform.metadata.resource.metadata_collection_factory.concerns" class="ApiPlatform\Metadata\Resource\Factory\ConcernsResourceMetadataCollectionFactory" decorates="api_platform.metadata.resource.metadata_collection_factory" decoration-priority="800" public="false">
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory.concerns.inner" />
</service>
Original file line number Diff line number Diff line change
@@ -22,6 +22,11 @@
<argument type="service" id="api_platform.metadata.resource_extractor.xml" />
</service>

<service id="api_platform.metadata.resource.name_collection_factory.php_file" class="ApiPlatform\Metadata\Resource\Factory\PhpFileResourceNameCollectionFactory" decorates="api_platform.metadata.resource.name_collection_factory" decoration-priority="900" public="false">
<argument type="service" id="api_platform.metadata.resource_extractor.php_file" />
<argument type="service" id="api_platform.metadata.resource.name_collection_factory.php_file.inner" />
</service>

<service id="api_platform.metadata.resource.name_collection_factory.concerns" class="ApiPlatform\Metadata\Resource\Factory\ConcernsResourceNameCollectionFactory" decorates="api_platform.metadata.resource.name_collection_factory" decoration-priority="800" public="false">
<argument>%api_platform.resource_class_directories%</argument>
<argument type="service" id="api_platform.metadata.resource.name_collection_factory.concerns.inner" />
Original file line number Diff line number Diff line change
@@ -29,11 +29,13 @@
use ApiPlatform\Tests\Fixtures\TestBundle\TestBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\ORM\OptimisticLockException;
use PHPUnit\Framework\Constraint\IsEqual;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpFoundation\Response;

class ApiPlatformExtensionTest extends TestCase
@@ -149,6 +151,11 @@
}
}

private function assertContainerHasService(string $service): void

Check warning on line 154 in src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Codecov / codecov/patch

src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php#L154

Added line #L154 was not covered by tests
{
$this->assertTrue($this->container->hasDefinition($service), \sprintf('Service "%s" not found.', $service));

Check warning on line 156 in src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Codecov / codecov/patch

src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php#L156

Added line #L156 was not covered by tests
}

private function assertNotContainerHasService(string $service): void
{
$this->assertFalse($this->container->hasDefinition($service), \sprintf('Service "%s" found.', $service));
@@ -286,4 +293,20 @@
$this->assertContainerHas($services, $aliases);
$this->container->hasParameter('api_platform.swagger.http_auth');
}

public function testItRegisterMetadataConfiguration(): void

Check warning on line 297 in src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Codecov / codecov/patch

src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php#L297

Added line #L297 was not covered by tests
{
$config = self::DEFAULT_CONFIG;
$config['api_platform']['mapping']['imports'] = [__DIR__.'/php'];
(new ApiPlatformExtension())->load($config, $this->container);

Check warning on line 301 in src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Codecov / codecov/patch

src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php#L299-L301

Added lines #L299 - L301 were not covered by tests

$emptyPhpFile = realpath(__DIR__.'/php/empty_file.php');

Check warning on line 303 in src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Codecov / codecov/patch

src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php#L303

Added line #L303 was not covered by tests

$this->assertContainerHasService('api_platform.metadata.resource_extractor.php_file');

Check warning on line 305 in src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Codecov / codecov/patch

src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php#L305

Added line #L305 was not covered by tests

$service = $this->container->get('api_platform.metadata.resource_extractor.php_file');
$reflection = new \ReflectionClass($service);

Check warning on line 308 in src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Codecov / codecov/patch

src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php#L307-L308

Added lines #L307 - L308 were not covered by tests

$this->assertSame([$emptyPhpFile], $reflection->getProperty('paths')->getValue($service));

Check warning on line 310 in src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Codecov / codecov/patch

src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php#L310

Added line #L310 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
Loading