| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Mail
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- /**
- * Zend_Mail_Message
- */
- require_once 'Zend/Mail/Header/HeaderValue.php';
- class Zend_Mail_Header_HeaderValueTest extends PHPUnit_Framework_TestCase
- {
- /**
- * Data for filter value
- */
- public function getFilterValues()
- {
- return array(
- array("This is a\n test", "This is a test"),
- array("This is a\r test", "This is a test"),
- array("This is a\n\r test", "This is a test"),
- array("This is a\r\n test", "This is a\r\n test"),
- array("This is a \r\ntest", "This is a test"),
- array("This is a \r\n\n test", "This is a test"),
- array("This is a\n\n test", "This is a test"),
- array("This is a\r\r test", "This is a test"),
- array("This is a \r\r\n test", "This is a \r\n test"),
- array("This is a \r\n\r\ntest", "This is a test"),
- array("This is a \r\n\n\r\n test", "This is a \r\n test")
- );
- }
- /**
- * @dataProvider getFilterValues
- * @group ZF2015-04
- */
- public function testFilterValue($value, $expected)
- {
- $this->assertEquals($expected, Zend_Mail_Header_HeaderValue::filter($value));
- }
- public function validateValues()
- {
- return array(
- array("This is a\n test", 'assertFalse'),
- array("This is a\r test", 'assertFalse'),
- array("This is a\n\r test", 'assertFalse'),
- array("This is a\r\n test", 'assertTrue'),
- array("This is a \r\ntest", 'assertFalse'),
- array("This is a \r\n\n test", 'assertFalse'),
- array("This is a\n\n test", 'assertFalse'),
- array("This is a\r\r test", 'assertFalse'),
- array("This is a \r\r\n test", 'assertFalse'),
- array("This is a \r\n\r\ntest", 'assertFalse'),
- array("This is a \r\n\n\r\n test", 'assertFalse')
- );
- }
- /**
- * @dataProvider validateValues
- * @group ZF2015-04
- */
- public function testValidateValue($value, $assertion)
- {
- $this->{$assertion}(Zend_Mail_Header_HeaderValue::isValid($value));
- }
- public function assertValues()
- {
- return array(
- array("This is a\n test"),
- array("This is a\r test"),
- array("This is a\n\r test"),
- array("This is a \r\ntest"),
- array("This is a \r\n\n test"),
- array("This is a\n\n test"),
- array("This is a\r\r test"),
- array("This is a \r\r\n test"),
- array("This is a \r\n\r\ntest"),
- array("This is a \r\n\n\r\n test")
- );
- }
- /**
- * @dataProvider assertValues
- * @group ZF2015-04
- */
- public function testAssertValidRaisesExceptionForInvalidValues($value)
- {
- $this->setExpectedException('Zend_Mail_Exception', 'Invalid');
- Zend_Mail_Header_HeaderValue::assertValid($value);
- }
- }
|