-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Equals to | ||
|
||
This asserter validates if the given data matches the given value. | ||
|
||
You can use the "equals to" asserter as `To::beEqualsTo($value)`. |
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,5 @@ | ||
# Like | ||
|
||
This asserter validates if the given data matches the given value without ensuring both values have the same type. | ||
|
||
You can use the "like" asserter as `To::beLike($value)`. |
33 changes: 33 additions & 0 deletions
33
spec/Extension/ConstraintsExtension/EqualsToAsserterSpec.php
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,33 @@ | ||
<?php | ||
|
||
namespace spec\carlosV2\Can\Extension\ConstraintsExtension; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
|
||
class EqualsToAsserterSpec extends ObjectBehavior | ||
{ | ||
function let() | ||
{ | ||
$this->beConstructedWith('123'); | ||
} | ||
|
||
function it_is_an_Asserter() | ||
{ | ||
$this->shouldHaveType('carlosV2\Can\AsserterInterface'); | ||
} | ||
|
||
function it_returns_true_if_both_values_are_equals() | ||
{ | ||
$this->check('123')->shouldReturn(true); | ||
} | ||
|
||
function it_returns_false_if_the_values_are_equals_but_have_different_type() | ||
{ | ||
$this->check(123)->shouldReturn(false); | ||
} | ||
|
||
function it_returns_false_if_the_values_are_not_equals() | ||
{ | ||
$this->check('321')->shouldReturn(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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace spec\carlosV2\Can\Extension\ConstraintsExtension; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
|
||
class LikeAsserterSpec extends ObjectBehavior | ||
{ | ||
function let() | ||
{ | ||
$this->beConstructedWith('123'); | ||
} | ||
|
||
function it_is_an_Asserter() | ||
{ | ||
$this->shouldHaveType('carlosV2\Can\AsserterInterface'); | ||
} | ||
|
||
function it_returns_true_if_both_values_are_equals() | ||
{ | ||
$this->check('123')->shouldReturn(true); | ||
} | ||
|
||
function it_returns_true_if_the_values_are_equals_but_have_different_type() | ||
{ | ||
$this->check(123)->shouldReturn(true); | ||
} | ||
|
||
function it_returns_false_if_the_values_are_not_equals() | ||
{ | ||
$this->check('321')->shouldReturn(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
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,29 @@ | ||
<?php | ||
|
||
namespace carlosV2\Can\Extension\ConstraintsExtension; | ||
|
||
use carlosV2\Can\AsserterInterface; | ||
|
||
class EqualsToAsserter implements AsserterInterface | ||
{ | ||
/** | ||
* @var mixed | ||
*/ | ||
private $value; | ||
|
||
/** | ||
* @param mixed $value | ||
*/ | ||
public function __construct($value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function check($data) | ||
{ | ||
return $data === $this->value; | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace carlosV2\Can\Extension\ConstraintsExtension; | ||
|
||
use carlosV2\Can\AsserterInterface; | ||
|
||
class LikeAsserter implements AsserterInterface | ||
{ | ||
/** | ||
* @var mixed | ||
*/ | ||
private $value; | ||
|
||
/** | ||
* @param mixed $value | ||
*/ | ||
public function __construct($value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function check($data) | ||
{ | ||
return $data == $this->value; | ||
} | ||
} |
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