Changeset View
Changeset View
Standalone View
Standalone View
src/abuse/__tests__/SecureSheldsUpTestCase.php
- This file was added.
<?php | |||||
final class SecureShieldsUpTestCase extends PhabricatorTestCase { | |||||
public function testPhoneNumberDetection() { | |||||
$numbers = array( | |||||
'8002044122', | |||||
); | |||||
$tests = array( | |||||
'8002044122' => true, | |||||
'1 (800) 204.4122' => true, | |||||
'80012044122' => false, | |||||
'8OO2o44I22' => true, | |||||
// Does not contain the number. | |||||
'Pulse Rifle' => false, | |||||
// Currently, we give up after 6 characters without finding the next | |||||
// digit. | |||||
'800........204.4122' => false, | |||||
// We aren't wizards, but users aren't either. | |||||
'eight hundred, then dial two zero 4, then 41 and finally twenty two' | |||||
=> false, | |||||
); | |||||
foreach ($tests as $input => $expect) { | |||||
$actual = SecureShieldsUpAction::matchPhoneNumbers($numbers, $input); | |||||
$this->assertEqual( | |||||
$expect, | |||||
$actual, | |||||
pht('Detection of phone numbers in: %s', $input)); | |||||
} | |||||
} | |||||
} |