mirror of
https://github.com/Respect/Validation.git
synced 2024-06-29 02:30:06 +02:00
Increase tests for "CountryCode" rule
- Add alpha-3 and numeric country codes and unit test for it - Add new integration tests for CountryCode rule alpha-3 and numeric
This commit is contained in:
parent
31f1f1c25e
commit
cbbf082c15
13
tests/integration/countryCode_alpha-3_1.phpt
Normal file
13
tests/integration/countryCode_alpha-3_1.phpt
Normal file
|
@ -0,0 +1,13 @@
|
|||
--TEST--
|
||||
countryCode()
|
||||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
|
||||
var_dump(Validator::countryCode(CountryCode::ALPHA3)->validate('BRA'));
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
13
tests/integration/countryCode_alpha-3_2.phpt
Normal file
13
tests/integration/countryCode_alpha-3_2.phpt
Normal file
|
@ -0,0 +1,13 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
|
||||
v::countryCode(CountryCode::ALPHA3)->assert('BRA');
|
||||
v::countryCode(CountryCode::ALPHA3)->assert('DEU');
|
||||
v::countryCode(CountryCode::ALPHA3)->check('BRA');
|
||||
v::countryCode(CountryCode::ALPHA3)->check('DEU');
|
||||
?>
|
||||
--EXPECTF--
|
16
tests/integration/countryCode_alpha-3_3.phpt
Normal file
16
tests/integration/countryCode_alpha-3_3.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
use Respect\Validation\Exceptions\CountryCodeException;
|
||||
|
||||
try {
|
||||
v::countryCode(CountryCode::ALPHA3)->check('1');
|
||||
} catch (CountryCodeException $exception) {
|
||||
echo $exception->getMainMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
"1" must be a valid country
|
16
tests/integration/countryCode_alpha-3_4.phpt
Normal file
16
tests/integration/countryCode_alpha-3_4.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
|
||||
try {
|
||||
v::countryCode(CountryCode::ALPHA3)->assert('1');
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
\-"1" must be a valid country
|
16
tests/integration/countryCode_alpha-3_5.phpt
Normal file
16
tests/integration/countryCode_alpha-3_5.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
use Respect\Validation\Exceptions\CountryCodeException;
|
||||
|
||||
try {
|
||||
v::not(v::countryCode(CountryCode::ALPHA3))->check('BRA');
|
||||
} catch (CountryCodeException $exception) {
|
||||
echo $exception->getMainMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
"BRA" must not be a valid country
|
16
tests/integration/countryCode_alpha-3_6.phpt
Normal file
16
tests/integration/countryCode_alpha-3_6.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
|
||||
try {
|
||||
v::not(v::countryCode(CountryCode::ALPHA3))->assert('BRA');
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
\-"BRA" must not be a valid country
|
13
tests/integration/countryCode_number_1.phpt
Normal file
13
tests/integration/countryCode_number_1.phpt
Normal file
|
@ -0,0 +1,13 @@
|
|||
--TEST--
|
||||
countryCode()
|
||||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
|
||||
var_dump(Validator::countryCode(CountryCode::NUMERIC)->validate('076'));
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
13
tests/integration/countryCode_number_2.phpt
Normal file
13
tests/integration/countryCode_number_2.phpt
Normal file
|
@ -0,0 +1,13 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
|
||||
v::countryCode(CountryCode::NUMERIC)->assert('076');
|
||||
v::countryCode(CountryCode::NUMERIC)->assert('276');
|
||||
v::countryCode(CountryCode::NUMERIC)->check('076');
|
||||
v::countryCode(CountryCode::NUMERIC)->check('276');
|
||||
?>
|
||||
--EXPECTF--
|
16
tests/integration/countryCode_number_3.phpt
Normal file
16
tests/integration/countryCode_number_3.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
use Respect\Validation\Exceptions\CountryCodeException;
|
||||
|
||||
try {
|
||||
v::countryCode(CountryCode::NUMERIC)->check('BRA');
|
||||
} catch (CountryCodeException $exception) {
|
||||
echo $exception->getMainMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
"BRA" must be a valid country
|
16
tests/integration/countryCode_number_4.phpt
Normal file
16
tests/integration/countryCode_number_4.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
|
||||
try {
|
||||
v::countryCode(CountryCode::NUMERIC)->assert('BRA');
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
\-"BRA" must be a valid country
|
16
tests/integration/countryCode_number_5.phpt
Normal file
16
tests/integration/countryCode_number_5.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
use Respect\Validation\Exceptions\CountryCodeException;
|
||||
|
||||
try {
|
||||
v::not(v::countryCode(CountryCode::NUMERIC))->check('076');
|
||||
} catch (CountryCodeException $exception) {
|
||||
echo $exception->getMainMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
"076" must not be a valid country
|
16
tests/integration/countryCode_number_6.phpt
Normal file
16
tests/integration/countryCode_number_6.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use Respect\Validation\Rules\CountryCode;
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
|
||||
try {
|
||||
v::not(v::countryCode(CountryCode::NUMERIC))->assert('076');
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
\-"076" must not be a valid country
|
Loading…
Reference in a new issue