Skip to content

Commit f3d3ec7

Browse files
committed
Closes #47
1 parent 23adc81 commit f3d3ec7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

tests/Extensions/Issue47/CustomResourceObject.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace Neomerx\Tests\JsonApi\Extensions\Issue47;
22

3+
use \InvalidArgumentException;
34
use \Neomerx\JsonApi\Schema\ResourceObject;
45

56
/**
@@ -31,7 +32,29 @@ public function getAttributes()
3132
$filter = $this->attributeKeysFilter;
3233
$attributes = $this->schema->getAttributes($this->resource);
3334

34-
// TODO implement filtering $attributes with $filter
35+
// in real app here should come filtering however for testing it's ok to make sure we have
36+
// - attributes
37+
// - filter params
38+
// - if we return correct result it will be delivered to to invoking test
39+
40+
// check we have received attribute filter
41+
$filterEquals = ($filter === ['private.email' => 0]);
42+
if ($filterEquals === false) {
43+
throw new InvalidArgumentException();
44+
}
45+
46+
// check we have received attributes
47+
$attributesEqual = ($attributes === [
48+
'username' => 'vivalacrowe',
49+
'private' => [
50+
'email' => '[email protected]',
51+
'name' => 'Rob',
52+
],
53+
]);
54+
if ($attributesEqual === false) {
55+
throw new InvalidArgumentException();
56+
}
57+
3558
return ['private' => ['email' => '[email protected]']];
3659
}
3760
}

tests/Extensions/Issue47/IssueTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testFilterNestedAttributes()
3636
])->encode($user, null, null, new EncodingParameters(
3737
null,
3838
[
39-
'users' => ['private.email']
39+
'users' => ['private.email'],
4040
]
4141
));
4242

0 commit comments

Comments
 (0)