-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Subfilter support #156
Open
harikt
wants to merge
9
commits into
auraphp:4.x
Choose a base branch
from
harikt:multi
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c9afe8c
Maximum support upto 2
harikt 93ab9f7
If empty pass empty array
harikt 46df5ac
Fix return type
koriym 1c01718
Merge pull request #1 from koriym/multi
harikt 1983539
Rename subfilter to subFilter
koriym 0c1143e
Split the workflow
koriym 2f454ee
Add phpdoc type
koriym 3bc7698
Merge pull request #2 from koriym/refactor
harikt f287106
Update tests/Spec/SubspecTest.php
harikt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
namespace Aura\Filter\Spec; | ||
|
||
use Aura\Filter\FilterFactory; | ||
use Aura\Filter\SubjectFilter; | ||
use Yoast\PHPUnitPolyfills\TestCases\TestCase; | ||
|
||
class SubspecTest extends TestCase | ||
{ | ||
/** @var SubjectFilter */ | ||
protected $filter; | ||
|
||
protected function set_up() | ||
{ | ||
$filter_factory = new FilterFactory(); | ||
$this->filter = $filter_factory->newSubjectFilter(); | ||
} | ||
|
||
public function testMultidimensionalSupport() | ||
{ | ||
$data = [ | ||
'id' => 'asd', | ||
'user' => [ | ||
'name' => 'Foo', | ||
'age' => 'asd', | ||
], | ||
// 'url' => 'http://example.com' | ||
]; | ||
|
||
$this->filter->validate('id')->is('int'); | ||
$this->filter->validate('url')->is('url'); | ||
|
||
$user_spec = $this->filter->subFilter('user'); // add a "SubSpec" | ||
$user_filter = $user_spec->filter(); // Get the "SubSpec" SubjectFilter | ||
|
||
$user_filter->validate('given-name')->isNotBlank(); | ||
$user_filter->validate('age')->is('int'); | ||
$user_filter->validate('gender')->is('strlen', 1); | ||
|
||
$subject = (object) $data; | ||
$result = $this->filter->apply($subject); | ||
$this->assertFalse($result); | ||
$expect = [ | ||
'id' => [ | ||
'id should have validated as int' | ||
], | ||
'url' => [ | ||
'url should have validated as url', | ||
], | ||
'user' => [ | ||
'given-name' => [ | ||
'given-name should not have been blank', | ||
], | ||
'age' => [ | ||
'age should have validated as int' | ||
], | ||
'gender' => [ | ||
'gender should have validated as strlen(1)' | ||
] | ||
] | ||
]; | ||
$actual = $this->filter->getFailures()->getMessages(); | ||
$this->assertSame($expect, $actual); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one place I dislike.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is return void sufficient? The caller does not use the return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier it was returning the Failure. As it currently changed this now can return Failure or FailureCollection. ie why return is removed. I will look once again if this returned value has some value inside the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is to add a failure. It seems no return value is needed.