neu strukturiert, namespace hinzugefügt und klasse sinvoller benannt.
This commit is contained in:
parent
be6438a68b
commit
bff013ce26
|
@ -0,0 +1,22 @@
|
|||
# ---> VisualStudioCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
# ---> Composer
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
405
ValidateTest.php
405
ValidateTest.php
|
@ -1,405 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once "Validate.php";
|
||||
|
||||
/**
|
||||
* User: Marcel 'CoNfu5eD Naeve <confu5ed@serious-pro.de>
|
||||
* Date: 14.05.2016
|
||||
* Time: 11:25
|
||||
*/
|
||||
class ValidateTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/*
|
||||
* Validate::email(); Tests
|
||||
*/
|
||||
public function testEmail_myEmail_level1()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de", 2);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level1_whitelisted()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de", 1,["whitelist"=>["confu5ed@serious-pro.de"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level1_not_in_whitelist()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de", 1,["whitelist"=>["confu5ed@serious-pro.eu"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level1_blacklisted()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de",1,["blacklist"=>["confu5ed@serious-pro.de"]]);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
public function testEmail_myEmail_level1_not_in_blacklist()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de", 1,["blacklist"=>["confu5ed@serious-pro.eu"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2_whitelisted()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de", 2,["whitelist"=>["confu5ed@serious-pro.de"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2_not_in_whitelist()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de", 2,["whitelist"=>["confu5ed@serious-pro.eu"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2_blacklisted()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de", 2,["blacklist"=>["confu5ed@serious-pro.de"]]);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2_not_in_blacklist()
|
||||
{
|
||||
$result = Validate::email("confu5ed@serious-pro.de", 2,["blacklist"=>["confu5ed@serious-pro.eu"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random1_level1()
|
||||
{
|
||||
$result = Validate::email("tempus.lorem.fringilla@vitae.co.uk");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random2_level1()
|
||||
{
|
||||
$result = Validate::email("Etiam.ligula@et.com");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random3_level1()
|
||||
{
|
||||
$result = Validate::email("orci.tincidunt.adipiscing@famesacturpis.edu");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random4_level1()
|
||||
{
|
||||
$result = Validate::email("_______@example.com");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random5_level1()
|
||||
{
|
||||
$result = Validate::email("nonummy.Fusce.fermentum@ut.org");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random6_level1()
|
||||
{
|
||||
$result = Validate::email('"email"@example.com');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random7_level1()
|
||||
{
|
||||
$result = Validate::email('much."more\ unusual"@example.com');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random8_level1()
|
||||
{
|
||||
$result = Validate::email('very.unusual."@".unusual.com@example.com');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random9_level1()
|
||||
{
|
||||
$result = Validate::email('very."(),:;<>[]".VERY."very@\\"very".unusual@strange.example.com');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random10_level2()
|
||||
{
|
||||
$result = Validate::email('very."(),:;<>[]".VERY."very@\\"very".unusual@serious-pro.de', 2);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_invalid1_level1()
|
||||
{
|
||||
$result = Validate::email("me@me@serious-pro.de");
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
public function testEmail_invalid2_level1()
|
||||
{
|
||||
$result = Validate::email("me me@serious-pro.de");
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
public function testEmail_invalid3_level1()
|
||||
{
|
||||
$result = Validate::email("me@serious pro.de");
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate::ipv4(); Tests
|
||||
*/
|
||||
public function testIPv4_v4_localhost()
|
||||
{
|
||||
$this->assertTrue( Validate::ipv4("127.0.0.1") );
|
||||
}
|
||||
public function testIPv4_v4_network()
|
||||
{
|
||||
$this->assertTrue( Validate::ipv4("192.168.178.1") );
|
||||
}
|
||||
public function testIPv4_v4_googledns1()
|
||||
{
|
||||
$this->assertTrue( Validate::ipv4("8.8.8.8") );
|
||||
}
|
||||
public function testIPv4_v4_googledns2()
|
||||
{
|
||||
$this->assertTrue( Validate::ipv4("8.8.4.4") );
|
||||
}
|
||||
public function testIPv4_v4_mask()
|
||||
{
|
||||
$this->assertTrue( Validate::ipv4("255.255.255.255") );
|
||||
}
|
||||
public function testIPv4_v4_zero()
|
||||
{
|
||||
$this->assertTrue( Validate::ipv4("0.0.0.0") );
|
||||
}
|
||||
public function testIPv4_v4_tomuch()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv4("256.255.255.255") );
|
||||
}
|
||||
public function testIPv4_domain()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv4("serious-pro.de") );
|
||||
}
|
||||
public function testIPv4_v6_localhost()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv4("::1") );
|
||||
}
|
||||
public function testIPv4_v6_googledns1()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv4("2001:4860:4860::8888") );
|
||||
}
|
||||
public function testIPv4_v6_googledns2()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv4("2001:4860:4860::8844") );
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate::ipv6(); Tests
|
||||
*/
|
||||
public function testIPv6_v4_localhost()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv6("127.0.0.1") );
|
||||
}
|
||||
public function testIPv6_v4_network()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv6("192.168.178.1") );
|
||||
}
|
||||
public function testIPv6_v4_googledns1()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv6("8.8.8.8") );
|
||||
}
|
||||
public function testIPv6_v4_googledns2()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv6("8.8.4.4") );
|
||||
}
|
||||
public function testIPv6_v4_mask()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv6("255.255.255.255") );
|
||||
}
|
||||
public function testIPv6_v4_zero()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv6("0.0.0.0") );
|
||||
}
|
||||
public function testIPv6_v4_tomuch()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv6("256.255.255.255") );
|
||||
}
|
||||
public function testIPv6_domain()
|
||||
{
|
||||
$this->assertFalse( Validate::ipv6("serious-pro.de") );
|
||||
}
|
||||
public function testIPv6_v6_localhost()
|
||||
{
|
||||
$this->assertTrue( Validate::ipv6("::1") );
|
||||
}
|
||||
public function testIPv6_v6_googledns1()
|
||||
{
|
||||
$this->assertTrue( Validate::ipv6("2001:4860:4860::8888") );
|
||||
}
|
||||
public function testIPv6_v6_googledns2()
|
||||
{
|
||||
$this->assertTrue( Validate::ipv6("2001:4860:4860::8844") );
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate::ip(); Tests
|
||||
*/
|
||||
public function testIP_v4_localhost()
|
||||
{
|
||||
$this->assertTrue( Validate::ip("127.0.0.1") );
|
||||
}
|
||||
public function testIP_v4_network()
|
||||
{
|
||||
$this->assertTrue( Validate::ip("192.168.178.1") );
|
||||
}
|
||||
public function testIP_v4_googledns1()
|
||||
{
|
||||
$this->assertTrue( Validate::ip("8.8.8.8") );
|
||||
}
|
||||
public function testIP_v4_googledns2()
|
||||
{
|
||||
$this->assertTrue( Validate::ip("8.8.4.4") );
|
||||
}
|
||||
public function testIP_v4_mask()
|
||||
{
|
||||
$this->assertTrue( Validate::ip("255.255.255.255") );
|
||||
}
|
||||
public function testIP_v4_zero()
|
||||
{
|
||||
$this->assertTrue( Validate::ip("0.0.0.0") );
|
||||
}
|
||||
public function testIP_v4_tomuch()
|
||||
{
|
||||
$this->assertFalse( Validate::ip("256.255.255.255") );
|
||||
}
|
||||
public function testIP_domain()
|
||||
{
|
||||
$this->assertFalse( Validate::ip("serious-pro.de") );
|
||||
}
|
||||
public function testIP_v6_localhost()
|
||||
{
|
||||
$this->assertTrue( Validate::ip("::1") );
|
||||
}
|
||||
public function testIP_v6_googledns1()
|
||||
{
|
||||
$this->assertTrue( Validate::ip("2001:4860:4860::8888") );
|
||||
}
|
||||
public function testIP_v6_googledns2()
|
||||
{
|
||||
$this->assertTrue( Validate::ip("2001:4860:4860::8844") );
|
||||
}
|
||||
public function testIP_empty()
|
||||
{
|
||||
$this->assertFalse( Validate::ip("") );
|
||||
}
|
||||
public function testIP_trash1()
|
||||
{
|
||||
$this->assertFalse( Validate::ip("%") );
|
||||
}
|
||||
public function testIP_trash2()
|
||||
{
|
||||
$this->assertFalse( Validate::ip("~") );
|
||||
}
|
||||
public function testIP_trash3()
|
||||
{
|
||||
$this->assertFalse( Validate::ip("@") );
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate::mac(); Tests
|
||||
*/
|
||||
public function testMac_random_valid11()
|
||||
{
|
||||
$this->assertTrue( Validate::mac("ce:bb:ac:22:9e:72") );
|
||||
}
|
||||
public function testMac_random_valid12()
|
||||
{
|
||||
$this->assertTrue( Validate::mac("ce-bb-ac-22-9e-72") );
|
||||
}
|
||||
public function testMac_random_valid13()
|
||||
{
|
||||
$this->assertTrue( Validate::mac("cebb.ac22.9e72") );
|
||||
}
|
||||
public function testMac_random_valid21()
|
||||
{
|
||||
$this->assertTrue( Validate::mac("77:a8:7a:bf:45:6f") );
|
||||
}
|
||||
public function testMac_random_valid22()
|
||||
{
|
||||
$this->assertTrue( Validate::mac("77-a8-7a-bf-45-6f") );
|
||||
}
|
||||
public function testMac_random_valid23()
|
||||
{
|
||||
$this->assertTrue( Validate::mac("77a8.7abf.456f") );
|
||||
}
|
||||
public function testMac_invalid1()
|
||||
{
|
||||
$this->assertFalse( Validate::mac("58-E4-C8-C3-5G-23") );
|
||||
}
|
||||
public function testMac_invalid2()
|
||||
{
|
||||
$this->assertFalse( Validate::mac("58-E4-C8-C3-5-23") );
|
||||
}
|
||||
public function testMac_invalid3()
|
||||
{
|
||||
$this->assertFalse( Validate::mac("58-E4-C8-C3-23") );
|
||||
}
|
||||
public function testMac_invalid4()
|
||||
{
|
||||
$this->assertFalse( Validate::mac("58-E4-C8-23") );
|
||||
}
|
||||
public function testMac_empty()
|
||||
{
|
||||
$this->assertFalse( Validate::mac("") );
|
||||
}
|
||||
public function testMac_trash1()
|
||||
{
|
||||
$this->assertFalse( Validate::mac("%") );
|
||||
}
|
||||
public function testMac_trash2()
|
||||
{
|
||||
$this->assertFalse( Validate::mac("-") );
|
||||
}
|
||||
public function testMac_trash3()
|
||||
{
|
||||
$this->assertFalse( Validate::mac(".") );
|
||||
}
|
||||
public function testMac_trash4()
|
||||
{
|
||||
$this->assertFalse( Validate::mac(":") );
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate::range(); Tests
|
||||
*/
|
||||
public function testRange_int1() {
|
||||
$this->assertTrue( Validate::range(23, 20, 25) );
|
||||
}
|
||||
public function testRange_int2() {
|
||||
$this->assertTrue( Validate::range(0, -1, 3) );
|
||||
}
|
||||
public function testRange_int3() {
|
||||
$this->assertFalse( Validate::range(-50, -1, 3) );
|
||||
}
|
||||
public function testRange_float1() {
|
||||
$this->assertTrue( Validate::range(2.3, 2.0, 2.5) );
|
||||
}
|
||||
public function testRange_float2() {
|
||||
$this->assertTrue( Validate::range(0.0, -0.1, 0.3) );
|
||||
}
|
||||
public function testRange_float3() {
|
||||
$this->assertFalse( Validate::range(-5.0, -0.1, 0.3) );
|
||||
}
|
||||
public function testRange_int_in_float1() {
|
||||
$this->assertTrue( Validate::range(2, 1.9, 2.1) );
|
||||
}
|
||||
public function testRange_int_in_float2() {
|
||||
$this->assertTrue( Validate::range(0, -0.1, 0.3) );
|
||||
}
|
||||
public function testRange_int_in_float3() {
|
||||
$this->assertFalse( Validate::range(5, -0.1, 0.3) );
|
||||
}
|
||||
public function testRange_float_in_int1() {
|
||||
$this->assertTrue( Validate::range(2.1, 2, 3) );
|
||||
}
|
||||
public function testRange_float_in_int2() {
|
||||
$this->assertTrue( Validate::range(0.1, 0, 1) );
|
||||
}
|
||||
public function testRange_float_in_int3() {
|
||||
$this->assertFalse( Validate::range(-5.5, -5, 0) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate::iban(); Tests
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Validate::swift(); Tests
|
||||
*/
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^10"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace NAE\Validation;
|
||||
|
||||
/**
|
||||
* Utility Class for validating data.
|
||||
* @license https://github.com/CoNfu5eD/php7-validation-class/blob/master/LICENSE MIT
|
||||
* @author CoNfu5eD (Marcel Naeve) <confu5ed@serious-pro.de>
|
||||
* @author Marcel Naeve <php@naeve.info>
|
||||
* @package NAE\Validation
|
||||
*/
|
||||
class Validate
|
||||
class ValidateStatic
|
||||
{
|
||||
/**
|
||||
* Static method for validating email addresses with multiple secure levels and black- and whitelist.
|
|
@ -0,0 +1,411 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\AppBundle;
|
||||
|
||||
include_once "../vendor/autoload.php";
|
||||
require_once "../src/class.ValidateStatic.php";
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use NAE\Validation\ValidateStatic;
|
||||
|
||||
/**
|
||||
* User: Marcel Naeve <php@naeve.info>
|
||||
* Date: 14.05.2016
|
||||
* Time: 11:25
|
||||
*/
|
||||
class ValidateStaticTest extends TestCase
|
||||
{
|
||||
/*
|
||||
* ValidateStatic::email(); Tests
|
||||
*/
|
||||
public function testEmail_myEmail_level1()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de", 2);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level1_whitelisted()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de", 1,["whitelist"=>["confu5ed@serious-pro.de"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level1_not_in_whitelist()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de", 1,["whitelist"=>["confu5ed@serious-pro.eu"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level1_blacklisted()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de",1,["blacklist"=>["confu5ed@serious-pro.de"]]);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
public function testEmail_myEmail_level1_not_in_blacklist()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de", 1,["blacklist"=>["confu5ed@serious-pro.eu"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2_whitelisted()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de", 2,["whitelist"=>["confu5ed@serious-pro.de"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2_not_in_whitelist()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de", 2,["whitelist"=>["confu5ed@serious-pro.eu"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2_blacklisted()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de", 2,["blacklist"=>["confu5ed@serious-pro.de"]]);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
public function testEmail_myEmail_level2_not_in_blacklist()
|
||||
{
|
||||
$result = ValidateStatic::email("confu5ed@serious-pro.de", 2,["blacklist"=>["confu5ed@serious-pro.eu"]]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random1_level1()
|
||||
{
|
||||
$result = ValidateStatic::email("tempus.lorem.fringilla@vitae.co.uk");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random2_level1()
|
||||
{
|
||||
$result = ValidateStatic::email("Etiam.ligula@et.com");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random3_level1()
|
||||
{
|
||||
$result = ValidateStatic::email("orci.tincidunt.adipiscing@famesacturpis.edu");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random4_level1()
|
||||
{
|
||||
$result = ValidateStatic::email("_______@example.com");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random5_level1()
|
||||
{
|
||||
$result = ValidateStatic::email("nonummy.Fusce.fermentum@ut.org");
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random6_level1()
|
||||
{
|
||||
$result = ValidateStatic::email('"email"@example.com');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random7_level1()
|
||||
{
|
||||
$result = ValidateStatic::email('much."more\ unusual"@example.com');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random8_level1()
|
||||
{
|
||||
$result = ValidateStatic::email('very.unusual."@".unusual.com@example.com');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random9_level1()
|
||||
{
|
||||
$result = ValidateStatic::email('very."(),:;<>[]".VERY."very@\\"very".unusual@strange.example.com');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_random10_level2()
|
||||
{
|
||||
$result = ValidateStatic::email('very."(),:;<>[]".VERY."very@\\"very".unusual@serious-pro.de', 2);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
public function testEmail_invalid1_level1()
|
||||
{
|
||||
$result = ValidateStatic::email("me@me@serious-pro.de");
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
public function testEmail_invalid2_level1()
|
||||
{
|
||||
$result = ValidateStatic::email("me me@serious-pro.de");
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
public function testEmail_invalid3_level1()
|
||||
{
|
||||
$result = ValidateStatic::email("me@serious pro.de");
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/*
|
||||
* ValidateStatic::ipv4(); Tests
|
||||
*/
|
||||
public function testIPv4_v4_localhost()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ipv4("127.0.0.1") );
|
||||
}
|
||||
public function testIPv4_v4_network()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ipv4("192.168.178.1") );
|
||||
}
|
||||
public function testIPv4_v4_googledns1()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ipv4("8.8.8.8") );
|
||||
}
|
||||
public function testIPv4_v4_googledns2()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ipv4("8.8.4.4") );
|
||||
}
|
||||
public function testIPv4_v4_mask()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ipv4("255.255.255.255") );
|
||||
}
|
||||
public function testIPv4_v4_zero()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ipv4("0.0.0.0") );
|
||||
}
|
||||
public function testIPv4_v4_tomuch()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv4("256.255.255.255") );
|
||||
}
|
||||
public function testIPv4_domain()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv4("serious-pro.de") );
|
||||
}
|
||||
public function testIPv4_v6_localhost()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv4("::1") );
|
||||
}
|
||||
public function testIPv4_v6_googledns1()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv4("2001:4860:4860::8888") );
|
||||
}
|
||||
public function testIPv4_v6_googledns2()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv4("2001:4860:4860::8844") );
|
||||
}
|
||||
|
||||
/*
|
||||
* ValidateStatic::ipv6(); Tests
|
||||
*/
|
||||
public function testIPv6_v4_localhost()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv6("127.0.0.1") );
|
||||
}
|
||||
public function testIPv6_v4_network()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv6("192.168.178.1") );
|
||||
}
|
||||
public function testIPv6_v4_googledns1()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv6("8.8.8.8") );
|
||||
}
|
||||
public function testIPv6_v4_googledns2()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv6("8.8.4.4") );
|
||||
}
|
||||
public function testIPv6_v4_mask()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv6("255.255.255.255") );
|
||||
}
|
||||
public function testIPv6_v4_zero()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv6("0.0.0.0") );
|
||||
}
|
||||
public function testIPv6_v4_tomuch()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv6("256.255.255.255") );
|
||||
}
|
||||
public function testIPv6_domain()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ipv6("serious-pro.de") );
|
||||
}
|
||||
public function testIPv6_v6_localhost()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ipv6("::1") );
|
||||
}
|
||||
public function testIPv6_v6_googledns1()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ipv6("2001:4860:4860::8888") );
|
||||
}
|
||||
public function testIPv6_v6_googledns2()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ipv6("2001:4860:4860::8844") );
|
||||
}
|
||||
|
||||
/*
|
||||
* ValidateStatic::ip(); Tests
|
||||
*/
|
||||
public function testIP_v4_localhost()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ip("127.0.0.1") );
|
||||
}
|
||||
public function testIP_v4_network()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ip("192.168.178.1") );
|
||||
}
|
||||
public function testIP_v4_googledns1()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ip("8.8.8.8") );
|
||||
}
|
||||
public function testIP_v4_googledns2()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ip("8.8.4.4") );
|
||||
}
|
||||
public function testIP_v4_mask()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ip("255.255.255.255") );
|
||||
}
|
||||
public function testIP_v4_zero()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ip("0.0.0.0") );
|
||||
}
|
||||
public function testIP_v4_tomuch()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ip("256.255.255.255") );
|
||||
}
|
||||
public function testIP_domain()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ip("serious-pro.de") );
|
||||
}
|
||||
public function testIP_v6_localhost()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ip("::1") );
|
||||
}
|
||||
public function testIP_v6_googledns1()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ip("2001:4860:4860::8888") );
|
||||
}
|
||||
public function testIP_v6_googledns2()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::ip("2001:4860:4860::8844") );
|
||||
}
|
||||
public function testIP_empty()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ip("") );
|
||||
}
|
||||
public function testIP_trash1()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ip("%") );
|
||||
}
|
||||
public function testIP_trash2()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ip("~") );
|
||||
}
|
||||
public function testIP_trash3()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::ip("@") );
|
||||
}
|
||||
|
||||
/*
|
||||
* ValidateStatic::mac(); Tests
|
||||
*/
|
||||
public function testMac_random_valid11()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::mac("ce:bb:ac:22:9e:72") );
|
||||
}
|
||||
public function testMac_random_valid12()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::mac("ce-bb-ac-22-9e-72") );
|
||||
}
|
||||
public function testMac_random_valid13()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::mac("cebb.ac22.9e72") );
|
||||
}
|
||||
public function testMac_random_valid21()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::mac("77:a8:7a:bf:45:6f") );
|
||||
}
|
||||
public function testMac_random_valid22()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::mac("77-a8-7a-bf-45-6f") );
|
||||
}
|
||||
public function testMac_random_valid23()
|
||||
{
|
||||
$this->assertTrue( ValidateStatic::mac("77a8.7abf.456f") );
|
||||
}
|
||||
public function testMac_invalid1()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::mac("58-E4-C8-C3-5G-23") );
|
||||
}
|
||||
public function testMac_invalid2()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::mac("58-E4-C8-C3-5-23") );
|
||||
}
|
||||
public function testMac_invalid3()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::mac("58-E4-C8-C3-23") );
|
||||
}
|
||||
public function testMac_invalid4()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::mac("58-E4-C8-23") );
|
||||
}
|
||||
public function testMac_empty()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::mac("") );
|
||||
}
|
||||
public function testMac_trash1()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::mac("%") );
|
||||
}
|
||||
public function testMac_trash2()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::mac("-") );
|
||||
}
|
||||
public function testMac_trash3()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::mac(".") );
|
||||
}
|
||||
public function testMac_trash4()
|
||||
{
|
||||
$this->assertFalse( ValidateStatic::mac(":") );
|
||||
}
|
||||
|
||||
/*
|
||||
* ValidateStatic::range(); Tests
|
||||
*/
|
||||
public function testRange_int1() {
|
||||
$this->assertTrue( ValidateStatic::range(23, 20, 25) );
|
||||
}
|
||||
public function testRange_int2() {
|
||||
$this->assertTrue( ValidateStatic::range(0, -1, 3) );
|
||||
}
|
||||
public function testRange_int3() {
|
||||
$this->assertFalse( ValidateStatic::range(-50, -1, 3) );
|
||||
}
|
||||
public function testRange_float1() {
|
||||
$this->assertTrue( ValidateStatic::range(2.3, 2.0, 2.5) );
|
||||
}
|
||||
public function testRange_float2() {
|
||||
$this->assertTrue( ValidateStatic::range(0.0, -0.1, 0.3) );
|
||||
}
|
||||
public function testRange_float3() {
|
||||
$this->assertFalse( ValidateStatic::range(-5.0, -0.1, 0.3) );
|
||||
}
|
||||
public function testRange_int_in_float1() {
|
||||
$this->assertTrue( ValidateStatic::range(2, 1.9, 2.1) );
|
||||
}
|
||||
public function testRange_int_in_float2() {
|
||||
$this->assertTrue( ValidateStatic::range(0, -0.1, 0.3) );
|
||||
}
|
||||
public function testRange_int_in_float3() {
|
||||
$this->assertFalse( ValidateStatic::range(5, -0.1, 0.3) );
|
||||
}
|
||||
public function testRange_float_in_int1() {
|
||||
$this->assertTrue( ValidateStatic::range(2.1, 2, 3) );
|
||||
}
|
||||
public function testRange_float_in_int2() {
|
||||
$this->assertTrue( ValidateStatic::range(0.1, 0, 1) );
|
||||
}
|
||||
public function testRange_float_in_int3() {
|
||||
$this->assertFalse( ValidateStatic::range(-5.5, -5, 0) );
|
||||
}
|
||||
|
||||
/*
|
||||
* ValidateStatic::iban(); Tests
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* ValidateStatic::swift(); Tests
|
||||
*/
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue