mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-25 14:26:04 +03:00
Added tests and use PSR4
This commit is contained in:
parent
0a7c96c34a
commit
cd001cf5b3
@ -14,10 +14,14 @@
|
|||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
"Mailgun\\Tests": "tests/",
|
|
||||||
"Mailgun": "src/"
|
"Mailgun": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Mailgun\\Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit bootstrap="tests/Bootstrap.php"
|
<phpunit bootstrap="vendor/autoload.php"
|
||||||
colors="true"
|
colors="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="false"
|
stopOnFailure="false"
|
||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite>
|
<testsuite>
|
||||||
<directory>tests/Mailgun/Tests</directory>
|
<directory>tests</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
//Grab the composer Autoloader!
|
|
||||||
$autoloader = include dirname(__DIR__).'/vendor/autoload.php';
|
|
51
tests/Functional/InlineFileTest.php
Normal file
51
tests/Functional/InlineFileTest.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Mailgun\Tests\Functional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||||
|
*/
|
||||||
|
class InlineFileTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testSimpleExample()
|
||||||
|
{
|
||||||
|
// Create a Closure that validates the $files parameter to RestClient::send()
|
||||||
|
$fileValidator = function($files) {
|
||||||
|
// Validate standard params
|
||||||
|
$this->assertContains(['name'=>'from', 'contents'=>'bob@example.com'], $files);
|
||||||
|
$this->assertContains(['name'=>'to', 'contents'=>'alice@example.com'], $files);
|
||||||
|
$this->assertContains(['name'=>'subject', 'contents'=>'Foo'], $files);
|
||||||
|
$this->assertContains(['name'=>'text', 'contents'=>'Bar'], $files);
|
||||||
|
|
||||||
|
$fileNames = [
|
||||||
|
['name'=>'inline[0]', 'filename'=>'foo.png'],
|
||||||
|
['name'=>'inline[1]', 'filename'=>'bar.png']
|
||||||
|
];
|
||||||
|
foreach ($fileNames as $idx => $fileName) {
|
||||||
|
foreach ($files as $file) {
|
||||||
|
if ($file['name'] === $fileName['name'] && $file['filename'] === $fileName['filename']) {
|
||||||
|
unset ($fileNames[$idx]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEmpty($fileNames, 'Filenames could not be found');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create the mocked mailgun client. We use $this->assertEquals on $method, $uri and $body parameters.
|
||||||
|
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
||||||
|
|
||||||
|
$builder = $mailgun->MessageBuilder();
|
||||||
|
$builder->setFromAddress("bob@example.com");
|
||||||
|
$builder->addToRecipient("alice@example.com");
|
||||||
|
$builder->setSubject("Foo");
|
||||||
|
$builder->setTextBody("Bar");
|
||||||
|
|
||||||
|
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon1.png", 'foo.png');
|
||||||
|
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon2.png", 'bar.png');
|
||||||
|
|
||||||
|
$mailgun->post("domain/messages", $builder->getMessage(), $builder->getFiles());
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 85 KiB |
Binary file not shown.
Before Width: | Height: | Size: 44 KiB |
@ -1,6 +1,6 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
|
|
||||||
namespace Mailgun\Tests\Lists;
|
namespace Mailgun\Tests;
|
||||||
|
|
||||||
use Mailgun\Mailgun;
|
use Mailgun\Mailgun;
|
||||||
|
|
@ -56,11 +56,11 @@ class ComplexMessageTest extends \Mailgun\Tests\MailgunTestCase
|
|||||||
'inline' => [
|
'inline' => [
|
||||||
[
|
[
|
||||||
'remoteName'=> 'mailgun_icon1.png',
|
'remoteName'=> 'mailgun_icon1.png',
|
||||||
'filePath' => 'tests/Mailgun/Tests/TestAssets/mailgun_icon1.png'
|
'filePath' => 'tests/TestAssets/mailgun_icon1.png'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'remoteName'=> 'mailgun_icon2.png',
|
'remoteName'=> 'mailgun_icon2.png',
|
||||||
'filePath' => 'tests/Mailgun/Tests/TestAssets/mailgun_icon2.png'
|
'filePath' => 'tests/TestAssets/mailgun_icon2.png'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
Loading…
Reference in New Issue
Block a user