Lots more tests!

This commit is contained in:
Robert Hafner 2013-12-18 16:16:33 -08:00
parent 806572b869
commit 7c9bc1d34f
3 changed files with 73 additions and 1 deletions

View File

@ -95,10 +95,21 @@ class AttachmentTest extends \PHPUnit_Framework_TestCase
$tmpdir = rtrim(sys_get_temp_dir(), '/') . '/';
$filepath = $tmpdir . 'RCA_Indian_Head_test_pattern.JPG.zip';
$attachment_RCA->saveToDirectory($tmpdir);
$this->assertTrue($attachment_RCA->saveToDirectory($tmpdir));
$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.');
}

View File

@ -174,7 +174,40 @@ class MessageTest extends \PHPUnit_Framework_TestCase
public function testMoveToMailbox()
{
$server = ServerTest::getServer();
// Testing by moving message from "Test Folder" to "Sent"
// Count Test Folder
$server->setMailBox('Test Folder');
$testFolderNumStart = $server->numMessages();
// Get message from Test Folder
$message = $server->getMessageByUid(1);
// Switch to Sent folder, count messages
$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'));
// Move the message!
$this->assertTrue($message->moveToMailBox('Sent'));
// Make sure we're still in the same folder
$this->assertEquals('Flagged Email', $server->getMailBox(), 'Returned Server back to right mailbox.');
$this->assertAttributeEquals('Sent', 'mailbox', $message, 'Message mailbox changed to new location.');
// Make sure Test Folder lost a message
$this->assertTrue($server->setMailBox('Test Folder'));
$this->assertEquals($testFolderNumStart - 1, $server->numMessages(), 'Message moved out of Test Folder.');
// Make sure Sent folder gains one
$this->assertTrue($server->setMailBox('Sent'));
$this->assertEquals($sentFolderNumStart + 1, $server->numMessages(), 'Message moved into Sent Folder.');
}

View File

@ -36,6 +36,17 @@ class ServerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(str_replace('%host%', TESTING_SERVER_HOST, $expected), $server->getServerString());
}
public function testFlagOverwrite()
{
$server = Static::getServer();
$server->setFlag('TestFlag', 'true');
$this->assertAttributeContains('TestFlag=true', 'flags', $server);
$server->setFlag('TestFlag', 'false');
$this->assertAttributeContains('TestFlag=false', 'flags', $server);
}
public function flagsDataProvider() {
return array(
array('{%host%:143/novalidate-cert}', 143, array()),
@ -140,6 +151,23 @@ class ServerTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($server->hasMailBox('Cheese'), 'Mailbox "Cheese" was created');
}
/**
* @expectedException \RuntimeException
*/
public function testSetOptionsException()
{
$server = Static::getServer();
$server->setOptions('purple');
}
public function testSetOptions()
{
$server = Static::getServer();
$server->setOptions(5);
$this->assertAttributeEquals(5, 'options', $server);
}
public function testExpunge()
{