Skip to content

Commit

Permalink
fix mongodb tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Jun 18, 2020
1 parent f1e3440 commit acfcd13
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion features/bootstrap/DoctrineContext.php
Expand Up @@ -67,6 +67,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\SoMany as SoManyDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Taxon as TaxonDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\ThirdLevel as ThirdLevelDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\UrlEncodedId as UrlEncodedIdDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\User as UserDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Address;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Answer;
Expand Down Expand Up @@ -1061,7 +1062,7 @@ public function thereIsAnAnswerToTheQuestion(string $a, string $q)
*/
public function thereIsAUrlEncodedIdResource()
{
$urlEncodedIdResource = new UrlEncodedId();
$urlEncodedIdResource = ($this->isOrm() ? new UrlEncodedId() : new UrlEncodedIdDocument());
$this->manager->persist($urlEncodedIdResource);
$this->manager->flush();
$this->manager->clear();
Expand Down
46 changes: 46 additions & 0 deletions tests/Fixtures/TestBundle/Document/UrlEncodedId.php
@@ -0,0 +1,46 @@
<?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\Document;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
* @author Daniel West <daniel@silverback.is>
*
* Resource with an ID that will be URL encoded
*
* @ODM\Document
*
* @ApiResource(
* itemOperations={
* "get"={
* "method"="GET",
* "requirements"={"id"=".+"}
* }
* }
* )
*/
class UrlEncodedId
{
/**
* @ODM\Id(strategy="none")
*/
private $id = '%encode:id';

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

0 comments on commit acfcd13

Please sign in to comment.