mirror of
https://github.com/Respect/Validation.git
synced 2024-06-08 08:42:15 +02:00
Validator composite structure and tests, base for new Validators
This commit is contained in:
parent
736caac8ac
commit
2043c1129c
0
README.rdoc
Normal file
0
README.rdoc
Normal file
40
library/Respect/Validation/InvalidException.php
Normal file
40
library/Respect/Validation/InvalidException.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Respect\Validation;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Exception;
|
||||
|
||||
class InvalidException extends InvalidArgumentException
|
||||
{
|
||||
|
||||
protected $exceptions = array();
|
||||
|
||||
public function __construct($spec)
|
||||
{
|
||||
if (is_string($spec)) {
|
||||
$message = $spec;
|
||||
} elseif (is_array($spec)) {
|
||||
$messages = array();
|
||||
foreach ($spec as $m) {
|
||||
if ($m instanceof Exception) {
|
||||
$messages[] = $m->getMessage();
|
||||
$this->addException($m);
|
||||
}
|
||||
}
|
||||
$message = implode(PHP_EOL, $messages);
|
||||
}
|
||||
parent::__construct($message);
|
||||
}
|
||||
|
||||
protected function addException($e)
|
||||
{
|
||||
$this->exceptions[] = $e;
|
||||
}
|
||||
|
||||
public function getExceptions()
|
||||
{
|
||||
return $this->exceptions;
|
||||
}
|
||||
|
||||
}
|
15
library/Respect/Validation/Validatable.php
Normal file
15
library/Respect/Validation/Validatable.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Respect\Validation;
|
||||
|
||||
interface Validatable
|
||||
{
|
||||
|
||||
public function validate($input);
|
||||
|
||||
public function isValid($input);
|
||||
|
||||
public function getMessages();
|
||||
|
||||
public function setMessages(array $messages);
|
||||
}
|
157
library/Respect/Validation/Validator.php
Normal file
157
library/Respect/Validation/Validator.php
Normal file
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
namespace Respect\Validation;
|
||||
|
||||
use OutOfRangeException;
|
||||
use LogicException;
|
||||
use ReflectionClass;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class Validator implements Validatable
|
||||
{
|
||||
|
||||
protected $validators = array();
|
||||
protected $messages = array();
|
||||
|
||||
protected function appendValidator(Validatable $validator)
|
||||
{
|
||||
$this->validators[spl_object_hash($validator)] = $validator;
|
||||
$this->messages = array_merge(
|
||||
$this->messages, $validator->getMessages()
|
||||
);
|
||||
}
|
||||
|
||||
public function addValidator($validator, $arguments=array())
|
||||
{
|
||||
if ($validator instanceof Validatable) {
|
||||
$this->appendValidator($validator);
|
||||
return;
|
||||
}
|
||||
if (is_object($validator))
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('%s does not implement the Respect\Validator\Validatable interface required for validators', get_class($validator))
|
||||
);
|
||||
$validatorFqn = explode('\\', get_called_class());
|
||||
array_pop($validatorFqn);
|
||||
$validatorFqn = array_merge($validatorFqn, explode('\\', $validator));
|
||||
$validatorFqn = implode('\\', $validatorFqn);
|
||||
$validatorClass = new ReflectionClass($validatorFqn);
|
||||
$implementedInterface = $validatorClass->implementsInterface(
|
||||
'Respect\Validation\Validatable'
|
||||
);
|
||||
if (!$implementedInterface)
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('%s does not implement the Respect\Validator\Validatable interface required for validators', $validatorFqn)
|
||||
);
|
||||
if ($validatorClass->hasMethod('__construct')) {
|
||||
$validatorInstance = $validatorClass->newInstanceArgs(
|
||||
$arguments
|
||||
);
|
||||
} else {
|
||||
$validatorInstance = new $validatorFqn;
|
||||
}
|
||||
$this->appendValidator($validatorInstance);
|
||||
}
|
||||
|
||||
public function hasValidator($validator)
|
||||
{
|
||||
if ($validator instanceof Valitatable)
|
||||
return isset($this->validators[spl_object_hash($validator)]);
|
||||
else
|
||||
return (boolean) array_filter(
|
||||
$this->validators, function($v) use ($validator) {
|
||||
return (integer) ($v instanceof $validator);
|
||||
});
|
||||
}
|
||||
|
||||
public function addValidators(array $validators)
|
||||
{
|
||||
foreach ($validators as $k => $v) {
|
||||
if (is_object($v)) {
|
||||
$this->addValidator($v);
|
||||
} elseif (is_numeric($k)) {
|
||||
$validatorName = $v;
|
||||
$validatorArgs = array();
|
||||
} else {
|
||||
$validatorName = $k;
|
||||
if (!empty($v) && !is_array($v))
|
||||
throw new LogicException(
|
||||
sprintf(
|
||||
'Arguments for array-specified validators must be an array, you provided %s', $v
|
||||
)
|
||||
);
|
||||
$validatorArgs = empty($v) ? array() : $v;
|
||||
}
|
||||
$this->addValidator($validatorName, $validatorArgs);
|
||||
}
|
||||
}
|
||||
|
||||
public function getValidators()
|
||||
{
|
||||
return $this->validators;
|
||||
}
|
||||
|
||||
protected function iterateValidation($input)
|
||||
{
|
||||
$validators = $this->getValidators();
|
||||
$exceptions = array();
|
||||
foreach ($validators as $v)
|
||||
try {
|
||||
$v->validate($input);
|
||||
} catch (InvalidException $e) {
|
||||
$exceptions[] = $e;
|
||||
}
|
||||
return $exceptions;
|
||||
}
|
||||
|
||||
public function validate($input)
|
||||
{
|
||||
$exceptions = $this->iterateValidation($input);
|
||||
if (!empty($exceptions))
|
||||
throw new InvalidException($exceptions);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validateOne($input)
|
||||
{
|
||||
$validators = $this->getValidators();
|
||||
$exceptions = $this->iterateValidation($input);
|
||||
if (count($exceptions) === count($validators))
|
||||
throw new InvalidException($exceptions);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isValid($input)
|
||||
{
|
||||
$validators = $this->getValidators();
|
||||
return count($validators) === count(array_filter(
|
||||
$validators, function($v) use($input) {
|
||||
return $v->isValid($input);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
public function isOneValid($input)
|
||||
{
|
||||
return (boolean) array_filter(
|
||||
$this->getValidators(), function($v) use($input) {
|
||||
return $v->isValid($input);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function getMessages()
|
||||
{
|
||||
return $this->messages;
|
||||
}
|
||||
|
||||
public function setMessages(array $messages)
|
||||
{
|
||||
if (count($this->messages) != count($messages))
|
||||
throw new OutOfRangeException(
|
||||
'You must set exactly the same amount of messages currently present in the validator'
|
||||
);
|
||||
$this->messages = $messages;
|
||||
}
|
||||
|
||||
}
|
136
library/SplClassLoader.php
Normal file
136
library/SplClassLoader.php
Normal file
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SplClassLoader implementation that implements the technical interoperability
|
||||
* standards for PHP 5.3 namespaces and class names.
|
||||
*
|
||||
* http://groups.google.com/group/php-standards/web/final-proposal
|
||||
*
|
||||
* // Example which loads classes for the Doctrine Common package in the
|
||||
* // Doctrine\Common namespace.
|
||||
* $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine');
|
||||
* $classLoader->register();
|
||||
*
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @author Roman S. Borschel <roman@code-factory.org>
|
||||
* @author Matthew Weier O'Phinney <matthew@zend.com>
|
||||
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.org>
|
||||
*/
|
||||
class SplClassLoader
|
||||
{
|
||||
private $_fileExtension = '.php';
|
||||
private $_namespace;
|
||||
private $_includePath;
|
||||
private $_namespaceSeparator = '\\';
|
||||
|
||||
/**
|
||||
* Creates a new <tt>SplClassLoader</tt> that loads classes of the
|
||||
* specified namespace.
|
||||
*
|
||||
* @param string $ns The namespace to use.
|
||||
*/
|
||||
public function __construct($ns = null, $includePath = null)
|
||||
{
|
||||
$this->_namespace = $ns;
|
||||
$this->_includePath = $includePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the namespace separator used by classes in the namespace of this class loader.
|
||||
*
|
||||
* @param string $sep The separator to use.
|
||||
*/
|
||||
public function setNamespaceSeparator($sep)
|
||||
{
|
||||
$this->_namespaceSeparator = $sep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the namespace seperator used by classes in the namespace of this class loader.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getNamespaceSeparator()
|
||||
{
|
||||
return $this->_namespaceSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base include path for all class files in the namespace of this class loader.
|
||||
*
|
||||
* @param string $includePath
|
||||
*/
|
||||
public function setIncludePath($includePath)
|
||||
{
|
||||
$this->_includePath = $includePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base include path for all class files in the namespace of this class loader.
|
||||
*
|
||||
* @return string $includePath
|
||||
*/
|
||||
public function getIncludePath()
|
||||
{
|
||||
return $this->_includePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file extension of class files in the namespace of this class loader.
|
||||
*
|
||||
* @param string $fileExtension
|
||||
*/
|
||||
public function setFileExtension($fileExtension)
|
||||
{
|
||||
$this->_fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file extension of class files in the namespace of this class loader.
|
||||
*
|
||||
* @return string $fileExtension
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
return $this->_fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs this class loader on the SPL autoload stack.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls this class loader from the SPL autoloader stack.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $className The name of the class to load.
|
||||
* @return void
|
||||
*/
|
||||
public function loadClass($className)
|
||||
{
|
||||
if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
|
||||
$fileName = '';
|
||||
$namespace = '';
|
||||
if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
|
||||
$namespace = substr($className, 0, $lastNsPos);
|
||||
$className = substr($className, $lastNsPos + 1);
|
||||
$fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
|
||||
|
||||
require ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
|
||||
}
|
||||
}
|
||||
}
|
6
tests/bootstrap.php
Normal file
6
tests/bootstrap.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../library/');
|
||||
require_once 'SplClassLoader.php';
|
||||
$respectLoader = new \SplClassLoader();
|
||||
$respectLoader->register();
|
314
tests/library/Respect/Validation/ValidatorTest.php
Normal file
314
tests/library/Respect/Validation/ValidatorTest.php
Normal file
|
@ -0,0 +1,314 @@
|
|||
<?php
|
||||
|
||||
namespace Respect\Validation;
|
||||
|
||||
use Mockery;
|
||||
|
||||
class ValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
protected $object;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
|
||||
$this->object = new Validator;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function buildMockValidator($name, array $messages, $invalid=false)
|
||||
{
|
||||
$validator = Mockery::mock('Respect\Validation\Validatable');
|
||||
if ($invalid) {
|
||||
$validator->shouldReceive('validate')->andThrow(
|
||||
new InvalidException('Always invalid, man.')
|
||||
);
|
||||
$validator->shouldReceive('isValid')->andReturn(false);
|
||||
} else {
|
||||
$validator->shouldReceive('isValid')->andReturn(true);
|
||||
$validator->shouldReceive('validate')->andReturn(true);
|
||||
}
|
||||
$validator->shouldReceive('getMessages')->andReturn(
|
||||
$messages
|
||||
);
|
||||
$className = 'Respect\Validation\Foo\\' . $name;
|
||||
if (!class_exists($className, false)) {
|
||||
eval("
|
||||
namespace Respect\Validation\Foo;
|
||||
class $name implements \Respect\Validation\Validatable {
|
||||
public function validate(\$input) {}
|
||||
public function isValid(\$input) {}
|
||||
public function setMessages(array \$messages) {}
|
||||
public function getMessages() {
|
||||
return " . var_export($messages, true) . ";
|
||||
}
|
||||
}
|
||||
");
|
||||
}
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
public function providerForMockImpossibleValidators()
|
||||
{
|
||||
$firstValidator = $this->buildMockValidator(
|
||||
'Bar', array('sfga', 'dfgb'), true
|
||||
);
|
||||
$secondValidator = $this->buildMockValidator(
|
||||
'Baz', array('dgd', 'dfgE', 'dfgf'), true
|
||||
);
|
||||
$thirdValidator = $this->buildMockValidator(
|
||||
'Bat', array('a34t'), true
|
||||
);
|
||||
return array(
|
||||
array($firstValidator, $secondValidator, $thirdValidator),
|
||||
array($secondValidator, $firstValidator, $thirdValidator),
|
||||
array($thirdValidator, $secondValidator, $firstValidator)
|
||||
);
|
||||
}
|
||||
|
||||
public function providerForMockValidators()
|
||||
{
|
||||
$firstValidator = $this->buildMockValidator(
|
||||
'Bar', array('a435', 'b345'), false
|
||||
);
|
||||
$secondValidator = $this->buildMockValidator(
|
||||
'Baz', array('345d', '435E', 'f345'), false
|
||||
);
|
||||
$thirdValidator = $this->buildMockValidator(
|
||||
'Bat', array('345324a'), false
|
||||
);
|
||||
return array(
|
||||
array($firstValidator, $secondValidator, $thirdValidator),
|
||||
array($secondValidator, $firstValidator, $thirdValidator),
|
||||
array($thirdValidator, $secondValidator, $firstValidator)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testAddExistentValidator($validator)
|
||||
{
|
||||
$this->object->addValidator($validator);
|
||||
$this->assertContains($validator, $this->object->getValidators());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testAddNonValidator()
|
||||
{
|
||||
$this->object->addValidator(new \stdClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testAddNonValidator2()
|
||||
{
|
||||
if (!class_exists('Respect\Validation\Foo\Freak', false)) {
|
||||
eval("
|
||||
namespace Respect\Validation\Foo;
|
||||
class Freak{}
|
||||
");
|
||||
}
|
||||
$this->object->addValidator('Foo\Freak');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testAddValidatorsMessages($a, $b)
|
||||
{
|
||||
$messagesA = $a->getMessages();
|
||||
$messagesB = $b->getMessages();
|
||||
$this->object->addValidator($a);
|
||||
$this->object->addValidator($b);
|
||||
$messagesObject = $this->object->getMessages();
|
||||
foreach ($messagesA as $m) {
|
||||
$this->assertContains($m, $messagesObject);
|
||||
}
|
||||
foreach ($messagesB as $m) {
|
||||
$this->assertContains($m, $messagesObject);
|
||||
}
|
||||
}
|
||||
|
||||
public function testBuildValidators()
|
||||
{
|
||||
$this->providerForMockImpossibleValidators();
|
||||
$this->object->addValidators(array(
|
||||
'Foo\Bar', 'Foo\Baz', 'Foo\Bat' => array(1, 2, 3)
|
||||
));
|
||||
$this->assertTrue($this->object->hasValidator('Respect\Validation\Foo\Bar'));
|
||||
$this->assertTrue($this->object->hasValidator('Respect\Validation\Foo\Baz'));
|
||||
$this->assertTrue($this->object->hasValidator('Respect\Validation\Foo\Bat'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException LogicException
|
||||
*/
|
||||
public function testBuildValidatorsInvalid()
|
||||
{
|
||||
$this->providerForMockImpossibleValidators();
|
||||
$this->object->addValidators(array(
|
||||
'Foo\Bar', 'Foo\Baz', 'Foo\Bat' => 'balkbal'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockValidators
|
||||
*/
|
||||
public function testValidateManyValid($a, $b, $c)
|
||||
{
|
||||
$this->object->addValidator($a);
|
||||
$this->object->addValidator($b);
|
||||
$this->object->addValidator($c);
|
||||
$this->assertTrue($this->object->validate('any'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockValidators
|
||||
*/
|
||||
public function testManyIsValid($a, $b, $c)
|
||||
{
|
||||
$this->object->addValidator($a);
|
||||
$this->object->addValidator($b);
|
||||
$this->object->addValidator($c);
|
||||
$this->assertTrue($this->object->isValid('any'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testManyIsInvalid($a, $b, $c)
|
||||
{
|
||||
$this->object->addValidator($a);
|
||||
$this->object->addValidator($b);
|
||||
$this->object->addValidator($c);
|
||||
$this->assertFalse($this->object->isValid('any'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testManyIsInvalid2($a, $b, $c)
|
||||
{
|
||||
$this->object->addValidator($a);
|
||||
$this->object->addValidator($b);
|
||||
$this->object->addValidator($c);
|
||||
$this->object->addValidator(
|
||||
$this->buildMockValidator('Aids', array('ergera'))
|
||||
);
|
||||
$this->assertFalse($this->object->isValid('any'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testValidateAllInvalid($a, $b, $c)
|
||||
{
|
||||
$this->object->addValidator($a);
|
||||
$this->object->addValidator($b);
|
||||
$this->object->addValidator($c);
|
||||
try {
|
||||
$this->object->validate('any');
|
||||
} catch (InvalidException $e) {
|
||||
$this->assertEquals(3, count($e->getExceptions()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testValidateOneValid($invalidA, $invalidB, $invalidC)
|
||||
{
|
||||
$valid = $this->buildMockValidator('Darth', array('o54n'));
|
||||
$this->object->addValidator($invalidA);
|
||||
$this->object->addValidator($invalidB);
|
||||
$this->object->addValidator($invalidC);
|
||||
$this->object->addValidator($valid);
|
||||
$this->assertTrue($this->object->validateOne('any'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testValidateOneAllRotten($invalidA, $invalidB, $invalidC)
|
||||
{
|
||||
$this->object->addValidator($invalidA);
|
||||
$this->object->addValidator($invalidB);
|
||||
$this->object->addValidator($invalidC);
|
||||
try {
|
||||
$this->object->validateOne('any');
|
||||
} catch (InvalidException $e) {
|
||||
$this->assertEquals(3, count($e->getExceptions()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testIsValidOneValid($invalidA, $invalidB, $invalidC)
|
||||
{
|
||||
$valid = $this->buildMockValidator('Darth', array('o54n'));
|
||||
$this->object->addValidator($invalidA);
|
||||
$this->object->addValidator($invalidB);
|
||||
$this->object->addValidator($invalidC);
|
||||
$this->object->addValidator($valid);
|
||||
$this->assertTrue($this->object->isOneValid('any'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testIsValidOneAllRotten($invalidA, $invalidB, $invalidC)
|
||||
{
|
||||
$this->object->addValidator($invalidA);
|
||||
$this->object->addValidator($invalidB);
|
||||
$this->object->addValidator($invalidC);
|
||||
$this->assertFalse($this->object->isOneValid('any'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
*/
|
||||
public function testSetMessages($a, $b)
|
||||
{
|
||||
$messagesA = $a->getMessages();
|
||||
$messagesB = $b->getMessages();
|
||||
$this->object->addValidator($a);
|
||||
$this->object->addValidator($b);
|
||||
$this->object->setMessages(
|
||||
array_map('strrev', $this->object->getMessages())
|
||||
);
|
||||
$messagesObject = $this->object->getMessages();
|
||||
foreach ($messagesA as $m) {
|
||||
$this->assertContains(strrev($m), $messagesObject);
|
||||
}
|
||||
foreach ($messagesB as $m) {
|
||||
$this->assertContains(strrev($m), $messagesObject);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForMockImpossibleValidators
|
||||
* @expectedException OutOfRangeException
|
||||
*/
|
||||
public function testSetInvalidMessages($invalidA, $invalidB, $invalidC)
|
||||
{
|
||||
$this->object->addValidator($invalidA);
|
||||
$this->object->addValidator($invalidB);
|
||||
$this->object->addValidator($invalidC);
|
||||
$messages = $this->object->getMessages();
|
||||
$messages = array_map('strrev', $messages);
|
||||
array_pop($messages);
|
||||
$this->object->setMessages($messages);
|
||||
$this->assertEquals($messages, $this->object->getMessages());
|
||||
}
|
||||
|
||||
}
|
12
tests/phpunit.xml
Normal file
12
tests/phpunit.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="true"
|
||||
bootstrap="bootstrap.php"
|
||||
colors="false"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader">
|
||||
</phpunit>
|
Loading…
Reference in a new issue