Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 Doctrine/Orm/Filter/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function apply(ResourceInterface $resource, QueryBuilder $queryBuilder, R

$nullManagement = isset($this->properties[$property]) ? $this->properties[$property] : null;

if (isset($values[self::PARAMETER_BEFORE])) {
if (!empty($values[self::PARAMETER_BEFORE])) {
$this->addWhere(
$queryBuilder,
$alias,
Expand All @@ -87,7 +87,7 @@ public function apply(ResourceInterface $resource, QueryBuilder $queryBuilder, R
);
}

if (isset($values[self::PARAMETER_AFTER])) {
if (!empty($values[self::PARAMETER_AFTER])) {
$this->addWhere(
$queryBuilder,
$alias,
Expand Down
68 changes: 68 additions & 0 deletions features/doctrine/date-filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,71 @@ Feature: Order filter on collections
}
}
"""

@createSchema
@dropSchema
Scenario: Search for entities within a range
Given there is "2" dummy objects with dummyDate
When I send a "GET" request to "/dummies?dummyDate[after]="
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"
And the JSON node "hydra:totalItems" should be equal to "2"
And the JSON should be valid according to this schema:
"""
{
"type": "object",
"properties": {
"@context": {"pattern": "^/contexts/Dummy$"},
"@id": {"pattern": "^/dummies\\?dummyDate\\[after\\]=$"},
"@type": {"pattern": "^hydra:PagedCollection$"},
"hydra:totalItems": {"type":"number"},
"hydra:member": {
"type": "array",
"items": {
"type": "object",
"properties": {
"@id": {
"oneOf": [
{"pattern": "^/dummies/1$"},
{"pattern": "^/dummies/2$"}
]
}
}
}
}
}
}
"""

When I send a "GET" request to "/dummies?dummyDate[before]="
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"
And the JSON node "hydra:totalItems" should be equal to "2"
And the JSON should be valid according to this schema:
"""
{
"type": "object",
"properties": {
"@context": {"pattern": "^/contexts/Dummy$"},
"@id": {"pattern": "^/dummies\\?dummyDate\\[before\\]=$"},
"@type": {"pattern": "^hydra:PagedCollection$"},
"hydra:totalItems": {"type":"number"},
"hydra:member": {
"type": "array",
"items": {
"type": "object",
"properties": {
"@id": {
"oneOf": [
{"pattern": "^/dummies/1$"},
{"pattern": "^/dummies/2$"}
]
}
}
}
}
}
}
"""