-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move trim type constants to TrimParser, add tests for all trim types,…
… remove TrimType
- Loading branch information
Yuval Herziger
committed
Feb 17, 2017
1 parent
2d21825
commit c5b1e15
Showing
5 changed files
with
25 additions
and
18 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -14,7 +14,6 @@ | |
use MPScholten\RequestParser\StringParser; | ||
use MPScholten\RequestParser\EmailParser; | ||
use MPScholten\RequestParser\UrlParser; | ||
use MPScholten\RequestParser\TrimType; | ||
use MPScholten\RequestParser\TrimParser; | ||
|
||
class ParserSpecTest extends \PHPUnit_Framework_TestCase | ||
|
@@ -47,7 +46,9 @@ public function specWithValueAndDefaultValue() | |
[new StringParser(new Config(), 'name', 'quintly'), '', 'quintly'], | ||
[new UrlParser(new Config(), 'referrer', 'https://www.quintly.com/'), 'https://www.quintly.com/blog/', 'https://www.quintly.com/'], | ||
[new EmailParser(new Config(), 'emailAddress', '[email protected]'), '', '[email protected]'], | ||
[new TrimParser(new Config(), 'emailAddress', ' [email protected] ', TrimType::TRIM), '', '[email protected]'], | ||
[new TrimParser(new Config(), 'emailAddress', ' [email protected] ', TrimParser::TRIM), '', '[email protected]'], | ||
[new TrimParser(new Config(), 'emailAddress', ' [email protected]', TrimParser::LEFT_TRIM), '', '[email protected]'], | ||
[new TrimParser(new Config(), 'emailAddress', '[email protected] ', TrimParser::RIGHT_TRIM), '', '[email protected]'], | ||
[new OneOfParser(new Config(), 'type', 'a', ['a', 'b']), 'b', 'a'], | ||
[new DateTimeParser(new Config(), 'createdAt', '2015-02-02'), new \DateTime('2015-01-01'), new \DateTime('2015-02-02')], | ||
[new JsonParser(new Config(), 'config', '{"value":false}'), ['value' => true], ['value' => false]] | ||
|
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 |
---|---|---|
|
@@ -64,6 +64,18 @@ public function testTrim() | |
$this->assertInstanceOf(TrimParser::class, $spec->string()->trim()); | ||
} | ||
|
||
public function testLeftTrim() | ||
{ | ||
$spec = new TypeParser(new Config(), 'emailAddress', ' [email protected]'); | ||
$this->assertInstanceOf(TrimParser::class, $spec->string()->leftTrim()); | ||
} | ||
|
||
public function testRightTrim() | ||
{ | ||
$spec = new TypeParser(new Config(), 'emailAddress', '[email protected] '); | ||
$this->assertInstanceOf(TrimParser::class, $spec->string()->rightTrim()); | ||
} | ||
|
||
public function testOneOf() | ||
{ | ||
$spec = new TypeParser(new Config(), 'type', 'b'); | ||
|