From bda2efd42e8896c03d6a95591a6d77bcb761ce26 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 6 Jan 2017 12:37:30 +0200 Subject: Add valid_mac() FV rule Close #3992 --- tests/codeigniter/libraries/Form_validation_test.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index edbe9da4a..035410724 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -268,7 +268,6 @@ class Form_validation_test extends CI_TestCase { public function test_rule_valid_email() { $this->assertTrue($this->form_validation->valid_email('email@sample.com')); - $this->assertFalse($this->form_validation->valid_email('valid_email', '@sample.com')); } @@ -294,10 +293,22 @@ class Form_validation_test extends CI_TestCase { $this->assertFalse($this->form_validation->valid_ip('127.0.0.259')); } + public function test_rule_valid_mac() + { + $this->assertTrue($this->form_validation->valid_mac("01-23-45-67-89-aB")); + $this->assertTrue($this->form_validation->valid_mac("01:23:45:67:89:aB")); + $this->assertTrue($this->form_validation->valid_mac("0123.4567.89aB")); + + $this->assertFalse($this->form_validation->valid_mac("-01-23-45-67-89-ab")); + $this->assertFalse($this->form_validation->valid_mac("01:23:45:67:89:ab:")); + $this->assertFalse($this->form_validation->valid_mac("01:23:45:67:89:ab\n")); + $this->assertFalse($this->form_validation->valid_mac("01:23:45:67:89:ag:")); + $this->assertFalse($this->form_validation->valid_mac('0123456789ab')); + } + public function test_rule_valid_base64() { $this->assertTrue($this->form_validation->valid_base64(base64_encode('string'))); - $this->assertFalse($this->form_validation->valid_base64('FA08GG')); } -- cgit v1.2.3-24-g4f1b