Merge pull request #7655 from SiR-DanieL/unit

Begin tests WC_Validation
This commit is contained in:
Barry Kooij 2015-04-08 13:15:18 +02:00
commit 017c3b341e
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
<?php
namespace WooCommerce\Tests\Util;
/**
* Class Validation
* @package WooCommerce\Tests\Util
* @since 2.3
*/
class Validation extends \WC_Unit_Test_Case {
/**
* Test is_email()
*
* @since 2.3
*/
public function test_is_email() {
$this->assertEquals( 'email@domain.com', \WC_Validation::is_email( 'email@domain.com' ) );
$this->assertFalse( \WC_Validation::is_email( 'not a mail' ) );
$this->assertFalse( \WC_Validation::is_email( 'http://test.com' ) );
}
/**
* Test is_phone()
*
* @since 2.3
*/
public function test_is_phone() {
$this->assertTrue( \WC_Validation::is_phone( '+00 000 00 00 000' ) );
$this->assertTrue( \WC_Validation::is_phone( '+00-000-00-00-000' ) );
$this->assertTrue( \WC_Validation::is_phone( '(000) 00 00 000' ) );
$this->assertFalse( \WC_Validation::is_phone( '+00.000.00.00.000' ) );
$this->assertFalse( \WC_Validation::is_phone( '+00 aaa dd ee fff' ) );
}
}