-
Notifications
You must be signed in to change notification settings - Fork 0
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 #20 from assertis/date_list
DateList object introduced
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Assertis\Util; | ||
|
||
/** | ||
* @author Rafał Orłowski <[email protected]> | ||
*/ | ||
class DateList extends ObjectList | ||
{ | ||
|
||
/** | ||
* Return true if the value is acceptable for this list. Typically something like: | ||
* return $value instanceof MyClass | ||
* | ||
* @param mixed $value | ||
* @return boolean | ||
*/ | ||
public function accepts($value) | ||
{ | ||
return $value instanceof Date; | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace Assertis\Util; | ||
|
||
use Assertis\Util\DateList; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
/** | ||
* @author Rafał Orłowski <[email protected]> | ||
*/ | ||
class DateListTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testAccept() | ||
{ | ||
$dateList = new DateList(); | ||
$this->assertTrue($dateList->accepts(new Date("2016-10-10"))); | ||
$this->assertFalse($dateList->accepts("2016-10-10")); | ||
} | ||
|
||
} |