From ed4969074ab3ae5834511ec551c6081b92779719 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 14 Jul 2016 15:42:04 +0200 Subject: Tests: Test muser username/email verification Email verification is pretty basic since we use the framework function right now. This might change in the future. Signed-off-by: Florian Pritz --- application/test/tests/test_models_muser.php | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 application/test/tests/test_models_muser.php diff --git a/application/test/tests/test_models_muser.php b/application/test/tests/test_models_muser.php new file mode 100644 index 000000000..1c5dc98b6 --- /dev/null +++ b/application/test/tests/test_models_muser.php @@ -0,0 +1,56 @@ + + * + * Licensed under AGPLv3 + * (see COPYING for full license text) + * + */ + +namespace test\tests; + +class test_models_muser extends \test\Test { + + public function __construct() + { + parent::__construct(); + } + + public function init() + { + } + + public function cleanup() + { + } + + public function test_valid_username() + { + $CI =& get_instance(); + + $this->t->is($CI->muser->valid_username("thisisbob42"), true, "valid username"); + $this->t->is($CI->muser->valid_username("31337"), true, "valid username"); + $this->t->is($CI->muser->valid_username("thisisjoe"), true, "valid username"); + $this->t->is($CI->muser->valid_username("1234567890123456789012345678901"), true, "31 chars"); + $this->t->is($CI->muser->valid_username("12345678901234567890123456789012"), true, "32 chars"); + + $this->t->is($CI->muser->valid_username("Joe"), false, "contains uppercase"); + $this->t->is($CI->muser->valid_username("joe_bob"), false, "contains underscore"); + $this->t->is($CI->muser->valid_username("joe-bob"), false, "contains dash"); + $this->t->is($CI->muser->valid_username("123456789012345678901234567890123"), false, "33 chars"); + $this->t->is($CI->muser->valid_username("1234567890123456789012345678901234"), false, "34 chars"); + } + + public function test_valid_email() + { + $CI =& get_instance(); + + $this->t->is($CI->muser->valid_email("joe@bob.com"), true, "valid email"); + $this->t->is($CI->muser->valid_email("joe+mailbox@bob.com"), true, "valid email"); + $this->t->is($CI->muser->valid_email("bob@fancyaddress.net"), true, "valid email"); + + $this->t->is($CI->muser->valid_email("joebob.com"), false, "missing @"); + } + +} + -- cgit v1.2.3-24-g4f1b