1<?php 2/** 3 * Copyright 2014-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file COPYING for license information (LGPL). If you 6 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 7 * 8 * @category Horde 9 * @copyright 2014-2016 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @package Smtp 12 * @subpackage UnitTests 13 */ 14 15/** 16 * Test for the SMTP BODY filter. 17 * 18 * @author Michael Slusarz <slusarz@horde.org> 19 * @category Horde 20 * @copyright 2014-2016 Horde LLC 21 * @ignore 22 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 23 * @package Smtp 24 * @subpackage UnitTests 25 */ 26class Horde_Smtp_FilterBodyTest extends Horde_Test_Case 27{ 28 /** 29 * @dataProvider bodyFilterProvider() 30 */ 31 public function testBodyFilter($data, $result) 32 { 33 $params = new stdClass; 34 35 $stream = fopen('php://temp', 'r+'); 36 stream_filter_register('horde_smtp_body', 'Horde_Smtp_Filter_Body'); 37 stream_filter_append( 38 $stream, 39 'horde_smtp_body', 40 STREAM_FILTER_WRITE, 41 $params 42 ); 43 44 fwrite($stream, $data); 45 fclose($stream); 46 47 $this->assertEquals( 48 $result, 49 $params->body 50 ); 51 } 52 53 public function bodyFilterProvider() 54 { 55 return array( 56 array( 57 "This is 7-bit\r\ndata.", 58 false 59 ), 60 array( 61 str_repeat('A', 900) . "This is also 7-bit\r\ndata.", 62 false 63 ), 64 array( 65 "This is 8-bit åå\r\ndata.", 66 '8bit' 67 ), 68 array( 69 str_repeat('A', 900) . "This is also 8-bit åå\r\ndata.", 70 '8bit' 71 ), 72 array( 73 "This is binary \0\r\ndata.", 74 'binary' 75 ), 76 array( 77 str_repeat('A', 1500) . "This is also binary åå\r\ndata.", 78 'binary' 79 ) 80 ); 81 } 82 83} 84