Formatting! PSR Compliance

This commit is contained in:
Robert Hafner 2014-04-16 00:35:51 -07:00
parent faaff0711d
commit 1725eb2f8b
8 changed files with 36 additions and 42 deletions

View File

@ -169,7 +169,6 @@ class Message
*/
public static $charset = 'UTF-8//TRANSLIT';
/**
* This constructor takes in the uid for the message and the Imap class representing the mailbox the
* message should be opened from. This constructor should generally not be called directly, but rather retrieved
@ -199,6 +198,7 @@ class Message
/* First load the message overview information */
if(!is_object($messageOverview = $this->getOverview()))
return false;
$this->subject = $messageOverview->subject;
@ -422,7 +422,6 @@ class Message
*
* @param \stdClass $structure
* @param string $partIdentifier
* @todoa process attachments.
*/
protected function processStructure($structure, $partIdentifier = null)
{
@ -649,9 +648,11 @@ class Message
if ($enable === true) {
$this->status[$flag] = true;
return imap_setflag_full($this->imapStream, $this->uid, $imapifiedFlag, ST_UID);
} else {
unset($this->status[$flag]);
return imap_clearflag_full($this->imapStream, $this->uid, $imapifiedFlag, ST_UID);
}
}

View File

@ -155,8 +155,11 @@ class Server
*/
public function setMailBox($mailbox = '')
{
if(!$this->hasMailBox($mailbox))
if (!$this->hasMailBox($mailbox)) {
return false;
}
$this->mailbox = $mailbox;
if (isset($this->imapStream)) {
@ -381,13 +384,13 @@ class Server
{
try {
$message = new \Fetch\Message($uid, $this);
return $message;
} catch (\Exception $e) {
return false;
}
}
/**
* This function removes all of the messages flagged for deletion from the mailbox.
*

View File

@ -11,7 +11,6 @@
namespace Fetch\Test;
/**
* @package Fetch
* @author Robert Hafner <tedivm@tedivm.com>
@ -27,6 +26,7 @@ class AttachmentTest extends \PHPUnit_Framework_TestCase
$returnAttachments = array();
foreach($attachments as $attachment)
$returnAttachments[$attachment->getFileName()] = $attachment;
return $returnAttachments;
}
@ -100,20 +100,16 @@ class AttachmentTest extends \PHPUnit_Framework_TestCase
$this->assertFileExists($filepath);
$this->assertEquals(md5(file_get_contents($filepath)), md5($attachment_RCA->getData()));
$attachments = static::getAttachments('6');
$attachment_RCA = $attachments['RCA_Indian_Head_test_pattern.JPG.zip'];
$this->assertFalse($attachment_RCA->saveToDirectory('/'), 'Returns false when attempting to save without filesystem permission.');
$attachments = static::getAttachments('6');
$attachment_RCA = $attachments['RCA_Indian_Head_test_pattern.JPG.zip'];
$this->assertFalse($attachment_RCA->saveToDirectory($filepath), 'Returns false when attempting to save over a file.');
}
static function tearDownAfterClass()
public static function tearDownAfterClass()
{
$tmpdir = rtrim(sys_get_temp_dir(), '/') . '/';
$filepath = $tmpdir . 'RCA_Indian_Head_test_pattern.JPG.zip';

View File

@ -12,7 +12,6 @@
namespace Fetch\Test;
use Fetch\Message;
/**
* @package Fetch
* @author Robert Hafner <tedivm@tedivm.com>
@ -22,6 +21,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
public static function getMessage($id)
{
$server = ServerTest::getServer();
return new \Fetch\Message($id, $server);
}
@ -68,7 +68,6 @@ class MessageTest extends \PHPUnit_Framework_TestCase
$messageNonHTML = $message->getMessageBody();
$this->assertEquals($plaintextTest, md5($messageNonHTML), 'Message returns as plaintext.');
$messageHTML = $message->getMessageBody(true);
$this->assertEquals($convertedHtmlTest, md5($messageHTML), 'Message converts from plaintext to HTML when requested.');
@ -130,14 +129,12 @@ class MessageTest extends \PHPUnit_Framework_TestCase
$messageWithoutAttachments = static::getMessage('3');
$this->assertFalse($messageWithoutAttachments->getAttachments(), 'getAttachments returns false when no attachments present.');
$messageWithAttachments = static::getMessage('6');
$attachments = $messageWithAttachments->getAttachments();
$this->assertCount(2, $attachments);
foreach($attachments as $attachment)
$this->assertInstanceOf('\Fetch\Attachment', $attachment, 'getAttachments returns Fetch\Attachment objects.');
$attachment = $messageWithAttachments->getAttachments('Test_card.png.zip');
$this->assertInstanceOf('\Fetch\Attachment', $attachment, 'getAttachment returns specified Fetch\Attachment object.');
}
@ -160,7 +157,6 @@ class MessageTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($message->setFlag('answered', false), 'setFlag returned true.');
$this->assertFalse($message->checkFlag('answered'), 'Message was successfully unanswered.');
$message = static::getMessage('2');
$this->assertFalse($message->checkFlag('flagged'), 'Message is not flagged.');
@ -190,7 +186,6 @@ class MessageTest extends \PHPUnit_Framework_TestCase
$server->setMailBox('Sent');
$sentFolderNumStart = $server->numMessages();
// Switch to "Flagged" folder in order to test that function properly returns to it
$this->assertTrue($server->setMailBox('Flagged Email'));
@ -246,5 +241,4 @@ class MessageTest extends \PHPUnit_Framework_TestCase
}
}

View File

@ -47,7 +47,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase
$this->assertAttributeContains('TestFlag=false', 'flags', $server);
}
public function flagsDataProvider() {
public function flagsDataProvider()
{
return array(
array('{%host%:143/novalidate-cert}', 143, array()),
array('{%host%:143/validate-cert}', 143, array('validate-cert' => true)),
@ -84,7 +85,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase
$this->assertInternalType('resource', $imapSteam, $message);
}
public function connectionDataProvider() {
public function connectionDataProvider()
{
return array(
array(143, array(), 'Connects with default settings.'),
array(993, array('novalidate-cert' => true), 'Connects over SSL (self signed).'),
@ -160,7 +162,6 @@ class ServerTest extends \PHPUnit_Framework_TestCase
$server->setOptions('purple');
}
public function testSetOptions()
{
$server = Static::getServer();
@ -168,7 +169,6 @@ class ServerTest extends \PHPUnit_Framework_TestCase
$this->assertAttributeEquals(5, 'options', $server);
}
public function testExpunge()
{
$server = Static::getServer();
@ -185,10 +185,11 @@ class ServerTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($server->getMessageByUid(12), 'Message successfully expunged');
}
static public function getServer()
public static function getServer()
{
$server = new Server(TESTING_SERVER_HOST, 143);
$server->setAuthentication(TEST_USER, TEST_PASSWORD);
return $server;
}
}

View File

@ -17,8 +17,7 @@ define('TEST_PASSWORD', 'applesauce');
date_default_timezone_set('UTC');
if(getenv('TRAVIS'))
{
if (getenv('TRAVIS')) {
define('TESTING_ENVIRONMENT', 'TRAVIS');
define('TESTING_SERVER_HOST', '127.0.0.1');
} else {