Skip to content

Commit

Permalink
Merge pull request woocommerce#7655 from SiR-DanieL/unit
Browse files Browse the repository at this point in the history
Begin tests WC_Validation
  • Loading branch information
barrykooij committed Apr 8, 2015
2 parents 37507ec + c72e444 commit 017c3b3
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/unit-tests/util/validation.php
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' ) );
}
}

0 comments on commit 017c3b3

Please sign in to comment.