Skip to content

Commit fcdcb5c

Browse files
authored
Fix tests (#1571)
1 parent 76d8a06 commit fcdcb5c

File tree

6 files changed

+32
-19
lines changed

6 files changed

+32
-19
lines changed

features/integration/nelmio_api_doc.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Skip while NelmioApiDoc 2 isn't compatible with Symfony 3.4
21
Feature: NelmioApiDoc integration
32
In order to use NelmioApiDocBundle
43
As an API software developer

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ini name="memory_limit" value="-1" />
1313
<server name="KERNEL_DIR" value="tests/Fixtures/app/" />
1414
<server name="KERNEL_CLASS" value="AppKernel" />
15+
<server name="LEGACY" value="0" />
1516
</php>
1617

1718
<testsuites>

src/Bridge/Doctrine/Orm/AbstractPaginator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public function __construct(DoctrinePaginator $paginator)
4646
*/
4747
public function getCurrentPage(): float
4848
{
49+
if (0 >= $this->maxResults) {
50+
return 1.;
51+
}
52+
4953
return floor($this->firstResult / $this->maxResults) + 1.;
5054
}
5155

tests/Fixtures/app/AppKernel.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,31 @@ class AppKernel extends Kernel
4040

4141
public function registerBundles(): array
4242
{
43-
return [
43+
$bundles = [
4444
new FrameworkBundle(),
4545
new TwigBundle(),
4646
new DoctrineBundle(),
4747
new SensioFrameworkExtraBundle(),
4848
new ApiPlatformBundle(),
4949
new SecurityBundle(),
5050
new FOSUserBundle(),
51-
new NelmioApiDocBundle(),
5251
new TestBundle(),
5352
];
53+
54+
if ($_SERVER['LEGACY'] ?? true) {
55+
$bundles[] = new NelmioApiDocBundle();
56+
}
57+
58+
return $bundles;
5459
}
5560

5661
protected function configureRoutes(RouteCollectionBuilder $routes)
5762
{
5863
$routes->import('config/routing.yml');
64+
65+
if ($_SERVER['LEGACY'] ?? true) {
66+
$routes->import('@NelmioApiDocBundle/Resources/config/routing.yml', '/nelmioapidoc');
67+
}
5968
}
6069

6170
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
@@ -110,7 +119,22 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
110119
if (method_exists(ContextListener::class, 'setLogoutOnUserChange')) {
111120
$securityConfig['firewalls']['default']['logout_on_user_change'] = true;
112121
}
113-
114122
$c->loadFromExtension('security', $securityConfig);
123+
124+
if ($_SERVER['LEGACY'] ?? true) {
125+
$c->loadFromExtension('nelmio_api_doc', [
126+
'sandbox' => [
127+
'accept_type' => 'application/json',
128+
'body_format' => [
129+
'formats' => ['json'],
130+
'default_format' => 'json',
131+
],
132+
'request_format' => [
133+
'formats' => ['json' => 'application/json'],
134+
],
135+
],
136+
]);
137+
$c->loadFromExtension('api_platform', ['enable_nelmio_api_doc' => true]);
138+
}
115139
}
116140
}

tests/Fixtures/app/config/config_test.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ api_platform:
4747
client_items_per_page: true
4848
client_partial: true
4949
items_per_page: 3
50-
enable_nelmio_api_doc: true
5150
exception_to_status:
5251
Symfony\Component\Serializer\Exception\ExceptionInterface: 400
5352
ApiPlatform\Core\Exception\InvalidArgumentException: 400
@@ -71,16 +70,6 @@ fos_user:
7170
address: '[email protected]'
7271
sender_name: 'Kévin Dunglas'
7372

74-
nelmio_api_doc:
75-
sandbox:
76-
accept_type: 'application/json'
77-
body_format:
78-
formats: [ 'json' ]
79-
default_format: 'json'
80-
request_format:
81-
formats:
82-
json: 'application/json'
83-
8473
parameters:
8574
container.autowiring.strict_mode: true
8675
container.dumper.inline_class_loader: true

tests/Fixtures/app/config/routing.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ api:
22
resource: '.'
33
type: 'api_platform'
44

5-
NelmioApiDocBundle:
6-
resource: '@NelmioApiDocBundle/Resources/config/routing.yml'
7-
prefix: '/nelmioapidoc'
8-
95
relation_embedded.custom_get:
106
path: '/relation_embedders/{id}/custom'
117
methods: ['GET', 'HEAD']

0 commit comments

Comments
 (0)