Fix fatal error in not finding exception.

Tried to throw MissingRequiredMIMEParameters which didn't exist in current namespace or added via use. Connection exceptions was included by MissingRequiredMIMEParameters is in messages exceptions so changed the added exception name to messages.

Exception message constant didn't exist. So added it.
This commit is contained in:
Iain Cambridge 2014-05-13 14:52:39 +01:00
parent 3af838f2c8
commit 502fac0b37
4 changed files with 22 additions and 3 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ mailgun_icon.png
build
composer.lock
nbproject/*
.idea

View File

@ -12,6 +12,7 @@ const DEFAULT_TIME_ZONE = "UTC";
const EXCEPTION_INVALID_CREDENTIALS = "Your credentials are incorrect.";
const EXCEPTION_GENERIC_HTTP_ERROR = "An HTTP Error has occurred! Check your network connection and try again.";
const EXCEPTION_MISSING_REQUIRED_PARAMETERS = "The parameters passed to the API were invalid. Check your inputs!";
const EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS = "The parameters passed to the API were invalid. Check your inputs!";
const EXCEPTION_MISSING_ENDPOINT = "The endpoint you've tried to access does not exist. Check your URL.";
const TOO_MANY_RECIPIENTS = "You've exceeded the maximum recipient count (1,000) on the to field with autosend disabled.";
const INVALID_PARAMETER_NON_ARRAY = "The parameter you've passed in position 2 must be an array.";

View File

@ -2,10 +2,10 @@
namespace Mailgun;
require 'Constants/Constants.php';
require_once 'Constants/Constants.php';
use Mailgun\Messages\Messages;
use Mailgun\Connection\Exceptions;
use Mailgun\Messages\Exceptions;
use Mailgun\Connection\RestClient;
use Mailgun\Messages\BatchMessage;
use Mailgun\Lists\OptInHandler;
@ -52,7 +52,7 @@ class Mailgun{
unlink($fileName);
}
else{
throw new MissingRequiredMIMEParameters(EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS);
throw new Exceptions\MissingRequiredMIMEParameters(EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS);
}
}

View File

@ -0,0 +1,17 @@
<?PHP
namespace Mailgun\Tests\Lists;
use Mailgun\Mailgun;
class MailgunTest extends \Mailgun\Tests\MailgunTestCase{
public function testSendMessageMissingRequiredMIMEParametersExceptionGetsFlung()
{
$this->setExpectedException("\\Mailgun\\Messages\\Exceptions\\MissingRequiredMIMEParameters");
$client = new Mailgun();
$client->sendMessage("test.mailgun.com", "etss", 1);
}
}
?>