Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added argument matchers: Not, AnyOf and NotAnyOf
- Loading branch information
Padraic Brady
committed
May 21, 2010
1 parent
a18387c
commit 5e1dde8
Showing
5 changed files
with
289 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
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,63 @@ | ||
<?php | ||
/** | ||
* Mockery | ||
* | ||
* LICENSE | ||
* | ||
* This source file is subject to the new BSD license that is bundled | ||
* with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://github.com/padraic/mockery/blob/master/LICENSE | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to padraic@php.net so we can send you a copy immediately. | ||
* | ||
* @category Mockery | ||
* @package Mockery | ||
* @copyright Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com) | ||
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License | ||
*/ | ||
|
||
namespace Mockery\Matcher; | ||
|
||
class AnyOf extends MatcherAbstract | ||
{ | ||
|
||
/** | ||
* Set the expected value | ||
* | ||
* @param mixed $expected | ||
*/ | ||
public function __construct($expected = null) | ||
{ | ||
$this->_expected = $expected; | ||
} | ||
|
||
/** | ||
* Check if the actual value does not match the expected (in this | ||
* case it's specifically NOT expected). | ||
* | ||
* @param mixed $actual | ||
* @return bool | ||
*/ | ||
public function match($actual) | ||
{ | ||
foreach ($this->_expected as $exp) { | ||
if ($actual === $exp || $actual == $exp) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Return a string representation of this Matcher | ||
* | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
return '<AnyOf>'; | ||
} | ||
|
||
} |
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,48 @@ | ||
<?php | ||
/** | ||
* Mockery | ||
* | ||
* LICENSE | ||
* | ||
* This source file is subject to the new BSD license that is bundled | ||
* with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://github.com/padraic/mockery/blob/master/LICENSE | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to padraic@php.net so we can send you a copy immediately. | ||
* | ||
* @category Mockery | ||
* @package Mockery | ||
* @copyright Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com) | ||
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License | ||
*/ | ||
|
||
namespace Mockery\Matcher; | ||
|
||
class Not extends MatcherAbstract | ||
{ | ||
|
||
/** | ||
* Check if the actual value does not match the expected (in this | ||
* case it's specifically NOT expected). | ||
* | ||
* @param mixed $actual | ||
* @return bool | ||
*/ | ||
public function match($actual) | ||
{ | ||
return $actual !== $this->_expected; | ||
} | ||
|
||
/** | ||
* Return a string representation of this Matcher | ||
* | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
return '<Not>'; | ||
} | ||
|
||
} |
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,63 @@ | ||
<?php | ||
/** | ||
* Mockery | ||
* | ||
* LICENSE | ||
* | ||
* This source file is subject to the new BSD license that is bundled | ||
* with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://github.com/padraic/mockery/blob/master/LICENSE | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to padraic@php.net so we can send you a copy immediately. | ||
* | ||
* @category Mockery | ||
* @package Mockery | ||
* @copyright Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com) | ||
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License | ||
*/ | ||
|
||
namespace Mockery\Matcher; | ||
|
||
class NotAnyOf extends MatcherAbstract | ||
{ | ||
|
||
/** | ||
* Set the expected value | ||
* | ||
* @param mixed $expected | ||
*/ | ||
public function __construct($expected = null) | ||
{ | ||
$this->_expected = $expected; | ||
} | ||
|
||
/** | ||
* Check if the actual value does not match the expected (in this | ||
* case it's specifically NOT expected). | ||
* | ||
* @param mixed $actual | ||
* @return bool | ||
*/ | ||
public function match($actual) | ||
{ | ||
foreach ($this->_expected as $exp) { | ||
if ($actual === $exp || $actual == $exp) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Return a string representation of this Matcher | ||
* | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
return '<AnyOf>'; | ||
} | ||
|
||
} |
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