Skip to content

Commit acfcd13

Browse files
committed
fix mongodb tests
1 parent f1e3440 commit acfcd13

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

features/bootstrap/DoctrineContext.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\SoMany as SoManyDocument;
6868
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Taxon as TaxonDocument;
6969
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\ThirdLevel as ThirdLevelDocument;
70+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\UrlEncodedId as UrlEncodedIdDocument;
7071
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\User as UserDocument;
7172
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Address;
7273
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Answer;
@@ -1061,7 +1062,7 @@ public function thereIsAnAnswerToTheQuestion(string $a, string $q)
10611062
*/
10621063
public function thereIsAUrlEncodedIdResource()
10631064
{
1064-
$urlEncodedIdResource = new UrlEncodedId();
1065+
$urlEncodedIdResource = ($this->isOrm() ? new UrlEncodedId() : new UrlEncodedIdDocument());
10651066
$this->manager->persist($urlEncodedIdResource);
10661067
$this->manager->flush();
10671068
$this->manager->clear();
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
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\Core\Tests\Fixtures\TestBundle\Document;
15+
16+
use ApiPlatform\Core\Annotation\ApiResource;
17+
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
18+
19+
/**
20+
* @author Daniel West <[email protected]>
21+
*
22+
* Resource with an ID that will be URL encoded
23+
*
24+
* @ODM\Document
25+
*
26+
* @ApiResource(
27+
* itemOperations={
28+
* "get"={
29+
* "method"="GET",
30+
* "requirements"={"id"=".+"}
31+
* }
32+
* }
33+
* )
34+
*/
35+
class UrlEncodedId
36+
{
37+
/**
38+
* @ODM\Id(strategy="none")
39+
*/
40+
private $id = '%encode:id';
41+
42+
public function getId()
43+
{
44+
return $this->id;
45+
}
46+
}

0 commit comments

Comments
 (0)