Skip to content

Commit

Permalink
Add tests on the debug bar/profiler view (api-platform#2314)
Browse files Browse the repository at this point in the history
* Add tests on the debug bar/profiler view

update tests to support lowest dependencies

Avoid deprecation errors when booting kernel with NelmioApiDocBundle (try to fix appveyor)

* Adapt tests for MongoDB
  • Loading branch information
antograssiot authored and alanpoulain committed Feb 12, 2019
1 parent 39f74f2 commit 9d54687
Show file tree
Hide file tree
Showing 12 changed files with 372 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
env: NO_UNIT_TESTS=true
before_install:
- composer remove --dev ext-mongodb doctrine/mongodb-odm doctrine/mongodb-odm-bundle
- sed -i '26,32d' tests/Fixtures/app/config/config_common.yml
- sed -i '33,39d' tests/Fixtures/app/config/config_common.yml
- php: '7.2'
- php: '7.3'
- php: '7.3'
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ services:
test_script:
- cd %APPVEYOR_BUILD_FOLDER%
- php vendor\behat\behat\bin\behat --format=progress --suite=default
- rmdir tests\Fixtures\app\var\cache /s /q
- php vendor\phpunit\phpunit\phpunit
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@
"symfony/cache": "^3.4 || ^4.0",
"symfony/config": "^3.4 || ^4.0",
"symfony/console": "^3.4 || ^4.0",
"symfony/css-selector": "^3.4 || ^4.0",
"symfony/debug": "^3.4 || ^4.0",
"symfony/dependency-injection": "^3.4 || ^4.0",
"symfony/doctrine-bridge": "^3.4 || ^4.0",
"symfony/dom-crawler": "^3.4 || ^4.0",
"symfony/event-dispatcher": "^3.4 || ^4.0",
"symfony/expression-language": "^3.4 || ^4.0",
"symfony/finder": "^3.4 || ^4.0",
Expand All @@ -72,7 +74,7 @@
"symfony/security-bundle": "^3.4 || ^4.0",
"symfony/twig-bundle": "^3.4 || ^4.0",
"symfony/validator": "^3.4 || ^4.0",
"symfony/web-profiler-bundle": "^3.4 || ^4.0",
"symfony/web-profiler-bundle": "^4.2",
"symfony/yaml": "^3.4 || ^4.0",
"webonyx/graphql-php": ">=0.13 <1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@
</tr>
{% endmacro %}

{% macro operationTable(object, name, actualOperationName) %}
{% import _self as apiPlatform %}
<table>
<thead>
<tr>
<th scope="col" class="key">{{- name|capitalize }} operations</th>
<th scope="col">Attributes</th>
</tr>
</thead>

<tbody>
{% for key, itemOperation in object %}
{{ apiPlatform.operationLine(key, itemOperation, actualOperationName) }}
{% else %}
<tr>
<td colspan="2" class="text-muted">
No available {{ name|lower }} operation for this resource.
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endmacro %}

{% macro providerTable(object, name) %}
{% if object.responses is empty %}
<div class="empty">
Expand Down Expand Up @@ -99,56 +123,13 @@
<h3 class="tab-title">Resource Metadata</h3>
<div class="tab-content">
<h3>Short name: "{{ collector.resourceMetadata.shortName }}"</h3>
{{ apiPlatform.operationTable(collector.resourceMetadata.itemOperations, 'item', collector.requestAttributes.item_operation_name|default('')) }}
{{ apiPlatform.operationTable(collector.resourceMetadata.collectionOperations, 'collection', collector.requestAttributes.collection_operation_name|default('')) }}
<table>
<thead>
<tr>
<th scope="col" class="key">
Item operations
</th>
<th scope="col">
Attributes
</th>
</tr>
</thead>

<tbody>
{% for key, itemOperation in collector.resourceMetadata.itemOperations %}
{{ apiPlatform.operationLine(key, itemOperation, collector.requestAttributes.item_operation_name|default('')) }}
{% endfor %}
</tbody>
</table>

<table>
<thead>
<tr>
<th scope="col" class="key">
Collection operations
</th>
<th scope="col">
Attributes
</th>
</tr>
</thead>

<tbody>
{% for key, collectionOperation in collector.resourceMetadata.collectionOperations %}
{{ apiPlatform.operationLine(key, collectionOperation, collector.requestAttributes.collection_operation_name|default('')) }}
{% else %}
<tr>
<td colspan="2" class="text-muted">
No available collection operation for this resource.
</td>
</tr>
{% endfor %}
</tbody>
</table>

<table>
<thead>
<tr>
<th scope="col">
Filters
</th>
<th scope="col" class="key">Filters</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -177,22 +158,16 @@
<table>
<thead>
<tr>
<th scope="col" class="key">
Attributes
</th>
<th scope="col" class="key">Attributes</th>
<th scope="col"></th>
</tr>
</thead>

<tbody>
{% for key, value in collector.resourceMetadata.attributes if key != 'filters' %}
<tr>
<th scope="row">
{{ key }}
</th>
<td>
{{- profiler_dump(value, 2) -}}
</td>
<th scope="row">{{ key }}</th>
<td>{{- profiler_dump(value, 2) -}}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Loading

0 comments on commit 9d54687

Please sign in to comment.