Skip to content

Commit

Permalink
Provide failing scenario for Gedmo/DoctrineExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Jun 7, 2019
1 parent e114acd commit af224ea
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"require-dev": {
"akeneo/phpspec-skip-example-extension": "^4.0",
"doctrine/orm": "^2.5",
"gedmo/doctrine-extensions": "^2.4",
"lakion/api-test-case": "^3.1.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.0",
"phpspec/phpspec": "^5.0",
Expand Down
1 change: 1 addition & 0 deletions src/Bundle/test/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function registerBundles()
new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new \winzou\Bundle\StateMachineBundle\winzouStateMachineBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle(),
new Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle(),
new AppBundle\AppBundle(),
Expand Down
6 changes: 6 additions & 0 deletions src/Bundle/test/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ fos_rest:
rules:
- { path: '^/', priorities: ['json'], fallback_format: json, prefer_extension: true }

stof_doctrine_extensions:
default_locale: "%locale%"
orm:
default:
sortable: true

services:
test.translation_locale_provider:
class: Sylius\Component\Resource\Translation\Provider\ImmutableTranslationLocaleProvider
Expand Down
4 changes: 4 additions & 0 deletions src/Bundle/test/app/config/resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ sylius_resource:
app.comic_book:
classes:
model: AppBundle\Entity\ComicBook

app.gedmo:
classes:
model: AppBundle\Entity\GedmoExtendedExample
5 changes: 5 additions & 0 deletions src/Bundle/test/app/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ app_book:
alias: app.book
type: sylius.resource_api

app_gedmo:
resource: |
alias: app.gedmo
type: sylius.resource_api

app_book_sortable_index:
path: /sortable-books/
methods: [GET]
Expand Down
40 changes: 40 additions & 0 deletions src/Bundle/test/src/AppBundle/Entity/GedmoBaseExample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace AppBundle\Entity;

use Sylius\Component\Resource\Model\ResourceInterface;

class GedmoBaseExample implements ResourceInterface
{
/** @var int */
private $id;

/** @var int|null */
private $position;

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

public function getPosition(): ?int
{
return $this->position;
}

public function setPosition(?int $position): void
{
$this->position = $position;
}
}
30 changes: 30 additions & 0 deletions src/Bundle/test/src/AppBundle/Entity/GedmoExtendedExample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace AppBundle\Entity;

class GedmoExtendedExample extends GedmoBaseExample
{
/** @var string|null */
private $extra;

public function getExtra(): ?string
{
return $this->extra;
}

public function setExtra(?string $extra): void
{
$this->extra = $extra;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AppBundle\Entity\GedmoBaseExample:
type: mappedSuperclass
table: gedmo
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
position:
type: integer
gedmo:
- sortablePosition
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AppBundle\Entity\GedmoExtendedExample:
type: mappedSuperclass
table: gedmo
fields:
extra:
type: string
45 changes: 45 additions & 0 deletions src/Bundle/test/src/Tests/Controller/GedmoApiTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace AppBundle\Tests\Controller;

use Lakion\ApiTestCase\JsonApiTestCase;
use Symfony\Component\HttpFoundation\Response;

final class GedmoApiTest extends JsonApiTestCase
{
/**
* @test
*/
public function it_allows_creating_a_comic_book()
{
$data =
<<<EOT
{
"extra": "Some info"
}
EOT;

$this->client->request('POST', '/gedmos/', [], [], ['CONTENT_TYPE' => 'application/json'], $data);
$response = $this->client->getResponse();
$this->assertResponse($response, 'gedmos/create_response', Response::HTTP_CREATED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": @integer@,
"position": 0,
"extra": "Some info"
}

0 comments on commit af224ea

Please sign in to comment.