mirror of
https://github.com/Respect/Validation.git
synced 2024-06-08 16:52:16 +02:00
Check "bcmath" extension before executing tests
Although BCMath is necessary to execute "Ip" and "Iban" rules, we not required that in the "composer.json" file. That's because if someone wants to use the library, but doesn't want to use those rules, they would not need to install that extension. However, when executing the tests, they will break. This commit will verify whether the extension exists to test "Ip" and "Iban" rules. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
e0c6f33c01
commit
ed304f3406
|
@ -35,6 +35,12 @@ try {
|
|||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('bcmath')) {
|
||||
echo 'skip: Extension "bcmath" is required to execute this test';
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"SE35 5000 5880 7742" must be a valid IBAN
|
||||
"GB82 WEST 1234 5698 7654 32" must not be a valid IBAN
|
||||
|
|
|
@ -60,6 +60,12 @@ try {
|
|||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('bcmath')) {
|
||||
echo 'skip: Extension "bcmath" is required to execute this test';
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"257.0.0.1" must be an IP address
|
||||
"127.0.0.1" must not be an IP address
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace Respect\Validation\Rules;
|
|||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
use function extension_loaded;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
*
|
||||
|
@ -68,4 +70,16 @@ final class IbanTest extends RuleTestCase
|
|||
'GermanydWrong' => [$sut, 'DE89 5000 5880 7742'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (extension_loaded('bcmath')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->markTestSkipped('You need bcmath to execute this test');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace Respect\Validation\Rules;
|
|||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
use function extension_loaded;
|
||||
|
||||
use const FILTER_FLAG_IPV6;
|
||||
use const FILTER_FLAG_NO_PRIV_RANGE;
|
||||
|
||||
|
@ -113,4 +115,16 @@ final class IpTest extends RuleTestCase
|
|||
|
||||
new Ip($range);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (extension_loaded('bcmath')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->markTestSkipped('You need bcmath to execute this test');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue