forked from woocommerce/woocommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request woocommerce#7655 from SiR-DanieL/unit
Begin tests WC_Validation
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' ) ); | ||
} | ||
} |