2020-02-24 18:02:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use PIN\Validator as P;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class SimpleTest extends TestCase {
|
2020-02-25 08:50:53 +00:00
|
|
|
const PINS = ['244713', '560029', '560030', '110011'];
|
2020-02-24 18:02:18 +00:00
|
|
|
|
2020-03-13 12:19:02 +00:00
|
|
|
const INVALID_PINS = ['999999', '99999', '9999', '999', '99', '9', '111111', '2447131'];
|
2020-02-24 18:02:18 +00:00
|
|
|
|
|
|
|
public function testSamplePins() {
|
|
|
|
foreach(self::PINS as $pin) {
|
|
|
|
$this->assertTrue(P::validate($pin), "$pin should be valid");
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach(self::INVALID_PINS as $pin) {
|
|
|
|
$this->assertFalse(P::validate($pin), "$pin should be invalid");
|
|
|
|
}
|
|
|
|
}
|
2023-07-01 14:30:02 +00:00
|
|
|
|
2023-07-02 08:51:35 +00:00
|
|
|
public function testSearch() {
|
|
|
|
$this->assertSame(P::search("560029"), ["560029"]);
|
|
|
|
$this->assertSame(P::search("my pincode is 560029"), ["560029"]);
|
|
|
|
$this->assertSame(P::search("560029 244713"), ["244713", "560029"]);
|
|
|
|
$this->assertSame(P::search("address 560038 bangalore"), ["560038"]);
|
|
|
|
}
|
2020-03-13 11:12:58 +00:00
|
|
|
}
|