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

Commit

Permalink
zendframework/zendframework#6775 - refactoring test logic to avoid ma…
Browse files Browse the repository at this point in the history
…gic `setUp` logic based on test name
  • Loading branch information
Ocramius committed Dec 31, 2014
1 parent 7af9989 commit 14ba047
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions test/Storage/MboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ public function setUp()
$this->_mboxFile = $this->_tmpdir . 'INBOX';

copy($this->_mboxOriginalFile, $this->_mboxFile);

if (strpos($this->getName(), 'Unix')) {
$this->_mboxOriginalFileLinux = __DIR__ . '/../_files/test.mbox/INBOX.unix';
$this->_mboxFileUnix = $this->_tmpdir . 'INBOX.unix';
copy($this->_mboxOriginalFileLinux, $this->_mboxFileUnix);
}
}

public function tearDown()
Expand Down Expand Up @@ -168,7 +162,7 @@ public function testFetchTopBody()

public function testFetchMessageHeaderUnix()
{
$mail = new Storage\Mbox(array('filename' => $this->_mboxFileUnix, 'messageEOL' => "\n"));
$mail = new Storage\Mbox(array('filename' => $this->getUnixMboxFile(), 'messageEOL' => "\n"));

$subject = $mail->getMessage(1)->subject;
$this->assertEquals('Simple Message', $subject);
Expand All @@ -193,7 +187,7 @@ public function testFetchMessageBody()

public function testFetchMessageBodyUnix()
{
$mail = new Storage\Mbox(array('filename' => $this->_mboxFileUnix, 'messageEOL' => "\n"));
$mail = new Storage\Mbox(array('filename' => $this->getUnixMboxFile(), 'messageEOL' => "\n"));

$content = $mail->getMessage(3)->getContent();
list($content, ) = explode("\n", $content, 2);
Expand Down Expand Up @@ -323,4 +317,16 @@ public function testShortMbox()
$this->assertEquals($mail->getMessage(2)->subject, 'test2');
$this->assertEquals($mail->getMessage(2)->getContent(), '');
}

/**
* @return string
*/
private function getUnixMboxFile()
{
$this->_mboxFileUnix = $this->_tmpdir . 'INBOX.unix';

copy(__DIR__ . '/../_files/test.mbox/INBOX.unix', $this->_mboxFileUnix);

return $this->_mboxFileUnix;
}
}

0 comments on commit 14ba047

Please sign in to comment.