From 14ba04710fd41ecdb3396458c4920559fb256ad2 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 31 Dec 2014 10:47:16 +0100 Subject: [PATCH] zendframework/zf2#6775 - refactoring test logic to avoid magic `setUp` logic based on test name --- test/Storage/MboxTest.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/test/Storage/MboxTest.php b/test/Storage/MboxTest.php index fe45ff37..d390081e 100644 --- a/test/Storage/MboxTest.php +++ b/test/Storage/MboxTest.php @@ -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() @@ -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); @@ -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); @@ -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; + } }