-
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.
Merge pull request #173 from elliotchance/1.4/173-is-a-boolean
? is a boolean
- Loading branch information
Showing
6 changed files
with
117 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
class IsABoolean extends AbstractMatcher | ||
{ | ||
public function supportedSyntaxes() | ||
{ | ||
return array( | ||
'? is a boolean' => 'Assert a value is true or false.', | ||
'? is a bool' => 'Assert a value is true or false.', | ||
); | ||
} | ||
|
||
public function match($syntax, array $data = array()) | ||
{ | ||
return is_bool($data[0]); | ||
} | ||
|
||
public function getTags() | ||
{ | ||
return array(Tag::BOOLEANS); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
class IsNotABoolean extends IsABoolean | ||
{ | ||
public function supportedSyntaxes() | ||
{ | ||
return array( | ||
'? is not a boolean' => 'Assert a value is not true or false.', | ||
'? is not a bool' => 'Assert a value is not true or false.', | ||
); | ||
} | ||
|
||
public function match($syntax, array $data = array()) | ||
{ | ||
return !parent::match(null, $data); | ||
} | ||
|
||
public function getTags() | ||
{ | ||
return array(Tag::BOOLEANS); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
class IsABooleanTest extends AbstractMatcherTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->matcher = new IsABoolean(); | ||
} | ||
|
||
public function testTrueIsABoolean() | ||
{ | ||
$this->assert(true, is_a_boolean); | ||
} | ||
|
||
public function testAStringIsNotABoolean() | ||
{ | ||
$this->assertFailure("true", is_a_boolean); | ||
} | ||
|
||
public function testFalseIsABoolean() | ||
{ | ||
$this->assert(false, is_a_boolean); | ||
} | ||
|
||
public function testAlternativeShorterSyntax() | ||
{ | ||
$this->assert(true, is_a_bool); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
class IsNotABooleanTest extends AbstractMatcherTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->matcher = new IsNotABoolean(); | ||
} | ||
|
||
public function testTrueIsABoolean() | ||
{ | ||
$this->assertFailure(true, is_not_a_boolean); | ||
} | ||
|
||
public function testAStringIsNotABoolean() | ||
{ | ||
$this->assert("true", is_not_a_boolean); | ||
} | ||
|
||
public function testFalseIsABoolean() | ||
{ | ||
$this->assertFailure(false, is_not_a_boolean); | ||
} | ||
|
||
public function testAlternativeShorterSyntax() | ||
{ | ||
$this->assertFailure(true, is_not_a_bool); | ||
} | ||
} |
Submodule wiki
updated
from 2a4976 to a241f9