You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @link http://www.yiiframework.com/
|
|
|
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
|
|
|
* @license http://www.yiiframework.com/license/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace yiiunit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IsOneOfAssert asserts that the value is one of the expected values.
|
|
|
|
*/
|
|
|
|
class IsOneOfAssert extends \PHPUnit\Framework\Constraint\Constraint
|
|
|
|
{
|
|
|
|
private $allowedValues;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IsOneOfAssert constructor.
|
|
|
|
* @param array $allowedValues
|
|
|
|
*/
|
|
|
|
public function __construct(array $allowedValues)
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->allowedValues = $allowedValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a string representation of the object.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function toString()
|
|
|
|
{
|
|
|
|
$expectedAsString = "'" . implode("', '", $this->allowedValues) . "'";
|
|
|
|
return "is one of $expectedAsString";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
protected function matches($other)
|
|
|
|
{
|
|
|
|
return in_array($other, $this->allowedValues, false);
|
|
|
|
}
|
|
|
|
}
|