Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ac65ba1
fix OneToOne bidirectional + unitTest WIP
Nightbr Oct 23, 2018
a6cd704
php-cs-fixer + add subresource to dummyEntity
Nightbr Oct 23, 2018
9f47142
add behat tests
Nightbr Oct 23, 2018
c061263
target dummy entity fix
Nightbr Oct 23, 2018
937e197
fix behat
Nightbr Oct 23, 2018
44278d5
fix unitTest + cs-fixer
Nightbr Oct 23, 2018
57be23c
fix context
Nightbr Oct 23, 2018
245dcda
fix Dummy name require
Nightbr Oct 23, 2018
2fdf109
fix payload for behat test
Nightbr Oct 23, 2018
6f1640c
fix broken test
Nightbr Oct 23, 2018
f146925
fix codeReview
Nightbr Oct 23, 2018
6280bce
fix code review2
Nightbr Oct 23, 2018
d2f699d
ApiPlatformExtension cleanup
dunglas Oct 23, 2018
968966e
Remove a now useless composer hack
dunglas Oct 23, 2018
483cbec
Merge pull request #2269 from dunglas/extension-cleanup
dunglas Oct 25, 2018
c569c0f
Merge pull request #2270 from dunglas/httpfoundation-dev
dunglas Oct 25, 2018
b36ca90
remove unset attributes key in normalization context
ArnoudThibaut Oct 10, 2018
d2cfbbc
Add tests on doctrine collection purge
antograssiot Oct 27, 2018
2b51e14
Fix 2285 - force Yaml::dump to dump empty array as actual empty array
Cethy Oct 28, 2018
81a50f5
Merge pull request #2284 from antograssiot/collection-purge
soyuka Oct 29, 2018
7af3d0d
Merge pull request #2286 from Cethy/2.3
dunglas Oct 29, 2018
91e5bb2
Merge pull request #2279 from ArnoudThibaut/fix-removing-attributes-k…
dunglas Oct 29, 2018
ce3258b
improve graphiql CSS
ginifizz Oct 30, 2018
6c0e55c
Prefix root resource route_prefix to sub-resources
silverbackdan Oct 30, 2018
66d6a98
Bump PHPStan analysis to level 6 (#2272)
antograssiot Oct 30, 2018
60433b3
Merge branch '2.3'
dunglas Oct 30, 2018
7dd3ccd
Bump PHPStan analysis to level 6
antograssiot Oct 24, 2018
549214a
Merge pull request #2273 from antograssiot/phpstan-level6-master
soyuka Oct 31, 2018
a46fd26
allow to use multiple values with NumericFilter
ArnoudThibaut Oct 12, 2018
6a0c10a
Deprecate dead code in QueryJoinParser and remove internal usage
antograssiot Oct 23, 2018
d76ac70
Add a non regression test for #2285 #2286
antograssiot Oct 30, 2018
d43c383
Merge pull request #2292 from ginifizz/master
dunglas Oct 31, 2018
3b41b80
Merge pull request #2294 from silverbackdan/patch/subresource-route-p…
dunglas Nov 1, 2018
647cafe
Merge pull request #2291 from antograssiot/non-regression-test
dunglas Nov 1, 2018
d3e3733
Ability to modify response headers (mainly cache related headers) (#2…
silverbackdan Nov 1, 2018
77da03e
Merge pull request #2271 from antograssiot/queryJoinParser-cleanup
dunglas Nov 1, 2018
d5c9d0b
Add data providers and data persisters matches to the debug panel (#2…
antograssiot Nov 1, 2018
c24b677
Merge branch '2.3'
dunglas Nov 1, 2018
9161117
Merge pull request #2277 from ArnoudThibaut/allow-numeric-filter-to-f…
soyuka Nov 2, 2018
3e4818b
Allow multiple order filters in entity.
Oct 3, 2018
dce8367
Merge pull request #2230 from Siregacvek/multiple-order-filters
soyuka Nov 2, 2018
fc17efc
remove Goto
Nightbr Nov 2, 2018
cb5421a
Allow an input and an output for a given resource class
soyuka Oct 4, 2018
060a895
Merge pull request #2268 from MoltenCoreIO/fix-oneToOneBidirectional
soyuka Nov 2, 2018
4f12b21
Merge pull request #2235 from soyuka/feat-input-output
dunglas Nov 2, 2018
a282c75
[Bugfix] Remove type Error
antograssiot Nov 3, 2018
413f594
Merge pull request #2307 from antograssiot/fix-fatal-in-debugbar
soyuka Nov 5, 2018
7e9655a
Merge branch '2.3'
dunglas Nov 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
name: Run PHPStan
command: |-
export PATH="$PATH:$HOME/.composer/vendor/bin"
phpstan analyse -c phpstan.neon -l5 --ansi src tests
phpstan analyse -c phpstan.neon -l6 --ansi src tests

phpunit-coverage:
docker:
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
mkdir -p build/logs/tmp build/cov
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature' | circleci tests split --split-by=timings); do
_f=${f//\//_}
FEATURE="${_f}" phpdbg -qrr vendor/bin/behat --profile=coverage --suite=default --tags=~@postgres --format=progress --out=std --format=junit --out=build/logs/tmp/"${_f}" "$f"
FEATURE="${_f}" phpdbg -qrr vendor/bin/behat --profile=coverage --suite=default --format=progress --out=std --format=junit --out=build/logs/tmp/"${_f}" "$f"
done
- run:
name: Merge Behat test reports
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ script:
vendor/bin/behat --suite=default --format=progress;
fi
- tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json
- tests/Fixtures/app/console api:swagger:export --yaml > swagger.yaml && npx swagger-cli validate --no-schema swagger.yaml && rm swagger.yaml
- tests/Fixtures/app/console api:swagger:export --yaml > swagger.yaml && npx swagger-cli validate swagger.yaml && rm swagger.yaml
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
"willdurand/negotiation": "^2.0.3"
},
"require-dev": {
"symfony/http-foundation": "^3.1@dev || ^4.0@dev",

"behat/behat": "^3.1",
"behat/mink": "^1.7",
"behat/mink-browserkit-driver": "^1.3.1",
Expand Down
34 changes: 34 additions & 0 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Question;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RamseyUuidDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedOwnedDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedOwningDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedToDummyFriend;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelationEmbedder;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\SecuredDummy;
Expand Down Expand Up @@ -1007,6 +1009,38 @@ public function thereIsADummyObjectWithAFourthLevelRelation()
$this->manager->flush();
}

/**
* @Given there is a RelatedOwnedDummy object with OneToOne relation
*/
public function thereIsARelatedOwnedDummy()
{
$relatedOwnedDummy = new RelatedOwnedDummy();
$this->manager->persist($relatedOwnedDummy);

$dummy = new Dummy();
$dummy->setName('plop');
$dummy->setRelatedOwnedDummy($relatedOwnedDummy);
$this->manager->persist($dummy);

$this->manager->flush();
}

/**
* @Given there is a RelatedOwningDummy object with OneToOne relation
*/
public function thereIsARelatedOwningDummy()
{
$dummy = new Dummy();
$dummy->setName('plop');
$this->manager->persist($dummy);

$relatedOwningDummy = new RelatedOwningDummy();
$relatedOwningDummy->setOwnedDummy($dummy);
$this->manager->persist($relatedOwningDummy);

$this->manager->flush();
}

/**
* @Given there is a person named :name greeting with a :message message
*/
Expand Down
14 changes: 13 additions & 1 deletion features/doctrine/date_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ Feature: Date filter on collections
},
"hydra:search": {
"@type": "hydra:IriTemplate",
"hydra:template": "/dummies{?dummyBoolean,relatedDummy.embeddedDummy.dummyBoolean,dummyDate[before],dummyDate[strictly_before],dummyDate[after],dummyDate[strictly_after],relatedDummy.dummyDate[before],relatedDummy.dummyDate[strictly_before],relatedDummy.dummyDate[after],relatedDummy.dummyDate[strictly_after],description[exists],relatedDummy.name[exists],dummyBoolean[exists],relatedDummy[exists],dummyFloat,dummyPrice,order[id],order[name],order[description],order[relatedDummy.name],order[relatedDummy.symfony],order[dummyDate],dummyFloat[between],dummyFloat[gt],dummyFloat[gte],dummyFloat[lt],dummyFloat[lte],dummyPrice[between],dummyPrice[gt],dummyPrice[gte],dummyPrice[lt],dummyPrice[lte],id,id[],name,alias,description,relatedDummy.name,relatedDummy.name[],relatedDummies,relatedDummies[],dummy,relatedDummies.name,properties[]}",
"hydra:template": "/dummies{?dummyBoolean,relatedDummy.embeddedDummy.dummyBoolean,dummyDate[before],dummyDate[strictly_before],dummyDate[after],dummyDate[strictly_after],relatedDummy.dummyDate[before],relatedDummy.dummyDate[strictly_before],relatedDummy.dummyDate[after],relatedDummy.dummyDate[strictly_after],description[exists],relatedDummy.name[exists],dummyBoolean[exists],relatedDummy[exists],dummyFloat,dummyFloat[],dummyPrice,dummyPrice[],order[id],order[name],order[description],order[relatedDummy.name],order[relatedDummy.symfony],order[dummyDate],dummyFloat[between],dummyFloat[gt],dummyFloat[gte],dummyFloat[lt],dummyFloat[lte],dummyPrice[between],dummyPrice[gt],dummyPrice[gte],dummyPrice[lt],dummyPrice[lte],id,id[],name,alias,description,relatedDummy.name,relatedDummy.name[],relatedDummies,relatedDummies[],dummy,relatedDummies.name,properties[]}",
"hydra:variableRepresentation": "BasicRepresentation",
"hydra:mapping": [
{
Expand Down Expand Up @@ -497,12 +497,24 @@ Feature: Date filter on collections
"property": "dummyFloat",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyFloat[]",
"property": "dummyFloat",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyPrice",
"property": "dummyPrice",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyPrice[]",
"property": "dummyPrice",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "order[id]",
Expand Down
45 changes: 45 additions & 0 deletions features/doctrine/numeric_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,51 @@ Feature: Numeric filter on collections
}
"""

@createSchema
Scenario: Get collection by multiple dummyPrice
Given there are 10 dummy objects with dummyPrice
When I send a "GET" request to "/dummies?dummyPrice[]=9.99&dummyPrice[]=12.99"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And print last JSON response
And the JSON should be valid according to this schema:
"""
{
"type": "object",
"properties": {
"@context": {"pattern": "^/contexts/Dummy$"},
"@id": {"pattern": "^/dummies$"},
"@type": {"pattern": "^hydra:Collection$"},
"hydra:member": {
"type": "array",
"items": {
"type": "object",
"properties": {
"@id": {
"oneOf": [
{"pattern": "^/dummies/1$"},
{"pattern": "^/dummies/2$"},
{"pattern": "^/dummies/5$"}
]
}
}
},
"maxItems": 3,
"uniqueItems": true
},
"hydra:totalItems": {"pattern": "^6$"},
"hydra:view": {
"type": "object",
"properties": {
"@id": {"pattern": "^/dummies\\?dummyPrice%5B%5D=9.99&dummyPrice%5B%5D=12.99"},
"@type": {"pattern": "^hydra:PartialCollectionView$"}
}
}
}
}
"""

Scenario: Get collection by non-numeric dummyPrice=marty
Given there are 10 dummy objects with dummyPrice
When I send a "GET" request to "/dummies?dummyPrice=marty"
Expand Down
37 changes: 37 additions & 0 deletions features/http_cache/tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,40 @@ Feature: Cache invalidation through HTTP Cache tags
"""
Then the response status code should be 200
And "/relation1s,/relation1s/1,/relation2s/2,/relation2s/1" IRIs should be purged

Scenario: Create a Relation3 with many to many
When I add "Content-Type" header equal to "application/ld+json"
And I send a "POST" request to "/relation3s" with body:
"""
{
"relation2s": ["/relation2s/1", "/relation2s/2"]
}
"""
Then the response status code should be 201
And "/relation3s,/relation2s/1,/relation2s/2" IRIs should be purged

Scenario: Get a Relation3
When I add "Content-Type" header equal to "application/ld+json"
And I send a "GET" request to "/relation3s"
Then the response status code should be 200
And the header "Cache-Tags" should be equal to "/relation3s/1,/relation2s/1,/relation2s/2,/relation3s"

Scenario: Update a collection member only
When I add "Content-Type" header equal to "application/ld+json"
And I send a "PUT" request to "/relation3s/1" with body:
"""
{
"relation2s": ["/relation2s/2"]
}
"""
Then the response status code should be 200
And the header "Cache-Tags" should not exist
And "/relation3s,/relation3s/1,/relation2s/2,/relation2s,/relation2s/1" IRIs should be purged

Scenario: Delete the collection owner
When I add "Content-Type" header equal to "application/ld+json"
And I send a "DELETE" request to "/relation3s/1"
Then the response status code should be 204
And the header "Cache-Tags" should not exist
And "/relation3s,/relation3s/1,/relation2s/2" IRIs should be purged

14 changes: 13 additions & 1 deletion features/main/crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Feature: Create-Retrieve-Update-Delete
"hydra:totalItems": 1,
"hydra:search": {
"@type": "hydra:IriTemplate",
"hydra:template": "/dummies{?dummyBoolean,relatedDummy.embeddedDummy.dummyBoolean,dummyDate[before],dummyDate[strictly_before],dummyDate[after],dummyDate[strictly_after],relatedDummy.dummyDate[before],relatedDummy.dummyDate[strictly_before],relatedDummy.dummyDate[after],relatedDummy.dummyDate[strictly_after],description[exists],relatedDummy.name[exists],dummyBoolean[exists],relatedDummy[exists],dummyFloat,dummyPrice,order[id],order[name],order[description],order[relatedDummy.name],order[relatedDummy.symfony],order[dummyDate],dummyFloat[between],dummyFloat[gt],dummyFloat[gte],dummyFloat[lt],dummyFloat[lte],dummyPrice[between],dummyPrice[gt],dummyPrice[gte],dummyPrice[lt],dummyPrice[lte],id,id[],name,alias,description,relatedDummy.name,relatedDummy.name[],relatedDummies,relatedDummies[],dummy,relatedDummies.name,properties[]}",
"hydra:template": "/dummies{?dummyBoolean,relatedDummy.embeddedDummy.dummyBoolean,dummyDate[before],dummyDate[strictly_before],dummyDate[after],dummyDate[strictly_after],relatedDummy.dummyDate[before],relatedDummy.dummyDate[strictly_before],relatedDummy.dummyDate[after],relatedDummy.dummyDate[strictly_after],description[exists],relatedDummy.name[exists],dummyBoolean[exists],relatedDummy[exists],dummyFloat,dummyFloat[],dummyPrice,dummyPrice[],order[id],order[name],order[description],order[relatedDummy.name],order[relatedDummy.symfony],order[dummyDate],dummyFloat[between],dummyFloat[gt],dummyFloat[gte],dummyFloat[lt],dummyFloat[lte],dummyPrice[between],dummyPrice[gt],dummyPrice[gte],dummyPrice[lt],dummyPrice[lte],id,id[],name,alias,description,relatedDummy.name,relatedDummy.name[],relatedDummies,relatedDummies[],dummy,relatedDummies.name,properties[]}",
"hydra:variableRepresentation": "BasicRepresentation",
"hydra:mapping": [
{
Expand Down Expand Up @@ -230,12 +230,24 @@ Feature: Create-Retrieve-Update-Delete
"property": "dummyFloat",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyFloat[]",
"property": "dummyFloat",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyPrice",
"property": "dummyPrice",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyPrice[]",
"property": "dummyPrice",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "order[id]",
Expand Down
65 changes: 65 additions & 0 deletions features/main/subresource.feature
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,71 @@ Feature: Subresource support
}
"""


Scenario: The OneToOne subresource should be accessible from owned side
Given there is a RelatedOwnedDummy object with OneToOne relation
When I send a "GET" request to "/related_owned_dummies/1/owning_dummy"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
"""
{
"@context": "/contexts/Dummy",
"@id": "/dummies/3",
"@type": "Dummy",
"description": null,
"dummy": null,
"dummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
"relatedDummy": null,
"relatedDummies": [],
"jsonData": [],
"arrayData": [],
"name_converted": null,
"relatedOwnedDummy": "/related_owned_dummies/1",
"relatedOwningDummy": null,
"id": 3,
"name": "plop",
"alias": null,
"foo": null
}
"""

Scenario: The OneToOne subresource should be accessible from owning side
Given there is a RelatedOwningDummy object with OneToOne relation
When I send a "GET" request to "/related_owning_dummies/1/owned_dummy"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
"""
{
"@context": "/contexts/Dummy",
"@id": "/dummies/4",
"@type": "Dummy",
"description": null,
"dummy": null,
"dummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
"relatedDummy": null,
"relatedDummies": [],
"jsonData": [],
"arrayData": [],
"name_converted": null,
"relatedOwnedDummy": null,
"relatedOwningDummy": "/related_owning_dummies/1",
"id": 4,
"name": "plop",
"alias": null,
"foo": null
}
"""

@dropSchema
Scenario: Recursive resource
When I send a "GET" request to "/dummy_products/2"
Expand Down
7 changes: 5 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ parameters:
- '#Access to an undefined property object::\$isIdentifierComposite.#'
- '#Call to an undefined method Doctrine\\Common\\Persistence\\ObjectManager::getConnection\(\)#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::[a-zA-Z0-9_]+\(\)#'
- '#Call to an undefined method Prophecy\\Prophecy\\ObjectProphecy::[a-zA-Z0-9_]+\(\)#'
- '#Call to an undefined method Prophecy\\Prophecy\\ObjectProphecy(|.*)?::[a-zA-Z0-9_]+\(\)#'
- '#Method ApiPlatform\\Core\\Tests\\Bridge\\Doctrine\\Orm\\ItemDataProviderTest::getManagerRegistry\(\) should return Doctrine\\Common\\Persistence\\ManagerRegistry but returns object\.#'
- '#Method ApiPlatform\\Core\\Tests\\Bridge\\Doctrine\\Orm\\Util\\IdentifierManagerTraitTest::getObjectManager\(\) should return Doctrine\\Common\\Persistence\\ObjectManager but returns object\.#'
- '#Parameter \#1 \$function of function call_user_func expects callable, .+ given\.#'
- '#Parameter \#1 \$classes of class ApiPlatform\\Core\\Metadata\\Resource\\ResourceNameCollection constructor expects array<string>, array<int, int\|string> given\.#'
- '#Method ApiPlatform\\Core\\Util\\RequestParser::parseRequestParams\(\) should return array but returns array\|false\.#'
# Temporary fix while the PHPStan extension for Prophecy isn't compatible with 0.10
- '#Parameter .* expects .*, .*object.* given\.#'
- '#Parameter \#[0-9] \$filterLocator of class ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Extension\\FilterExtension constructor expects ApiPlatform\\Core\\Api\\FilterCollection|Psr\\Container\\ContainerInterface(\|null)?, ArrayObject given\.#'
Expand All @@ -25,7 +28,7 @@ parameters:
# https://github.com/doctrine/doctrine2/pull/7298/files
- '#Strict comparison using === between null and int will always evaluate to false\.#'
- '#Strict comparison using !== between null and null will always evaluate to false\.#'
- '#Class ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\DummyBis not found.#'
- '#Method ApiPlatform\\Core\\(Serializer\\Abstract|JsonApi\\Serializer\\)ItemNormalizer::normalizeRelation\(\) should return array\|string but returns array\|bool\|float\|int\|string\.#'

# Expected, due to deprecations
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Extension\\QueryResult(Item|Collection)ExtensionInterface::getResult\(\) invoked with 4 parameters, 1 required\.#'
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/ApiFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class ApiFilter
public $strategy;

/**
* @var string
* @var string|FilterInterface
*/
public $filterClass;

Expand Down
Loading