Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2728' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Oct 16, 2012
4 parents b9d3f85 + de6ba8b + 19c92ef + a6996cb commit 730f592
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Header/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function toString()
*/
public function setType($type)
{
if (!preg_match('/^[a-z_-]+\/[a-z_-]+$/i', $type)) {
if (!preg_match('/^[a-z-]+\/[a-z0-9.+-]+$/i', $type)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a value in the format "type/subtype"; received "%s"',
__METHOD__,
Expand Down
21 changes: 21 additions & 0 deletions test/Header/ContentTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,25 @@ public function testExtractsExtraInformationFromContentType()
$this->assertEquals($params,array('boundary' => 'Apple-Mail=_1B852F10-F9C6-463D-AADD-CD503A5428DD'));
}

/**
* @group #2728
*
* Tests setting different MIME types
*/
public function testSetContentType()
{
$header = new ContentType();

$header->setType('application/vnd.ms-excel');
$this->assertEquals('Content-Type: application/vnd.ms-excel', $header->toString());

$header->setType('application/rss+xml');
$this->assertEquals('Content-Type: application/rss+xml', $header->toString());

$header->setType('video/mp4');
$this->assertEquals('Content-Type: video/mp4', $header->toString());

$header->setType('message/rfc822');
$this->assertEquals('Content-Type: message/rfc822', $header->toString());
}
}
5 changes: 4 additions & 1 deletion test/Storage/MaildirFolderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public function tearDown()
if (!file_exists($this->_tmpdir . $dir . '/' . $subdir)) {
continue;
}
if (!is_dir($this->_tmpdir . $dir . '/' . $subdir)) {
continue;
}
$dh = opendir($this->_tmpdir . $dir . '/' . $subdir);
while (($entry = readdir($dh)) !== false) {
$entry = $this->_tmpdir . $dir . '/' . $subdir . '/' . $entry;
Expand All @@ -100,7 +103,7 @@ public function tearDown()
closedir($dh);
rmdir($this->_tmpdir . $dir . '/' . $subdir);
}
if ($dir != '.') {
if ($dir != '.' && is_dir($this->_tmpdir . $dir)) {
rmdir($this->_tmpdir . $dir);
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/Storage/MaildirMessageOldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public function setUp()
public function tearDown()
{
foreach (array('cur', 'new') as $dir) {
if (!is_dir($this->_tmpdir . $dir)) {
continue;
}
$dh = opendir($this->_tmpdir . $dir);
while (($entry = readdir($dh)) !== false) {
$entry = $this->_tmpdir . $dir . '/' . $entry;
Expand Down
3 changes: 3 additions & 0 deletions test/Storage/MaildirTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public function setUp()
public function tearDown()
{
foreach (array('cur', 'new') as $dir) {
if (!is_dir($this->_tmpdir . $dir)) {
continue;
}
$dh = opendir($this->_tmpdir . $dir);
while (($entry = readdir($dh)) !== false) {
$entry = $this->_tmpdir . $dir . '/' . $entry;
Expand Down

0 comments on commit 730f592

Please sign in to comment.