Skip to content

Commit

Permalink
Updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Jan 12, 2020
1 parent 23fcb76 commit dcb4a52
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions system/classes/validator.class.php
Expand Up @@ -671,8 +671,8 @@ public function phone($check, $regex = null)
}

if (is_null($_this->regex)) {
// includes all NANPA members. see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
$_this->regex = '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/';
// includes all NANPA members. see https://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
$_this->regex = '/^(?:\+?1)?[-. ]?\\(?[2-9][0-9][0-9]\\)?[-. ]?[2-9][0-9][0-9][-. ]?[0-9]{4}$/';
}

return $_this->_check();
Expand Down
18 changes: 17 additions & 1 deletion tests/system/classes/ValidatorClassTest.php
Expand Up @@ -375,7 +375,23 @@ public function testNumeric()
*/
public function testPhone()
{
$this->markTestIncomplete();
$validator = Validator::getInstance();

// USA
$data = [
[true, '234-235-5678'],
// [false, '234-911-5678'],
[false, '314-159-2653'],
[false, '123-234-5678'],
[true, '1-213-555-0123'],
];

foreach ($data as $items) {
$this->assertEquals(
$items[0],
$validator->phone($items[1]),
'Expected ' . $items[1] . ' is ' . ($items[0] ? '' : 'not') . ' the right phone number given, but such is not the case.');
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/system/classes/templateClassTest.php
Expand Up @@ -30,7 +30,7 @@ protected function setUp()
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout';
$_CONF['cache_templates'] = false;

require_once $_CONF['path_system'] . 'classes/mobiledetect/Mobile_Detect.php';
require_once $_CONF['path_system'] . 'vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php';
$_DEVICE = new Mobile_Detect();

// Reset Template Options so they do not include default vars
Expand Down

0 comments on commit dcb4a52

Please sign in to comment.