本文整理汇总了PHP中PHPUnit_Util_InvalidArgumentHelper类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_InvalidArgumentHelper类的具体用法?PHP PHPUnit_Util_InvalidArgumentHelper怎么用?PHP PHPUnit_Util_InvalidArgumentHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_Util_InvalidArgumentHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extendsOrImplements
/**
* Creates and returns an ExtendsOrImplements constraint.
*
* @param string[] $parentsAndInterfaces
*
* @return ExtendsOrImplements
* @throws \PHPUnit_Framework_Exception
*/
public static function extendsOrImplements($parentsAndInterfaces)
{
if (!is_array($parentsAndInterfaces)) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'array or ArrayAccess');
}
return new ExtendsOrImplements($parentsAndInterfaces);
}
示例2: __construct
/**
* @param array|ArrayAccess $value
* @throws PHPUnit_Framework_Exception
*/
public function __construct($value)
{
if (!(is_array($value) || $value instanceof ArrayAccess)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'array or ArrayAccess');
}
$this->value = $value;
}
示例3: evaluate
/**
* @param \PHP\Manipulator\Tokenfinder\Result $other
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
* @return boolean
*/
public function evaluate($other, $description = '', $returnResult = FALSE)
{
if (!$other instanceof Result) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'PHP\\Manipulator\\Tokenfinder\\Result');
}
$expectedResultTokens = $this->_expectedResult->getTokens();
$actualResultTokens = $other->getTokens();
if (count($expectedResultTokens) != count($actualResultTokens)) {
$this->_cause = 'length';
if ($returnResult) {
return FALSE;
}
$this->fail($other, $description);
}
foreach ($expectedResultTokens as $key => $token) {
if ($token !== $actualResultTokens[$key]) {
$this->_cause = 'missmatch of token: ' . $key;
if ($returnResult) {
return FALSE;
}
$this->fail($other, $description);
}
}
return true;
}
示例4: setUseStderrRedirection
/**
* Defines if should use STDERR redirection or not.
*
* Then $stderrRedirection is TRUE, STDERR is redirected to STDOUT.
*
* @throws PHPUnit_Framework_Exception
*
* @param bool $stderrRedirection
*/
public function setUseStderrRedirection($stderrRedirection)
{
if (!is_bool($stderrRedirection)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean');
}
$this->stderrRedirection = $stderrRedirection;
}
示例5: matches
/** Checks the status code.
*
* @param Test_Browser $browser
*
* @throws InvalidArgumentException
* @return bool
*/
protected function matches($browser)
{
if (!$browser instanceof Test_Browser) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(0, 'Test_Browser');
}
return $this->_equal === in_array($browser->getResponse()->getStatusCode(), $this->_expected);
}
示例6: matches
/** Checks the status code.
*
* @param sfForm $form
*
* @return bool
*/
protected function matches($form)
{
if (!$form instanceof sfForm) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(0, 'Test_Browser');
}
return $form->isValid() == $this->_expected;
}
示例7: defaultAttributesValues
/**
* Creates and returns an DefaultAttributesValues constraint.
*
* @param array $defaultAttributes
*
* @return DefaultAttributesValues
* @throws \PHPUnit_Framework_Exception
*/
public static function defaultAttributesValues($defaultAttributes)
{
if (!is_array($defaultAttributes)) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'array or ArrayAccess');
}
return new DefaultAttributesValues($defaultAttributes);
}
示例8: __construct
/**
* Creates configuration constraint for config object
*
* @param Varien_Simplexml_Config $config
*/
public function __construct($constraint)
{
if (!$constraint instanceof Mage_PHPUnit_Constraint_Config_Interface) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'Mage_PHPUnit_Constraint_Config_Interface');
}
$this->constraint = $constraint;
}
示例9: setOs
public function setOs($os)
{
if (!is_string($os)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
}
$this->os = $os;
}
示例10: usesTraits
/**
* Creates and returns an UsesTraits constraint.
*
* @param string[] $traits
*
* @return UsesTraits
* @throws \PHPUnit_Framework_Exception
*/
public static function usesTraits($traits)
{
if (!is_array($traits)) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'array or ArrayAccess');
}
return new UsesTraits($traits);
}
示例11: __construct
/**
* Constraint for testing observer
* event definitions in configuration
*
* @param string $area
* @param string $eventName
* @param string $observerClassAlias
* @param string $observerMethod
* @param string|null $observerName
*/
public function __construct($area, $eventName, $observerClassAlias, $observerMethod, $type = self::TYPE_DEFINDED, $observerName = null)
{
if (empty($area) || !is_string($area)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string', $area);
}
if (empty($eventName) || !is_string($eventName)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string', $eventName);
}
if (empty($observerClassAlias) || !is_string($observerClassAlias)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'string', $observerClassAlias);
}
if (empty($observerMethod) || !is_string($observerMethod)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(4, 'string', $observerMethod);
}
if ($observerName !== null && !is_string($observerName)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(6, 'string', $observerName);
}
$this->_area = $area;
$this->_eventName = $eventName;
$this->_observerClassAlias = $observerClassAlias;
$this->_observerMethod = $observerMethod;
$this->_observerName = $observerName;
$expectedValue = $this->_observerClassAlias . '::' . $this->_observerMethod;
$nodePath = sprintf(self::XML_PATH_EVENTS, $this->_area, $this->_eventName);
parent::__construct($nodePath, $type, $expectedValue);
}
示例12: regExp
public static function regExp($pattern)
{
if (!is_string($pattern)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
}
return new PHPUnit_Framework_Constraint_PCREMatch($pattern);
}
示例13: evaluate
/**
* @param \PHP\Manipulator\Token $other
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
* @return boolean
*/
public function evaluate($other, $description = '', $returnResult = FALSE)
{
if (!$other instanceof Token) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'PHP\\Manipulator\\Token');
}
$expectedToken = $this->_expectedToken;
$equal = $this->_getEqualsConstraint($expectedToken->getValue());
if (!$equal->evaluate($other->getValue(), $description, true)) {
$this->_difference = 'values';
if ($returnResult) {
return FALSE;
}
$this->fail($other, $description);
}
$equal = $this->_getEqualsConstraint($expectedToken->getType());
if (!$equal->evaluate($other->getType(), $description, true)) {
$this->_difference = 'types';
if ($returnResult) {
return FALSE;
}
$this->fail($other, $description);
}
if (true === $this->_strict) {
$equal = $this->_getEqualsConstraint($expectedToken->getLinenumber());
if (!$equal->evaluate($other->getLinenumber(), $description, true)) {
$this->_difference = 'linenumber';
if ($returnResult) {
return FALSE;
}
$this->fail($other, $description);
}
}
return true;
}
示例14: evaluate
/**
* @param \PHP\Manipulator\TokenContainer $other
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
* @return boolean
*/
public function evaluate($other, $description = '', $returnResult = FALSE)
{
if (!$other instanceof TokenContainer) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'PHP\\Manipulator\\TokenContainer');
}
$expectedIterator = $this->_expectedContainer->getIterator();
$actualIterator = $other->getIterator();
$i = 0;
while ($expectedIterator->valid() && $actualIterator->valid()) {
$expectedToken = $expectedIterator->current();
/* @var $expectedToken PHP\Manipulator\Token */
$actualToken = $actualIterator->current();
/* @var $actualToken PHP\Manipulator\Token */
if (!$actualToken->equals($expectedToken, $this->_strict)) {
if ($returnResult) {
return FALSE;
}
$this->fail($other, $description);
}
$i++;
$expectedIterator->next();
$actualIterator->next();
}
if ($expectedIterator->valid() || $actualIterator->valid()) {
if ($returnResult) {
return FALSE;
}
$this->fail($other, $description);
}
return true;
}
示例15: __construct
/**
* Constraint constructor
*
* @param string $nodePath
* @param string $type
* @param mixed $expectedValue
* @throws PHPUnit_Framework_Exception
*/
public function __construct($nodePath, $type, $expectedValue = null)
{
if (empty($nodePath) || !is_string($nodePath)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string', $type);
}
$this->_nodePath = $nodePath;
parent::__construct($type, $expectedValue);
}