mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-24 05:26:02 +03:00
Apply fixes from StyleCI and make sure we add MIT license properly (#163)
* Applied fixes from StyleCI * Create LICENSE
This commit is contained in:
parent
5d04bc63a7
commit
8fe342f5b9
17
LICENSE
Normal file
17
LICENSE
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Connection\Exceptions;
|
namespace Mailgun\Connection\Exceptions;
|
||||||
|
|
||||||
class GenericHTTPError extends \Exception
|
class GenericHTTPError extends \Exception
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Connection\Exceptions;
|
namespace Mailgun\Connection\Exceptions;
|
||||||
|
|
||||||
class InvalidCredentials extends \Exception
|
class InvalidCredentials extends \Exception
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Connection\Exceptions;
|
namespace Mailgun\Connection\Exceptions;
|
||||||
|
|
||||||
class MissingEndpoint extends \Exception
|
class MissingEndpoint extends \Exception
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Connection\Exceptions;
|
namespace Mailgun\Connection\Exceptions;
|
||||||
|
|
||||||
class MissingRequiredParameters extends \Exception
|
class MissingRequiredParameters extends \Exception
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Connection\Exceptions;
|
namespace Mailgun\Connection\Exceptions;
|
||||||
|
|
||||||
class NoDomainsConfigured extends \Exception
|
class NoDomainsConfigured extends \Exception
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Connection;
|
namespace Mailgun\Connection;
|
||||||
|
|
||||||
use Http\Client\HttpClient;
|
use Http\Client\HttpClient;
|
||||||
@ -254,7 +261,7 @@ class RestClient
|
|||||||
*
|
*
|
||||||
* @param string $fieldName
|
* @param string $fieldName
|
||||||
* @param string|array $filePath
|
* @param string|array $filePath
|
||||||
* @param integer $fileIndex
|
* @param int $fileIndex
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Constants;
|
namespace Mailgun\Constants;
|
||||||
|
|
||||||
class Api
|
class Api
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Constants;
|
namespace Mailgun\Constants;
|
||||||
|
|
||||||
class ExceptionMessages
|
class ExceptionMessages
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Lists;
|
namespace Mailgun\Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun;
|
namespace Mailgun;
|
||||||
|
|
||||||
use Http\Client\HttpClient;
|
use Http\Client\HttpClient;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Messages;
|
namespace Mailgun\Messages;
|
||||||
|
|
||||||
use Mailgun\Constants\Api;
|
use Mailgun\Constants\Api;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Messages\Exceptions;
|
namespace Mailgun\Messages\Exceptions;
|
||||||
|
|
||||||
class InvalidParameter extends \Exception
|
class InvalidParameter extends \Exception
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Messages\Exceptions;
|
namespace Mailgun\Messages\Exceptions;
|
||||||
|
|
||||||
class InvalidParameterType extends \Exception
|
class InvalidParameterType extends \Exception
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Messages\Exceptions;
|
namespace Mailgun\Messages\Exceptions;
|
||||||
|
|
||||||
class MissingRequiredMIMEParameters extends \Exception
|
class MissingRequiredMIMEParameters extends \Exception
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Messages\Exceptions;
|
namespace Mailgun\Messages\Exceptions;
|
||||||
|
|
||||||
class TooManyParameters extends \Exception
|
class TooManyParameters extends \Exception
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Messages;
|
namespace Mailgun\Messages;
|
||||||
|
|
||||||
use Mailgun\Constants\Api;
|
use Mailgun\Constants\Api;
|
||||||
@ -309,7 +316,6 @@ class MessageBuilder
|
|||||||
];
|
];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Functional;
|
namespace Mailgun\Tests\Functional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||||
*/
|
*/
|
||||||
class InlineFileTest extends \PHPUnit_Framework_TestCase
|
class InlineFileTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -13,7 +19,7 @@ class InlineFileTest extends \PHPUnit_Framework_TestCase
|
|||||||
$fileValidator = function ($files) {
|
$fileValidator = function ($files) {
|
||||||
$fileNames = [
|
$fileNames = [
|
||||||
['name' => 'inline[0]', 'filename' => 'foo.png'],
|
['name' => 'inline[0]', 'filename' => 'foo.png'],
|
||||||
['name'=>'inline[1]', 'filename'=>'bar.png']
|
['name' => 'inline[1]', 'filename' => 'bar.png'],
|
||||||
];
|
];
|
||||||
|
|
||||||
// Make sure that both files exists
|
// Make sure that both files exists
|
||||||
@ -33,14 +39,14 @@ class InlineFileTest extends \PHPUnit_Framework_TestCase
|
|||||||
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
||||||
|
|
||||||
$builder = $mailgun->MessageBuilder();
|
$builder = $mailgun->MessageBuilder();
|
||||||
$builder->setFromAddress("bob@example.com");
|
$builder->setFromAddress('bob@example.com');
|
||||||
$builder->addToRecipient("alice@example.com");
|
$builder->addToRecipient('alice@example.com');
|
||||||
$builder->setSubject("Foo");
|
$builder->setSubject('Foo');
|
||||||
$builder->setTextBody("Bar");
|
$builder->setTextBody('Bar');
|
||||||
|
|
||||||
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon1.png", 'foo.png');
|
$builder->addInlineImage('@./tests/TestAssets/mailgun_icon1.png', 'foo.png');
|
||||||
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon2.png", 'bar.png');
|
$builder->addInlineImage('@./tests/TestAssets/mailgun_icon2.png', 'bar.png');
|
||||||
|
|
||||||
$mailgun->post("domain/messages", $builder->getMessage(), $builder->getFiles());
|
$mailgun->post('domain/messages', $builder->getMessage(), $builder->getFiles());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Functional;
|
namespace Mailgun\Tests\Functional;
|
||||||
|
|
||||||
use Mailgun\Mailgun;
|
use Mailgun\Mailgun;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Functional;
|
namespace Mailgun\Tests\Functional;
|
||||||
|
|
||||||
use Mailgun\Connection\RestClient;
|
use Mailgun\Connection\RestClient;
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Functional;
|
namespace Mailgun\Tests\Functional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||||
*/
|
*/
|
||||||
class NoSamePostNameTest extends \PHPUnit_Framework_TestCase
|
class NoSamePostNameTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* No post names should ever be the same
|
* No post names should ever be the same.
|
||||||
*/
|
*/
|
||||||
public function testNames()
|
public function testNames()
|
||||||
{
|
{
|
||||||
@ -25,25 +31,25 @@ class NoSamePostNameTest extends \PHPUnit_Framework_TestCase
|
|||||||
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
||||||
|
|
||||||
$builder = $mailgun->MessageBuilder();
|
$builder = $mailgun->MessageBuilder();
|
||||||
$builder->setFromAddress("bob@example.com");
|
$builder->setFromAddress('bob@example.com');
|
||||||
$builder->addToRecipient("to1@example.com");
|
$builder->addToRecipient('to1@example.com');
|
||||||
$builder->addToRecipient("to2@example.com");
|
$builder->addToRecipient('to2@example.com');
|
||||||
$builder->addCcRecipient("cc1@example.com");
|
$builder->addCcRecipient('cc1@example.com');
|
||||||
$builder->addCcRecipient("cc2@example.com");
|
$builder->addCcRecipient('cc2@example.com');
|
||||||
$builder->addBccRecipient("bcc1@example.com");
|
$builder->addBccRecipient('bcc1@example.com');
|
||||||
$builder->addBccRecipient("bcc2@example.com");
|
$builder->addBccRecipient('bcc2@example.com');
|
||||||
$builder->addCustomParameter('foo', 'bar');
|
$builder->addCustomParameter('foo', 'bar');
|
||||||
$builder->addCustomParameter('foo', 'baz');
|
$builder->addCustomParameter('foo', 'baz');
|
||||||
$builder->addCampaignId('campaign0');
|
$builder->addCampaignId('campaign0');
|
||||||
$builder->addCampaignId('campaign1');
|
$builder->addCampaignId('campaign1');
|
||||||
$builder->setSubject("Foo");
|
$builder->setSubject('Foo');
|
||||||
$builder->setTextBody("Bar");
|
$builder->setTextBody('Bar');
|
||||||
|
|
||||||
$builder->addAttachment("@./tests/TestAssets/mailgun_icon1.png", 'foo.png');
|
$builder->addAttachment('@./tests/TestAssets/mailgun_icon1.png', 'foo.png');
|
||||||
$builder->addAttachment("@./tests/TestAssets/mailgun_icon1.png", 'foo.png');
|
$builder->addAttachment('@./tests/TestAssets/mailgun_icon1.png', 'foo.png');
|
||||||
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon2.png", 'bar.png');
|
$builder->addInlineImage('@./tests/TestAssets/mailgun_icon2.png', 'bar.png');
|
||||||
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon2.png", 'bar.png');
|
$builder->addInlineImage('@./tests/TestAssets/mailgun_icon2.png', 'bar.png');
|
||||||
|
|
||||||
$mailgun->post("domain/messages", $builder->getMessage(), $builder->getFiles());
|
$mailgun->post('domain/messages', $builder->getMessage(), $builder->getFiles());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Functional;
|
namespace Mailgun\Tests\Functional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple test to show how to use the MockedMailgun client
|
* Simple test to show how to use the MockedMailgun client.
|
||||||
*
|
*
|
||||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||||
*/
|
*/
|
||||||
@ -22,10 +29,10 @@ class SendMessageTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Create the mocked mailgun client. We use $this->assertEquals on $method, $uri and $body parameters.
|
// Create the mocked mailgun client. We use $this->assertEquals on $method, $uri and $body parameters.
|
||||||
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
||||||
|
|
||||||
$mailgun->sendMessage('domain', array(
|
$mailgun->sendMessage('domain', [
|
||||||
'from' => 'bob@example.com',
|
'from' => 'bob@example.com',
|
||||||
'to' => 'alice@example.com',
|
'to' => 'alice@example.com',
|
||||||
'subject' => 'Foo',
|
'subject' => 'Foo',
|
||||||
'text' => 'Bar'));
|
'text' => 'Bar', ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Lists;
|
namespace Mailgun\Tests\Lists;
|
||||||
|
|
||||||
use Mailgun\Tests\Mock\Mailgun;
|
use Mailgun\Tests\Mock\Mailgun;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests;
|
namespace Mailgun\Tests;
|
||||||
|
|
||||||
use Mailgun\Mailgun;
|
use Mailgun\Mailgun;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests;
|
namespace Mailgun\Tests;
|
||||||
|
|
||||||
abstract class MailgunTestCase extends \PHPUnit_Framework_TestCase
|
abstract class MailgunTestCase extends \PHPUnit_Framework_TestCase
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Messages;
|
namespace Mailgun\Tests\Messages;
|
||||||
|
|
||||||
use Mailgun\Tests\Mock\Mailgun;
|
use Mailgun\Tests\Mock\Mailgun;
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Messages;
|
namespace Mailgun\Tests\Messages;
|
||||||
|
|
||||||
use Mailgun\Tests\Mock\Mailgun;
|
|
||||||
use Mailgun\Connection\RestClient;
|
use Mailgun\Connection\RestClient;
|
||||||
|
use Mailgun\Tests\Mock\Mailgun;
|
||||||
|
|
||||||
|
class mockRestClient extends RestClient
|
||||||
class mockRestClient extends RestClient{
|
{
|
||||||
public function send($method, $uri, $body = null, $files = [], array $headers = [])
|
public function send($method, $uri, $body = null, $files = [], array $headers = [])
|
||||||
{
|
{
|
||||||
$result = new \stdClass;
|
$result = new \stdClass();
|
||||||
|
|
||||||
$result->method = $method;
|
$result->method = $method;
|
||||||
$result->uri = $uri;
|
$result->uri = $uri;
|
||||||
@ -21,7 +28,8 @@ class mockRestClient extends RestClient{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class mockMailgun extends Mailgun{
|
class mockMailgun extends Mailgun
|
||||||
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$apiKey = null,
|
$apiKey = null,
|
||||||
HttpClient $httpClient = null,
|
HttpClient $httpClient = null,
|
||||||
@ -44,25 +52,24 @@ class ComplexMessageTest extends \Mailgun\Tests\MailgunTestCase
|
|||||||
|
|
||||||
public function testSendComplexMessage()
|
public function testSendComplexMessage()
|
||||||
{
|
{
|
||||||
|
|
||||||
$message = [
|
$message = [
|
||||||
'to' => 'test@test.mailgun.org',
|
'to' => 'test@test.mailgun.org',
|
||||||
'from' => 'sender@test.mailgun.org',
|
'from' => 'sender@test.mailgun.org',
|
||||||
'subject' => 'This is my test subject',
|
'subject' => 'This is my test subject',
|
||||||
'text' => 'Testing!'
|
'text' => 'Testing!',
|
||||||
];
|
];
|
||||||
|
|
||||||
$files = [
|
$files = [
|
||||||
'inline' => [
|
'inline' => [
|
||||||
[
|
[
|
||||||
'remoteName' => 'mailgun_icon1.png',
|
'remoteName' => 'mailgun_icon1.png',
|
||||||
'filePath' => 'tests/TestAssets/mailgun_icon1.png'
|
'filePath' => 'tests/TestAssets/mailgun_icon1.png',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'remoteName' => 'mailgun_icon2.png',
|
'remoteName' => 'mailgun_icon2.png',
|
||||||
'filePath' => 'tests/TestAssets/mailgun_icon2.png'
|
'filePath' => 'tests/TestAssets/mailgun_icon2.png',
|
||||||
]
|
],
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = $this->client->sendMessage('test.mailgun.org', $message, $files);
|
$result = $this->client->sendMessage('test.mailgun.org', $message, $files);
|
||||||
@ -106,6 +113,5 @@ class ComplexMessageTest extends \Mailgun\Tests\MailgunTestCase
|
|||||||
|
|
||||||
$this->assertEquals([], $result->body);
|
$this->assertEquals([], $result->body);
|
||||||
$this->assertEquals([], $result->headers);
|
$this->assertEquals([], $result->headers);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Messages;
|
namespace Mailgun\Tests\Messages;
|
||||||
|
|
||||||
use Mailgun\Tests\Mock\Mailgun;
|
use Mailgun\Tests\Mock\Mailgun;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Messages;
|
namespace Mailgun\Tests\Messages;
|
||||||
|
|
||||||
use Mailgun\Tests\Mock\Mailgun;
|
use Mailgun\Tests\Mock\Mailgun;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Mock\Connection;
|
namespace Mailgun\Tests\Mock\Connection;
|
||||||
|
|
||||||
use Mailgun\Connection\Exceptions\GenericHTTPError;
|
use Mailgun\Connection\Exceptions\GenericHTTPError;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Mock;
|
namespace Mailgun\Tests\Mock;
|
||||||
|
|
||||||
use Mailgun\Mailgun as Base;
|
use Mailgun\Mailgun as Base;
|
||||||
|
Loading…
Reference in New Issue
Block a user