Skip to content

Commit

Permalink
Merge pull request #8 from chadicus/develop
Browse files Browse the repository at this point in the history
allow date string for modifiedSince paramter
  • Loading branch information
chadicus committed Jul 30, 2015
2 parents 072c13a + 3487085 commit e66facb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Entities/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public static function findAll(Client $client, array $criteria = [])
{
$filters = [
'name' => [['string']],
'modifiedSince' => [['uint']],
'modifiedSince' => [['date']],
'comics' => [['ofScalars', [['uint']]], ['implode', ',']],
'series' => [['ofScalars', [['uint']]], ['implode', ',']],
'events' => [['ofScalars', [['uint']]], ['implode', ',']],
Expand All @@ -266,7 +266,7 @@ public static function findAll(Client $client, array $criteria = [])

$modifiedSince = Arrays::get($filteredCriteria, 'modifiedSince');
if ($modifiedSince !== null) {
$filteredCriteria['modifiedSince'] = date('c', $modifiedSince);
$filteredCriteria['modifiedSince'] = $modifiedSince->format('c');
}

return new Collection(
Expand Down
5 changes: 3 additions & 2 deletions tests/Entities/CharacterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ public function findAll()
*/
public function findAllParametersSetProperly()
{
$now = new \DateTime();
$criteria = [
'name' => 'a name',
'modifiedSince' => \time(),
'modifiedSince' => $now->format('r'),
'comics' => [1,2,3],
'series' => [2,4,6],
'events' => [1,3,5],
Expand All @@ -169,7 +170,7 @@ public function findAllParametersSetProperly()

$expectedParameters = [
'name' => 'a name',
'modifiedSince' => date('c', $criteria['modifiedSince']),
'modifiedSince' => $now->format('c'),
'comics' => '1,2,3',
'series' => '2,4,6',
'events' => '1,3,5',
Expand Down

0 comments on commit e66facb

Please # to comment.