Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ jobs:
if [ "$COVERAGE" = '1' ]; then
vendor/bin/behat --out=std --format=progress --format=junit --out=build/logs/behat/junit --profile=default-coverage --no-interaction
else
vendor/bin/behat --out=std --format=progress --format=junit --out=build/logs/behat/junit --profile=default --no-interaction
if [ "${{ matrix.php }}" = '7.1' ]; then
vendor/bin/behat --out=std --format=progress --format=junit --out=build/logs/behat/junit --profile=default --no-interaction --tags='~@symfony/uid'
else
vendor/bin/behat --out=std --format=progress --format=junit --out=build/logs/behat/junit --profile=default --no-interaction
fi
fi
- name: Merge code coverage reports
if: matrix.coverage
Expand Down Expand Up @@ -384,7 +388,8 @@ jobs:
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run Behat tests
run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction
# @TODO remove the tag "@symfony/uid" in 3.0
run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction --tags='~@symfony/uid'

postgresql:
name: Behat (PHP ${{ matrix.php }}) (PostgreSQL)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Filter validation: Fix issue in Required filter validator with dot notation (#4221)
* OpenAPI: Fix notice/warning for `response` without `content` in the `openapi_context` (#4210)
* Serializer: Convert internal error to HTTP 400 in Ramsey uuid denormalization from invalid body string (#4200)
* Symfony: Add tests with Symfony Uuid (#4230)

## 2.6.4

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
"require-dev": {
"behat/behat": "^3.1",
"behat/mink": "^1.7",
"friends-of-behat/mink-browserkit-driver": "^1.3.1",
"friends-of-behat/mink-extension": "^2.2",
"friends-of-behat/symfony-extension": "^2.1",
"soyuka/contexts": "^3.3.1",
"doctrine/annotations": "^1.7",
"doctrine/common": "^2.11 || ^3.0",
"doctrine/data-fixtures": "^1.2.2",
Expand All @@ -41,6 +37,9 @@
"doctrine/mongodb-odm-bundle": "^4.0",
"doctrine/orm": "^2.6.4 || ^3.0",
"elasticsearch/elasticsearch": "^6.0 || ^7.0",
"friends-of-behat/mink-browserkit-driver": "^1.3.1",
"friends-of-behat/mink-extension": "^2.2",
"friends-of-behat/symfony-extension": "^2.1",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"jangregor/phpstan-prophecy": "^0.8",
"justinrainbow/json-schema": "^5.2.1",
Expand All @@ -54,6 +53,7 @@
"psr/log": "^1.0",
"ramsey/uuid": "^3.7 || ^4.0",
"ramsey/uuid-doctrine": "^1.4",
"soyuka/contexts": "^3.3.1",
"soyuka/stubs-mongodb": "^1.0",
"symfony/asset": "^3.4 || ^4.4 || ^5.1",
"symfony/browser-kit": "^4.4 || ^5.1",
Expand Down
11 changes: 11 additions & 0 deletions features/main/uuid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,14 @@ Feature: Using uuid identifier on resource
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"

# @TODO remove the tag "@symfony/uid" in 3.0
@symfony/uid
@!mongodb
@createSchema
Scenario: Retrieve a resource identified by Symfony\Component\Uid\Uuid
Given there is a Symfony dummy identified resource with uuid "cdf8f706-ebe3-4fb6-b0bd-ae7b48028f24"
When I send a "GET" request to "/symfony_uuid_dummies/cdf8f706-ebe3-4fb6-b0bd-ae7b48028f24"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
13 changes: 13 additions & 0 deletions tests/Behat/DoctrineContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\SecuredDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Site;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\SoMany;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\SymfonyUuidDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Taxon;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ThirdLevel;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\UrlEncodedId;
Expand All @@ -169,6 +170,7 @@
use Doctrine\Persistence\ObjectManager;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Uid\Uuid as SymfonyUuid;

/**
* Defines application features from the specific context.
Expand Down Expand Up @@ -1372,6 +1374,17 @@ public function thereIsARamseyIdentifiedResource(string $uuid)
$this->manager->flush();
}

/**
* @Given there is a Symfony dummy identified resource with uuid :uuid
*/
public function thereIsASymfonyDummyIdentifiedResource(string $uuid)
{
$dummy = new SymfonyUuidDummy(SymfonyUuid::fromString($uuid));

$this->manager->persist($dummy);
$this->manager->flush();
}

/**
* @Given there is a dummy object with a fourth level relation
*/
Expand Down
65 changes: 65 additions & 0 deletions tests/Fixtures/TestBundle/Entity/SymfonyUuidDummy.php
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 <dunglas@gmail.com>
*
* 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\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;

/* @TODO remove this check in 3.0 */
if (\PHP_VERSION_ID >= 70200 && class_exists(Uuid::class) && class_exists(UuidType::class)) {
/**
* @ORM\Entity
* @ApiResource
*
* @author Vincent Chalamon <vincentchalamon@gmail.com>
*/
class SymfonyUuidDummy
{
/**
* @ORM\Id
* @ORM\Column(type="symfony_uuid", unique=true)
* @ORM\GeneratedValue(strategy="NONE")
*/
private $id;

/**
* @ORM\Column(nullable=true)
*/
private $number;

public function __construct($id = null)
{
$this->id = $id ?? Uuid::v4();
}

public function getId(): Uuid
{
return $this->id;
}

public function getNumber(): ?string
{
return $this->number;
}

public function setNumber(?string $number): self
{
$this->number = $number;

return $this;
}
}
}
7 changes: 7 additions & 0 deletions tests/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Doctrine\Common\Inflector\Inflector;
use FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle;
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Bundle\MercureBundle\MercureBundle;
Expand All @@ -35,6 +36,7 @@
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Uid\Uuid;

/**
* AppKernel for tests.
Expand Down Expand Up @@ -110,6 +112,11 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load

$loader->load(__DIR__."/config/config_{$this->getEnvironment()}.yml");

/* @TODO remove this check in 3.0 */
if (\PHP_VERSION_ID >= 70200 && class_exists(Uuid::class) && class_exists(UuidType::class)) {
$loader->load(__DIR__.'/config/config_symfony_uid.yml');
}

$c->prependExtensionConfig('framework', [
'secret' => 'dunglas.fr',
'validation' => ['enable_annotations' => true],
Expand Down
6 changes: 6 additions & 0 deletions tests/Fixtures/app/config/config_symfony_uid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add custom configuration for PHP > 7.1
# @TODO in 3.0, merge this configuration in config_common.yml, config_mysql.yml, config_postgres.yml, config_sqlite.yml
doctrine:
dbal:
types:
symfony_uuid: Symfony\Bridge\Doctrine\Types\UuidType