From fb1d67614399c26869db4065da024d3756b657e1 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Sun, 1 Apr 2012 22:30:29 +0200 Subject: transformed inc/mail tests to phpunit --- _testing/unittests/inc/mail_isvalid.test.php | 82 ++++++++++++++++++++++ .../inc/mail_quoted_printable_encode.test.php | 44 ++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 _testing/unittests/inc/mail_isvalid.test.php create mode 100644 _testing/unittests/inc/mail_quoted_printable_encode.test.php (limited to '_testing/unittests/inc') diff --git a/_testing/unittests/inc/mail_isvalid.test.php b/_testing/unittests/inc/mail_isvalid.test.php new file mode 100644 index 000000000..e4eaf8d78 --- /dev/null +++ b/_testing/unittests/inc/mail_isvalid.test.php @@ -0,0 +1,82 @@ +@example.com', false); // Disallowed Characters + $tests[] = array('test@.', false); + $tests[] = array('test@example.', false); + $tests[] = array('test@.org', false); + $tests[] = array('12345678901234567890123456789012345678901234567890123456789012345@example.com', false); // 64 characters is maximum length for local part. This is 65. + $tests[] = array('test@123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012.com', false); // 255 characters is maximum length for domain. This is 256. + $tests[] = array('test@[123.123.123.123', false); + $tests[] = array('test@123.123.123.123]', false); + + + foreach($tests as $test){ + $info = 'Testing '.$test[0]; + + if($test[1]){ + $this->assertTrue((bool) mail_isvalid($test[0]), $info); + }else{ + $this->assertFalse((bool) mail_isvalid($test[0]), $info); + } + } + } + +} +//Setup VIM: ex: et ts=4 : diff --git a/_testing/unittests/inc/mail_quoted_printable_encode.test.php b/_testing/unittests/inc/mail_quoted_printable_encode.test.php new file mode 100644 index 000000000..8228d007b --- /dev/null +++ b/_testing/unittests/inc/mail_quoted_printable_encode.test.php @@ -0,0 +1,44 @@ +assertEquals(mail_quotedprintable_encode($in),$out); + } + + function test_spaceend(){ + $in = "hello \nhello"; + $out = "hello=20\nhello"; + $this->assertEquals(mail_quotedprintable_encode($in),$out); + } + + function test_german_utf8(){ + $in = 'hello überlänge'; + $out = 'hello =C3=BCberl=C3=A4nge'; + $this->assertEquals(mail_quotedprintable_encode($in),$out); + } + + function test_wrap(){ + $in = '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789'; + $out = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234=\n56789 123456789"; + $this->assertEquals(mail_quotedprintable_encode($in,74),$out); + } + + function test_nowrap(){ + $in = '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789'; + $out = '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789'; + $this->assertEquals(mail_quotedprintable_encode($in,0),$out); + } + + function test_russian_utf8(){ + $in = 'Ваш пароль для системы Доку Вики'; + $out = '=D0=92=D0=B0=D1=88 =D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8C =D0=B4=D0=BB=D1=8F =D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B =D0=94=D0=BE=D0=BA=D1=83 =D0=92=D0=B8=D0=BA=D0=B8'; + $this->assertEquals(mail_quotedprintable_encode($in,0),$out); + } +} + +//Setup VIM: ex: et ts=4 : -- cgit v1.2.3