mirror of
https://github.com/Respect/Validation.git
synced 2024-06-09 01:02:16 +02:00
Unify integration tests
PHPT files are amazing, but they are also expensive to execute. Having just one single file running the necessary tests is best than having one file per test. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
d8f43589dc
commit
8bb49d8ab2
43
tests/integration/rules/identityCard.phpt
Normal file
43
tests/integration/rules/identityCard.phpt
Normal file
|
@ -0,0 +1,43 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
// declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\IdentityCardException;
|
||||
use Respect\Validation\Exceptions\Locale\PlIdentityCardException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::identityCard('PL')->check('AYE205411');
|
||||
} catch (PlIdentityCardException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::identityCard('PL'))->check('AYE205410');
|
||||
} catch (IdentityCardException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::identityCard('PL')->assert('AYE205411');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::identityCard('PL'))->assert('AYE205410');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"AYE205411" must be a valid Polish Identity Card number
|
||||
"AYE205410" must not be a valid Identity Card number for "PL"
|
||||
- "AYE205411" must be a valid Polish Identity Card number
|
||||
- "AYE205410" must not be a valid Identity Card number for "PL"
|
|
@ -1,15 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
v::identityCard('PL')->check('AYE205410');
|
||||
v::identityCard('PL')->assert('AYE205410');
|
||||
?>
|
||||
--EXPECT--
|
|
@ -1,20 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\Locale\PlIdentityCardException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::identityCard('PL')->check('AYE205411');
|
||||
} catch (PlIdentityCardException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"AYE205411" must be a valid Polish Identity Card number
|
|
@ -1,20 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::identityCard('PL')->assert('AYE205411');
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
- "AYE205411" must be a valid Polish Identity Card number
|
|
@ -1,20 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\IdentityCardException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::identityCard('PL'))->check('AYE205410');
|
||||
} catch (IdentityCardException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"AYE205410" must not be a valid Identity Card number for "PL"
|
|
@ -1,20 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::identityCard('PL'))->assert('AYE205410');
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
- "AYE205410" must not be a valid Identity Card number for "PL"
|
43
tests/integration/rules/nif.phpt
Normal file
43
tests/integration/rules/nif.phpt
Normal file
|
@ -0,0 +1,43 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
Julián Gutiérrez <juliangut@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\NifException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::nif()->check('06357771Q');
|
||||
} catch (NifException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::nif())->check('71110316C');
|
||||
} catch (NifException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::nif()->assert('06357771Q');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::nif())->assert('R1332622H');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"06357771Q" must be a NIF
|
||||
"71110316C" must not be a NIF
|
||||
- "06357771Q" must be a NIF
|
||||
- "R1332622H" must not be a NIF
|
|
@ -1,14 +0,0 @@
|
|||
--CREDITS--
|
||||
Julián Gutiérrez <juliangut@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
v::nif()->check('43333207B');
|
||||
?>
|
||||
--EXPECT--
|
|
@ -1,21 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
Julián Gutiérrez <juliangut@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NifException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::nif()->check('06357771Q');
|
||||
} catch (NifException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"06357771Q" must be a NIF
|
|
@ -1,20 +0,0 @@
|
|||
--CREDITS--
|
||||
Julián Gutiérrez <juliangut@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::nif()->assert('06357771Q');
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
- "06357771Q" must be a NIF
|
|
@ -1,21 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
Julián Gutiérrez <juliangut@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NifException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::nif())->check('71110316C');
|
||||
} catch (NifException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"71110316C" must not be a NIF
|
|
@ -1,20 +0,0 @@
|
|||
--CREDITS--
|
||||
Julián Gutiérrez <juliangut@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::nif())->assert('R1332622H');
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
- "R1332622H" must not be a NIF
|
44
tests/integration/rules/vatin.phpt
Normal file
44
tests/integration/rules/vatin.phpt
Normal file
|
@ -0,0 +1,44 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
Tomasz Regdos <tomek@regdos.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\Locale\PlVatinException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\VatinException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::vatin('PL')->check('1645865778');
|
||||
} catch (PlVatinException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::vatin('PL'))->check('1645865777');
|
||||
} catch (VatinException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::vatin('PL')->assert('1645865778');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::vatin('PL'))->assert('1645865777');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"1645865778" must be a valid Polish VAT identification number
|
||||
"1645865777" must not be a valid VAT identification number for "PL"
|
||||
- "1645865778" must be a valid Polish VAT identification number
|
||||
- "1645865777" must not be a valid VAT identification number for "PL"
|
|
@ -1,15 +0,0 @@
|
|||
--CREDITS--
|
||||
Tomasz Regdos <tomek@regdos.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
v::vatin('PL')->check('1645865777');
|
||||
v::vatin('PL')->assert('1645865777');
|
||||
?>
|
||||
--EXPECT--
|
|
@ -1,21 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
Tomasz Regdos <tomek@regdos.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\Locale\PlVatinException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::vatin('PL')->check('1645865778');
|
||||
} catch (PlVatinException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"1645865778" must be a valid Polish VAT identification number
|
|
@ -1,21 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
Tomasz Regdos <tomek@regdos.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::vatin('PL')->assert('1645865778');
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
- "1645865778" must be a valid Polish VAT identification number
|
|
@ -1,21 +0,0 @@
|
|||
--CREDITS--
|
||||
Henrique Moody <henriquemoody@gmail.com>
|
||||
Tomasz Regdos <tomek@regdos.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\VatinException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::vatin('PL'))->check('1645865777');
|
||||
} catch (VatinException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"1645865777" must not be a valid VAT identification number for "PL"
|
|
@ -1,20 +0,0 @@
|
|||
--CREDITS--
|
||||
Tomasz Regdos <tomek@regdos.com>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::vatin('PL'))->assert('1645865777');
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
- "1645865777" must not be a valid VAT identification number for "PL"
|
Loading…
Reference in a new issue