ZF-9: unit test failure for Zend_Mime; OS/env dependent? TRAC-145
Description
hi,
per comments from ZF list from Matthew Weier O'Phinney:
=========================== Please open a bug for this issue, and, when doing so, please indicate what platform you're running on (Windows, Mac, Linux, etc.), what version of PHP you're using, and which version of PHPUnit you used.
I'm currently unable to recreate the failure -- all tests run on my machine, even under a fresh checkout -- using Debian GNU/Linux, PHP 5.1.2, and PHPUnit 2.3.5. A colleague reports the test failing under Cygwin + Windows using PHP 5.1.4 and PHPUnit 3.0.0alpha5. This information leads me to believe the failure may be related to OS, PHP version, or PHPUnit version.
I'll get someone with specs closer to those you report to delve into it further
so we can close the bug.
on OSX 10.4.6 ...
% zend_framework > % zend_framework > svn info | grep Revision Revision: 668 % zend_framework > pear list | grep -i phpunit2 PHPUnit2 3.0.0alpha11 alpha % zend_framework > php -i PHP Version => 5.2.0-dev System => Darwin devuser 8.6.0 Darwin Kernel Version 8.6.0: Tue Mar 7 16:58:48 PST 2006; root:xnu-792.6.70.obj~1/RELEASE_PPC Power Macintosh
./configure \
...
--with-apxs2=/usr/local/apache2/sbin/apxs \
--enable-shared --disable-static \
--disable-debug \
--disable-safe-mode \
--disable-dmalloc \
--enable-inline-optimization \
--enable-session \
--with-tsrm-pthreads \
--enable-maintainer-zts \
...
% httpd -V
Server version: Apache/2.2.3-dev Server built: Jun 8 2006 17:00:58 Server's Module Magic Number: 20051115:2 Server loaded: APR 1.2.8-dev, APR-Util 1.2.8-dev Compiled using: APR 1.2.8-dev, APR-Util 1.2.8-dev Architecture: 32-bit Server MPM: Worker
threaded: yes (fixed thread count)
forked: yes (variable process count)
% zend_framework > cd tests % zend_framework/tests > php Zend/Mime/AllTests.php
Time: 00:00 There was 1 failure: 1) testStreamEncoding(Zend_Mime_PartTest) failed asserting that <'<?php /** * @package Zend_Mime * @subpackage UnitTests */
/** * Zend_Mime_Part */ require_once \'Zend/Mime/Part.php\';
/** * PHPUnit2 test case */ require_once \'PHPUnit2/Framework/TestCase.php\';
/** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText;
protected function setUp()
{
$this->_testText = \'safdsafsaˆlg ˆˆgdˆˆ sdˆjgˆsdjgˆldˆgksdˆgjˆsdfgˆdsjˆgjsdˆgjˆdfsjgˆdsfjˆdjsˆg kjhdkj \'
. \'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg\';
$this->part = new Zend_Mime_Part($this->_testText);
$this->part->encoding = Zend_Mime::ENCODING_BASE64;
$this->part->type = "text/plain";
$this->part->filename = \'test.txt\';
$this->part->disposition = \'attachment\';
$this->part->charset = \'iso8859-1\';
$this->part->id = \'4711\';
}
public function testHeaders()
{
$expectedHeaders = array(\'Content-Type: text/plain\',
\'Content-Transfer-Encoding: \' . Zend_Mime::ENCODING_BASE64,
\'Content-Disposition: attachment\',
\'filename="test.txt"\',
\'charset="iso8859-1"\',
\'Content-ID: <4711>\');
$actual = $this->part->getHeaders();
foreach ($expectedHeaders as $expected) {
$this->assertContains($expected, $actual);
}
}
public function testContentEncoding()
{
// Test with base64 encoding
$content = $this->part->getContent();
$this->assertEquals($this->_testText, base64_decode($content));
// Test with quotedPrintable Encoding:
$this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
$content = $this->part->getContent();
$this->assertEquals($this->_testText, quoted_printable_decode($content));
// Test with 8Bit encoding
$this->part->encoding = Zend_Mime::ENCODING_8BIT;
$content = $this->part->getContent();
$this->assertEquals($this->_testText, $content);
}
public function testStreamEncoding()
{
$testfile = realpath(__FILE__);
$original = file_get_contents($testfile);
// Test Base64
$fp = fopen($testfile,\'rb\');
$this->assertTrue(is_resource($fp));
$part = new Zend_Mime_Part($fp);
$part->encoding = Zend_Mime::ENCODING_BASE64;
$fp2 = $part->getEncodedStream();
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(base64_decode($encoded),$original);
// test QuotedPrintable
$fp = fopen($testfile,\'rb\');
$this->assertTrue(is_resource($fp));
$part = new Zend_Mime_Part($fp);
$part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
$fp2 = $part->getEncodedStream();
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(quoted_printable_decode($encoded),$original);
}
} '> is equal to <string:'<?php /** * @package Zend_Mime * @subpackage UnitTests */
/** * Zend_Mime_Part */ require_once \'Zend/Mime/Part.php\';
/** * PHPUnit2 test case */ require_once \'PHPUnit2/Framework/TestCase.php\';
/** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText;
protected function setUp()
{
$this->_testText = \'safdsafsaˆlg ˆˆgdˆˆ sdˆjgˆsdjgˆldˆgksdˆgjˆsdfgˆdsjˆgjsdˆgjˆdfsjgˆdsfjˆdjsˆg kjhdkj \'
. \'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg\';
$this->part = new Zend_Mime_Part($this->_testText);
$this->part->encoding = Zend_Mime::ENCODING_BASE64;
$this->part->type = "text/plain";
$this->part->filename = \'test.txt\';
$this->part->disposition = \'attachment\';
$this->part->charset = \'iso8859-1\';
$this->part->id = \'4711\';
}
public function testHeaders()
{
$expectedHeaders = array(\'Content-Type: text/plain\',
\'Content-Transfer-Encoding: \' . Zend_Mime::ENCODING_BASE64,
\'Content-Disposition: attachment\',
\'filename="test.txt"\',
\'charset="iso8859-1"\',
\'Content-ID: <4711>\');
$actual = $this->part->getHeaders();
foreach ($expectedHeaders as $expected) {
$this->assertContains($expected, $actual);
}
}
public function testContentEncoding()
{
// Test with base64 encoding
$content = $this->part->getContent();
$this->assertEquals($this->_testText, base64_decode($content));
// Test with quotedPrintable Encoding:
$this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
$content = $this->part->getContent();
$this->assertEquals($this->_testText, quoted_printable_decode($content));
// Test with 8Bit encoding
$this->part->encoding = Zend_Mime::ENCODING_8BIT;
$content = $this->part->getContent();
$this->assertEquals($this->_testText, $content);
}
public function testStreamEncoding()
{
$testfile = realpath(__FILE__);
$original = file_get_contents($testfile);
// Test Base64
$fp = fopen($testfile,\'rb\');
$this->assertTrue(is_resource($fp));
$part = new Zend_Mime_Part($fp);
$part->encoding = Zend_Mime::ENCODING_BASE64;
$fp2 = $part->getEncodedStream();
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(base64_decode($encoded),$original);
// test QuotedPrintable
$fp = fopen($testfile,\'rb\');
$this->assertTrue(is_resource($fp));
$part = new Zend_Mime_Part($fp);
$part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
$fp2 = $part->getEncodedStream();
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(quoted_printable_decode($encoded),$o'>
expected string <<?php /** * @package Zend_Mime * @subpackage UnitTests */ /** * Zend_Mime_Part */ require_once 'Zend/Mime/Part.php'; /** * PHPUnit2 test case */ require_once 'PHPUnit2/Framework/TestCase.php'; /** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText; protected function setUp() { $this->_testText = 'safdsafsaˆlg ˆˆgdˆˆ sdˆjgˆsdjgˆldˆgksdˆgjˆsdfgˆdsjˆgjsdˆgjˆdfsjgˆdsfjˆdjsˆg kjhdkj ' . 'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg'; $this->part = new Zend_Mime_Part($this->_testText); $this->part->encoding = Zend_Mime::ENCODING_BASE64; $this->part->type = "text/plain"; $this->part->filename = 'test.txt'; $this->part->disposition = 'attachment'; $this->part->charset = 'iso8859-1'; $this->part->id = '4711'; } public function testHeaders() { $expectedHeaders = array('Content-Type: text/plain', 'Content-Transfer-Encoding: ' . Zend_Mime::ENCODING_BASE64, 'Content-Disposition: attachment', 'filename="test.txt"', 'charset="iso8859-1"', 'Content-ID: <4711>'); $actual = $this->part->getHeaders(); foreach ($expectedHeaders as $expected) { $this->assertContains($expected, $actual); } } public function testContentEncoding() { // Test with base64 encoding $content = $this->part->getContent(); $this->assertEquals($this->_testText, base64_decode($content)); // Test with quotedPrintable Encoding: $this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $content = $this->part->getContent(); $this->assertEquals($this->_testText, quoted_printable_decode($content)); // Test with 8Bit encoding $this->part->encoding = Zend_Mime::ENCODING_8BIT; $content = $this->part->getContent(); $this->assertEquals($this->_testText, $content); } public function testStreamEncoding() { $testfile = realpath(__FILE__); $original = file_get_contents($testfile); // Test Base64 $fp = fopen($testfile,'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_BASE64; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(base64_decode($encoded),$original); // test QuotedPrintable $fp = fopen($testfile,'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(quoted_printable_decode($encoded),$o> difference < ??????????????????> got string <<?php /** * @package Zend_Mime * @subpackage UnitTests */
/** * Zend_Mime_Part */ require_once 'Zend/Mime/Part.php';
/** * PHPUnit2 test case */ require_once 'PHPUnit2/Framework/TestCase.php';
/** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText;
protected function setUp()
{
$this->_testText = 'safdsafsaˆlg ˆˆgdˆˆ sdˆjgˆsdjgˆldˆgksdˆgjˆsdfgˆdsjˆgjsdˆgjˆdfsjgˆdsfjˆdjsˆg kjhdkj '
. 'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg';
$this->part = new Zend_Mime_Part($this->_testText);
$this->part->encoding = Zend_Mime::ENCODING_BASE64;
$this->part->type = "text/plain";
$this->part->filename = 'test.txt';
$this->part->disposition = 'attachment';
$this->part->charset = 'iso8859-1';
$this->part->id = '4711';
}
public function testHeaders()
{
$expectedHeaders = array('Content-Type: text/plain',
'Content-Transfer-Encoding: ' . Zend_Mime::ENCODING_BASE64,
'Content-Disposition: attachment',
'filename="test.txt"',
'charset="iso8859-1"',
'Content-ID: <4711>');
$actual = $this->part->getHeaders();
foreach ($expectedHeaders as $expected) {
$this->assertContains($expected, $actual);
}
}
public function testContentEncoding()
{
// Test with base64 encoding
$content = $this->part->getContent();
$this->assertEquals($this->_testText, base64_decode($content));
// Test with quotedPrintable Encoding:
$this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
$content = $this->part->getContent();
$this->assertEquals($this->_testText, quoted_printable_decode($content));
// Test with 8Bit encoding
$this->part->encoding = Zend_Mime::ENCODING_8BIT;
$content = $this->part->getContent();
$this->assertEquals($this->_testText, $content);
}
public function testStreamEncoding()
{
$testfile = realpath(__FILE__);
$original = file_get_contents($testfile);
// Test Base64
$fp = fopen($testfile,'rb');
$this->assertTrue(is_resource($fp));
$part = new Zend_Mime_Part($fp);
$part->encoding = Zend_Mime::ENCODING_BASE64;
$fp2 = $part->getEncodedStream();
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(base64_decode($encoded),$original);
// test QuotedPrintable
$fp = fopen($testfile,'rb');
$this->assertTrue(is_resource($fp));
$part = new Zend_Mime_Part($fp);
$part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
$fp2 = $part->getEncodedStream();
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(quoted_printable_decode($encoded),$original);
}
} > /webapps/tools/zend_framework/tests/Zend/Mime/PartTest.php:90 /webapps/tools/zend_framework/tests/Zend/Mime/AllTests.php:16 /webapps/tools/zend_framework/tests/Zend/Mime/AllTests.php:31
FAILURES! Tests: 8, Failures: 1.
Comments
Posted by Richard (openmacnews) on 2006-06-17T16:30:17.000+0000
w/ ZF svn r650 php 52-dev OSX 10.4.6 upgrade to PHPUnit 300a11 % php Zend/Mime/AllTests.php PHPUnit 3.0.0alpha11 by Sebastian Bergmann. ..F..... Time: 00:00 There was 1 failure: 1) testStreamEncoding(Zend_Mime_PartTest) failed asserting that <'<?php /** * @package Zend_Mime * @subpackage UnitTests */ /** * Zend_Mime_Part */ require_once \'Zend/Mime/Part.php\'; /** * PHPUnit2 test case */ require_once \'PHPUnit2/Framework/TestCase.php\'; /** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText; protected function setUp() { $this->_testText = \'safdsafsaˆlg ˆˆgdˆˆ sdˆjgˆsdjgˆldˆgksdˆgjˆsdfgˆdsjˆgjsdˆgjˆdfsjgˆdsfjˆdjsˆg kjhdkj \' . \'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg\'; $this->part = new Zend_Mime_Part($this->_testText); $this->part->encoding = Zend_Mime::ENCODING_BASE64; $this->part->type = "text/plain"; $this->part->filename = \'test.txt\'; $this->part->disposition = \'attachment\'; $this->part->charset = \'iso8859-1\'; $this->part->id = \'4711\'; } public function testHeaders() { $expectedHeaders = array(\'Content-Type: text/plain\', \'Content-Transfer-Encoding: \' . Zend_Mime::ENCODING_BASE64, \'Content-Disposition: attachment\', \'filename="test.txt"\', \'charset="iso8859-1"\', \'Content-ID: <4711>\'); $actual = $this->part->getHeaders(); foreach ($expectedHeaders as $expected) { $this->assertContains($expected, $actual); } } public function testContentEncoding() { // Test with base64 encoding $content = $this->part->getContent(); $this->assertEquals($this->_testText, base64_decode($content)); // Test with quotedPrintable Encoding: $this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $content = $this->part->getContent(); $this->assertEquals($this->_testText, quoted_printable_decode($content)); // Test with 8Bit encoding $this->part->encoding = Zend_Mime::ENCODING_8BIT; $content = $this->part->getContent(); $this->assertEquals($this->_testText, $content); } public function testStreamEncoding() { $testfile = realpath(__FILE__); $original = file_get_contents($testfile); // Test Base64 $fp = fopen($testfile,\'rb\'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_BASE64; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(base64_decode($encoded),$original); // test QuotedPrintable $fp = fopen($testfile,\'rb\'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(quoted_printable_decode($encoded),$original); } } '> is equal to _testText = \'safdsafsaˆlg ˆˆgdˆˆ sdˆjgˆsdjgˆldˆgksdˆgjˆsdfgˆdsjˆgjsdˆgjˆdfsjgˆdsfjˆdjsˆg kjhdkj \' . \'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg\'; $this->part = new Zend_Mime_Part($this->_testText); $this->part->encoding = Zend_Mime::ENCODING_BASE64; $this->part->type = "text/plain"; $this->part->filename = \'test.txt\'; $this->part->disposition = \'attachment\'; $this->part->charset = \'iso8859-1\'; $this->part->id = \'4711\'; } public function testHeaders() { $expectedHeaders = array(\'Content-Type: text/plain\', \'Content-Transfer-Encoding: \' . Zend_Mime::ENCODING_BASE64, \'Content-Disposition: attachment\', \'filename="test.txt"\', \'charset="iso8859-1"\', \'Content-ID: <4711>\'); $actual = $this->part->getHeaders(); foreach ($expectedHeaders as $expected) { $this->assertContains($expected, $actual); } } public function testContentEncoding() { // Test with base64 encoding $content = $this->part->getContent(); $this->assertEquals($this->_testText, base64_decode($content)); // Test with quotedPrintable Encoding: $this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $content = $this->part->getContent(); $this->assertEquals($this->_testText, quoted_printable_decode($content)); // Test with 8Bit encoding $this->part->encoding = Zend_Mime::ENCODING_8BIT; $content = $this->part->getContent(); $this->assertEquals($this->_testText, $content); } public function testStreamEncoding() { $testfile = realpath(__FILE__); $original = file_get_contents($testfile); // Test Base64 $fp = fopen($testfile,\'rb\'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_BASE64; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(base64_decode($encoded),$original); // test QuotedPrintable $fp = fopen($testfile,\'rb\'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(quoted_printable_decode($encoded),$o'> expected string <<?php /** * @package Zend_Mime * @subpackage UnitTests */ /** * Zend_Mime_Part */ require_once 'Zend/Mime/Part.php'; /** * PHPUnit2 test case */ require_once 'PHPUnit2/Framework/TestCase.php'; /** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText; protected function setUp() { $this->_testText = 'safdsafsaˆlg ˆˆgdˆˆ sdˆjgˆsdjgˆldˆgksdˆgjˆsdfgˆdsjˆgjsdˆgjˆdfsjgˆdsfjˆdjsˆg kjhdkj ' . 'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg'; $this->part = new Zend_Mime_Part($this->_testText); $this->part->encoding = Zend_Mime::ENCODING_BASE64; $this->part->type = "text/plain"; $this->part->filename = 'test.txt'; $this->part->disposition = 'attachment'; $this->part->charset = 'iso8859-1'; $this->part->id = '4711'; } public function testHeaders() { $expectedHeaders = array('Content-Type: text/plain', 'Content-Transfer-Encoding: ' . Zend_Mime::ENCODING_BASE64, 'Content-Disposition: attachment', 'filename="test.txt"', 'charset="iso8859-1"', 'Content-ID: <4711>'); $actual = $this->part->getHeaders(); foreach ($expectedHeaders as $expected) { $this->assertContains($expected, $actual); } } public function testContentEncoding() { // Test with base64 encoding $content = $this->part->getContent(); $this->assertEquals($this->_testText, base64_decode($content)); // Test with quotedPrintable Encoding: $this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $content = $this->part->getContent(); $this->assertEquals($this->_testText, quoted_printable_decode($content)); // Test with 8Bit encoding $this->part->encoding = Zend_Mime::ENCODING_8BIT; $content = $this->part->getContent(); $this->assertEquals($this->_testText, $content); } public function testStreamEncoding() { $testfile = realpath(__FILE__); $original = file_get_contents($testfile); // Test Base64 $fp = fopen($testfile,'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_BASE64; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(base64_decode($encoded),$original); // test QuotedPrintable $fp = fopen($testfile,'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(quoted_printable_decode($encoded),$o> difference < ??????????????????> got string <<?php /** * @package Zend_Mime * @subpackage UnitTests */ /** * Zend_Mime_Part */ require_once 'Zend/Mime/Part.php'; /** * PHPUnit2 test case */ require_once 'PHPUnit2/Framework/TestCase.php'; /** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText; protected function setUp() { $this->_testText = 'safdsafsaˆlg ˆˆgdˆˆ sdˆjgˆsdjgˆldˆgksdˆgjˆsdfgˆdsjˆgjsdˆgjˆdfsjgˆdsfjˆdjsˆg kjhdkj ' . 'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg'; $this->part = new Zend_Mime_Part($this->_testText); $this->part->encoding = Zend_Mime::ENCODING_BASE64; $this->part->type = "text/plain"; $this->part->filename = 'test.txt'; $this->part->disposition = 'attachment'; $this->part->charset = 'iso8859-1'; $this->part->id = '4711'; } public function testHeaders() { $expectedHeaders = array('Content-Type: text/plain', 'Content-Transfer-Encoding: ' . Zend_Mime::ENCODING_BASE64, 'Content-Disposition: attachment', 'filename="test.txt"', 'charset="iso8859-1"', 'Content-ID: <4711>'); $actual = $this->part->getHeaders(); foreach ($expectedHeaders as $expected) { $this->assertContains($expected, $actual); } } public function testContentEncoding() { // Test with base64 encoding $content = $this->part->getContent(); $this->assertEquals($this->_testText, base64_decode($content)); // Test with quotedPrintable Encoding: $this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $content = $this->part->getContent(); $this->assertEquals($this->_testText, quoted_printable_decode($content)); // Test with 8Bit encoding $this->part->encoding = Zend_Mime::ENCODING_8BIT; $content = $this->part->getContent(); $this->assertEquals($this->_testText, $content); } public function testStreamEncoding() { $testfile = realpath(__FILE__); $original = file_get_contents($testfile); // Test Base64 $fp = fopen($testfile,'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_BASE64; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(base64_decode($encoded),$original); // test QuotedPrintable $fp = fopen($testfile,'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(quoted_printable_decode($encoded),$original); } } > /webapps/tools/zend_framework/tests/Zend/Mime/PartTest.php:90 /webapps/tools/zend_framework/tests/Zend/Mime/AllTests.php:16 /webapps/tools/zend_framework/tests/Zend/Mime/AllTests.php:31 FAILURES! Tests: 8, Failures: 1.Posted by Elisamuel Resto (user00265) on 2006-06-21T06:30:37.000+0000
Not the same error, at least, I doesn't look like it, but it is a unit test failure, so I'll update this.
Versions: {{php -i}}
{{httpd -V}}
{{svn info | grep -i revision}}
Error returned:
ryuji@user00265 ~/Zend/Framework/tests $ php Zend/Mime/AllTests.php PHPUnit 2.3.6 by Sebastian Bergmann. ..F..... Time: 0.005915 There was 1 failure: 1) testStreamEncoding(Zend_Mime_PartTest) expected: <...> but was: <...riginal); } } > /home/ryuji/Zend/Framework/tests/Zend/Mime/PartTest.php:90 /home/ryuji/Zend/Framework/tests/Zend/Mime/AllTests.php:16 /home/ryuji/Zend/Framework/tests/Zend/Mime/AllTests.php:31 FAILURES!!! Tests run: 8, Failures: 1, Errors: 0, Incomplete Tests: 0.Posted by Matthew Weier O'Phinney (matthew) on 2006-06-21T21:16:44.000+0000
I found a syntax issue in the B64Filter (base64 stream conversion filter) where it was using a concatenation operator instead of addition operator. This fix was applied in patch 689.
Please test and update the ticket to indicate whether this corrects the testing issue.
Thanks!
Posted by Richard (openmacnews) on 2006-06-21T22:32:37.000+0000
w/ ZF Revision: 689, still problems ....
/webapps/tools/zend_framework/tests > php Zend/Mime/AllTests.php PHPUnit 3.0.0alpha11 by Sebastian Bergmann.
..F.....
Time: 00:00 There was 1 failure: 1) testStreamEncoding(Zend_Mime_PartTest) failed asserting that <'<?php /** * @package Zend_Mime * @subpackage UnitTests */
/** * Zend_Mime_Part */ require_once \'Zend/Mime/Part.php\';
/** * PHPUnit2 test case */ require_once \'PHPUnit2/Framework/TestCase.php\';
/** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText;
} '> is equal to <string:'<?php /** * @package Zend_Mime * @subpackage UnitTests */
/** * Zend_Mime_Part */ require_once \'Zend/Mime/Part.php\';
/** * PHPUnit2 test case */ require_once \'PHPUnit2/Framework/TestCase.php\';
/** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText;
expected string <<?php /** * @package Zend_Mime * @subpackage UnitTests */ /** * Zend_Mime_Part */ require_once 'Zend/Mime/Part.php'; /** * PHPUnit2 test case */ require_once 'PHPUnit2/Framework/TestCase.php'; /** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText; protected function setUp() { $this->_testText = 'safdsafsaˆlg ˆˆgdˆˆ sdˆjgˆsdjgˆldˆgksdˆgjˆsdfgˆdsjˆgjsdˆgjˆdfsjgˆdsfjˆdjsˆg kjhdkj ' . 'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg'; $this->part = new Zend_Mime_Part($this->_testText); $this->part->encoding = Zend_Mime::ENCODING_BASE64; $this->part->type = "text/plain"; $this->part->filename = 'test.txt'; $this->part->disposition = 'attachment'; $this->part->charset = 'iso8859-1'; $this->part->id = '4711'; } public function testHeaders() { $expectedHeaders = array('Content-Type: text/plain', 'Content-Transfer-Encoding: ' . Zend_Mime::ENCODING_BASE64, 'Content-Disposition: attachment', 'filename="test.txt"', 'charset="iso8859-1"', 'Content-ID: <4711>'); $actual = $this->part->getHeaders(); foreach ($expectedHeaders as $expected) { $this->assertContains($expected, $actual); } } public function testContentEncoding() { // Test with base64 encoding $content = $this->part->getContent(); $this->assertEquals($this->_testText, base64_decode($content)); // Test with quotedPrintable Encoding: $this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $content = $this->part->getContent(); $this->assertEquals($this->_testText, quoted_printable_decode($content)); // Test with 8Bit encoding $this->part->encoding = Zend_Mime::ENCODING_8BIT; $content = $this->part->getContent(); $this->assertEquals($this->_testText, $content); } public function testStreamEncoding() { $testfile = realpath(__FILE__); $original = file_get_contents($testfile); // Test Base64 $fp = fopen($testfile,'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_BASE64; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(base64_decode($encoded),$original); // test QuotedPrintable $fp = fopen($testfile,'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(quoted_printable_decode($encoded),$o> difference < ??????????????????> got string <<?php /** * @package Zend_Mime * @subpackage UnitTests */
/** * Zend_Mime_Part */ require_once 'Zend/Mime/Part.php';
/** * PHPUnit2 test case */ require_once 'PHPUnit2/Framework/TestCase.php';
/** * @package Zend_Mime * @subpackage UnitTests */ class Zend_Mime_PartTest extends PHPUnit2_Framework_TestCase { /** * MIME part test object * * @var Zend_Mime_Part */ protected $_part = null; protected $_testText;
} > /webapps/tools/zend_framework/tests/Zend/Mime/PartTest.php:90 /webapps/tools/zend_framework/tests/Zend/Mime/AllTests.php:16 /webapps/tools/zend_framework/tests/Zend/Mime/AllTests.php:31
FAILURES! Tests: 8, Failures: 1.
Posted by Matthew Weier O'Phinney (matthew) on 2006-06-22T09:20:49.000+0000
Patch 692 refactors the encoding to use native PHP stream conversion filters. Please update, run tests, and report the status of this fix.
Posted by Richard (openmacnews) on 2006-06-22T09:58:54.000+0000
w/ ZF r692,
php Zend/Mime/AllTests.php PHPUnit 3.0.0alpha11 by Sebastian Bergmann.
........
Time: 00:00
OK (8 tests)
which, if it's expected, looks like the issue is fixed.
thx,
richard
Posted by Matthew Weier O'Phinney (matthew) on 2006-06-22T10:24:37.000+0000
Fixed with patch 692.