mirror of
https://github.com/Respect/Validation.git
synced 2024-06-29 02:30:06 +02:00
Create integration tests for "KeyValue" rule
This commit is contained in:
parent
5dc5410617
commit
16ad8f804d
16
tests/integration/keyValue-1.phpt
Normal file
16
tests/integration/keyValue-1.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
$data = array(
|
||||
'password' => 'shuberry',
|
||||
'password_confirmation' => 'shuberry',
|
||||
'valid_passwords' => array('shuberry', 'monty-python')
|
||||
);
|
||||
|
||||
v::keyValue('password', 'equals', 'password_confirmation')->check($data);
|
||||
v::keyValue('password', 'in', 'valid_passwords')->assert($data);
|
||||
?>
|
||||
--EXPECTF--
|
20
tests/integration/keyValue-2.phpt
Normal file
20
tests/integration/keyValue-2.phpt
Normal file
|
@ -0,0 +1,20 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Exceptions\EqualsException;
|
||||
|
||||
$data = array(
|
||||
'password' => 'shuberry',
|
||||
'password_confirmation' => '_shuberry_'
|
||||
);
|
||||
|
||||
try {
|
||||
v::keyValue('password', 'equals', 'password_confirmation')->check($data);
|
||||
} catch (EqualsException $e) {
|
||||
echo $e->getMainMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
password must be equals "password_confirmation"
|
19
tests/integration/keyValue-3.phpt
Normal file
19
tests/integration/keyValue-3.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
|
||||
$data = array(
|
||||
'password' => 'shazam',
|
||||
'password_confirmation' => 'batman'
|
||||
);
|
||||
|
||||
try {
|
||||
v::keyValue('password', 'equals', 'password_confirmation')->assert($data);
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getMainMessage();
|
||||
}
|
||||
--EXPECTF--
|
||||
All of the required rules must pass for { "password": "shazam", "password_confirmation": "batman" }
|
19
tests/integration/keyValue-4.phpt
Normal file
19
tests/integration/keyValue-4.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Exceptions\KeyValuException;
|
||||
|
||||
$data = array(
|
||||
'password' => '123',
|
||||
'invalid_passwords' => array('123', 'secreta')
|
||||
);
|
||||
|
||||
try {
|
||||
v::not(v::keyValue('password', 'in', 'invalid_passwords'))->check($data);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMainMessage();
|
||||
}
|
||||
--EXPECTF--
|
||||
Key { "password": "123", "invalid_passwords": { "123", "secreta" } } must not be present
|
19
tests/integration/keyValue-5.phpt
Normal file
19
tests/integration/keyValue-5.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
|
||||
$data = array(
|
||||
'password' => '123',
|
||||
'invalid_passwords' => array('123', 'secreta')
|
||||
);
|
||||
|
||||
try {
|
||||
v::not(v::keyValue('password', 'in', 'invalid_passwords'))->assert($data);
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
--EXPECTF--
|
||||
\-Key { "password": "123", "invalid_passwords": { "123", "secreta" } } must not be present
|
Loading…
Reference in a new issue