/** * @dataProvider valuesProvider */ public function testValues($input, $expected_val, $is_default) { $ob = new Horde_Mime_Headers_ContentTransferEncoding(null, $input); $this->assertEquals($expected_val, $ob->value); if ($is_default) { $this->assertTrue($ob->isDefault()); } else { $this->assertFalse($ob->isDefault()); } }
/** * Returns a Horde_Mime_Header object containing all MIME headers needed * for the part. * * @param array $options Additional options: * - encode: (integer) A mask of allowable encodings. * DEFAULT: Auto-determined * - headers: (Horde_Mime_Headers) The object to add the MIME headers * to. * DEFAULT: Add headers to a new object * * @return Horde_Mime_Headers A Horde_Mime_Headers object. */ public function addMimeHeaders($options = array()) { if (empty($options['headers'])) { $headers = new Horde_Mime_Headers(); } else { $headers = $options['headers']; $headers->removeHeader('Content-Disposition'); $headers->removeHeader('Content-Transfer-Encoding'); } /* Add the mandatory Content-Type header. */ $ct = $this->_headers['content-type']; $headers->addHeaderOb($ct); /* Add the language(s), if set. (RFC 3282 [2]) */ if ($hdr = $this->_headers['content-language']) { $headers->addHeaderOb($hdr); } /* Get the description, if any. */ if ($hdr = $this->_headers['content-description']) { $headers->addHeaderOb($hdr); } /* Set the duration, if it exists. (RFC 3803) */ if ($hdr = $this->_headers['content-duration']) { $headers->addHeaderOb($hdr); } /* Per RFC 2046[4], this MUST appear in the base message headers. */ if ($this->_status & self::STATUS_BASEPART) { $headers->addHeaderOb(Horde_Mime_Headers_MimeVersion::create()); } /* message/* parts require no additional header information. */ if ($ct->ptype === 'message') { return $headers; } /* RFC 2183 [2] indicates that default is no requested disposition - * the receiving MUA is responsible for display choice. */ $cd = $this->_headers['content-disposition']; if (!$cd->isDefault()) { $headers->addHeaderOb($cd); } /* Add transfer encoding information. RFC 2045 [6.1] indicates that * default is 7bit. No need to send the header in this case. */ $cte = new Horde_Mime_Headers_ContentTransferEncoding(null, $this->_getTransferEncoding(empty($options['encode']) ? null : $options['encode'])); if (!$cte->isDefault()) { $headers->addHeaderOb($cte); } /* Add content ID information. */ if ($hdr = $this->_headers['content-id']) { $headers->addHeaderOb($hdr); } return $headers; }