-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from rakit/58-fix-unexpected-get-valid-data
Fixes #58
- Loading branch information
Showing
5 changed files
with
127 additions
and
28 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ public function testRequiredUploadedFile() | |
$validation = $this->validator->validate([ | ||
'file' => $empty_file | ||
], [ | ||
'file' => 'required|uploaded_file' | ||
'file' => 'required|uploaded_file' | ||
]); | ||
|
||
$errors = $validation->errors(); | ||
|
@@ -97,20 +97,20 @@ public function testOptionalUploadedFile() | |
$validation = $this->validator->validate([ | ||
'file' => $empty_file | ||
], [ | ||
'file' => 'uploaded_file' | ||
'file' => 'uploaded_file' | ||
]); | ||
$this->assertTrue($validation->passes()); | ||
} | ||
|
||
/** | ||
* @dataProvider getSamplesMissingKeyFromUploadedFileValue | ||
*/ | ||
*/ | ||
public function testMissingKeyUploadedFile($uploaded_file) | ||
{ | ||
$validation = $this->validator->validate([ | ||
'file' => $uploaded_file | ||
], [ | ||
'file' => 'required|uploaded_file' | ||
'file' => 'required|uploaded_file' | ||
]); | ||
|
||
$errors = $validation->errors(); | ||
|
@@ -335,7 +335,7 @@ public function testAfterRule() | |
|
||
$this->assertFalse($validator2->passes()); | ||
} | ||
|
||
public function testNewValidationRuleCanBeAdded() | ||
{ | ||
|
||
|
@@ -735,7 +735,7 @@ public function testUsingDefaults() | |
'is_enabled' => '1', | ||
'is_published' => 'invalid-value' | ||
]); | ||
|
||
// Getting only valid data | ||
$validData = $validation->getValidData(); | ||
$this->assertEquals($validData, [ | ||
|
@@ -914,13 +914,22 @@ public function testGetValidData() | |
'something', | ||
'[email protected]' | ||
], | ||
'stuffs' => [ | ||
'one' => '1', | ||
'two' => '2', | ||
'three' => 'three', | ||
], | ||
'thing' => 'exists', | ||
], [ | ||
'thing' => 'required', | ||
'items.*.product_id' => 'required|numeric', | ||
'emails.*' => 'required|email', | ||
'items.*.qty' => 'required|numeric', | ||
'something' => 'default:on|required|in:on,off' | ||
'something' => 'default:on|required|in:on,off', | ||
'stuffs' => 'required|array', | ||
'stuffs.one' => 'required|numeric', | ||
'stuffs.two' => 'required|numeric', | ||
'stuffs.three' => 'required|numeric', | ||
]); | ||
|
||
$validData = $validation->getValidData(); | ||
|
@@ -936,8 +945,15 @@ public function testGetValidData() | |
2 => '[email protected]' | ||
], | ||
'thing' => 'exists', | ||
'something' => 'on' | ||
'something' => 'on', | ||
'stuffs' => [ | ||
'one' => '1', | ||
'two' => '2', | ||
] | ||
], $validData); | ||
|
||
$stuffs = $validData['stuffs']; | ||
$this->assertFalse(isset($stuffs['three'])); | ||
} | ||
|
||
public function testGetInvalidData() | ||
|
@@ -954,13 +970,22 @@ public function testGetInvalidData() | |
'something', | ||
'[email protected]' | ||
], | ||
'stuffs' => [ | ||
'one' => '1', | ||
'two' => '2', | ||
'three' => 'three', | ||
], | ||
'thing' => 'exists', | ||
], [ | ||
'thing' => 'required', | ||
'items.*.product_id' => 'required|numeric', | ||
'emails.*' => 'required|email', | ||
'items.*.qty' => 'required|numeric', | ||
'something' => 'required|in:on,off' | ||
'something' => 'required|in:on,off', | ||
'stuffs' => 'required|array', | ||
'stuffs.one' => 'numeric', | ||
'stuffs.two' => 'numeric', | ||
'stuffs.three' => 'numeric', | ||
]); | ||
|
||
$invalidData = $validation->getInvalidData(); | ||
|
@@ -974,8 +999,15 @@ public function testGetInvalidData() | |
'emails' => [ | ||
1 => 'something' | ||
], | ||
'something' => null | ||
'something' => null, | ||
'stuffs' => [ | ||
'three' => 'three', | ||
] | ||
], $invalidData); | ||
|
||
$stuffs = $invalidData['stuffs']; | ||
$this->assertFalse(isset($stuffs['one'])); | ||
$this->assertFalse(isset($stuffs['two'])); | ||
} | ||
|
||
} |