Added meta files (#195)

* Added meta files

* Style fixes from StyleCI
This commit is contained in:
Tobias Nyholm 2016-10-15 02:20:46 +02:00 committed by Sean Johnson
parent fb377f7257
commit 043658f996
15 changed files with 106 additions and 46 deletions

9
.editorconfig Normal file
View File

@ -0,0 +1,9 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

15
.gitattributes vendored Normal file
View File

@ -0,0 +1,15 @@
.editorconfig export-ignore
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
/.php_cs export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/behat.yml.dist export-ignore
/features/ export-ignore
/phpspec.ci.yml export-ignore
/phpspec.yml.dist export-ignore
/phpunit.xml.dist export-ignore
/spec/ export-ignore
/tests/ export-ignore

13
.php_cs Normal file
View File

@ -0,0 +1,13 @@
<?php
/*
* In order to make it work, fabpot/php-cs-fixer and sllh/php-cs-fixer-styleci-bridge must be installed globally
* with composer.
*
* @link https://github.com/Soullivaneuh/php-cs-fixer-styleci-bridge
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer
*/
use SLLH\StyleCIBridge\ConfigBridge;
return ConfigBridge::create();

8
.scrutinizer.yml Normal file
View File

@ -0,0 +1,8 @@
filter:
paths: [src/*]
checks:
php:
code_rating: true
duplication: true
tools:
external_code_coverage: true

12
.styleci.yml Normal file
View File

@ -0,0 +1,12 @@
preset: symfony
finder:
path:
- "src"
- "tests"
enabled:
- short_array_syntax
disabled:
- phpdoc_annotation_without_dot # This is still buggy: https://github.com/symfony/symfony/pull/19198

View File

@ -54,6 +54,7 @@ class RestClient
* If we should use SSL or not.
*
* @var bool
*
* @deprecated To be removed in 3.0
*/
protected $sslEnabled = true;
@ -130,7 +131,7 @@ class RestClient
$fileIndex = 0;
foreach ($files[$fieldName] as $file) {
$postFiles[] = $this->prepareFile($fieldName, $file, $fileIndex);
$fileIndex++;
++$fileIndex;
}
} else {
$postFiles[] = $this->prepareFile($fieldName, $files[$fieldName]);
@ -144,13 +145,13 @@ class RestClient
$index = 0;
foreach ($value as $subValue) {
$postDataMultipart[] = [
'name' => sprintf('%s[%d]', $key, $index++),
'name' => sprintf('%s[%d]', $key, $index++),
'contents' => $subValue,
];
}
} else {
$postDataMultipart[] = [
'name' => $key,
'name' => $key,
'contents' => $value,
];
}
@ -296,7 +297,7 @@ class RestClient
$fieldName .= '['.$fileIndex.']';
return [
'name' => $fieldName,
'name' => $fieldName,
'contents' => $resource,
'filename' => $filename,
];
@ -352,6 +353,7 @@ class RestClient
* @param bool $sslEnabled
*
* @return RestClient
*
* @deprecated To be removed in 3.0
*/
public function setSslEnabled($sslEnabled)

View File

@ -173,6 +173,7 @@ class Mailgun
* @param bool $sslEnabled
*
* @return Mailgun
*
* @deprecated This will be removed in 3.0. Mailgun does not support non-secure connections to their API.
*/
public function setSslEnabled($sslEnabled)

View File

@ -44,15 +44,15 @@ class MessageBuilder
*/
protected $counters = [
'recipients' => [
'to' => 0,
'cc' => 0,
'to' => 0,
'cc' => 0,
'bcc' => 0,
],
'attributes' => [
'attachment' => 0,
'campaign_id' => 0,
'attachment' => 0,
'campaign_id' => 0,
'custom_option' => 0,
'tag' => 0,
'tag' => 0,
],
];
@ -280,14 +280,14 @@ class MessageBuilder
{
if (isset($this->files['attachment'])) {
$attachment = [
'filePath' => $attachmentPath,
'filePath' => $attachmentPath,
'remoteName' => $attachmentName,
];
array_push($this->files['attachment'], $attachment);
} else {
$this->files['attachment'] = [
[
'filePath' => $attachmentPath,
'filePath' => $attachmentPath,
'remoteName' => $attachmentName,
],
];
@ -311,7 +311,7 @@ class MessageBuilder
}
$this->files['inline'][] = [
'filePath' => $inlineImagePath,
'filePath' => $inlineImagePath,
'remoteName' => $inlineImageName,
];

View File

@ -20,7 +20,7 @@ class FileFromMemoryTest extends \PHPUnit_Framework_TestCase
// Convert resources to strings
$attachments = array_map(function ($f) {
return [
'name' => $f['name'],
'name' => $f['name'],
'contents' => fread($f['contents'], 50),
'filename' => $f['filename'],
];
@ -40,10 +40,10 @@ class FileFromMemoryTest extends \PHPUnit_Framework_TestCase
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
$mailgun->sendMessage('domain', [
'from' => 'bob@example.com',
'to' => 'alice@example.com',
'subject' => 'Foo',
'text' => 'Bar', ], [
'from' => 'bob@example.com',
'to' => 'alice@example.com',
'subject' => 'Foo',
'text' => 'Bar', ], [
'attachment' => $attachments,
]);
}

View File

@ -30,9 +30,9 @@ class SendMessageTest extends \PHPUnit_Framework_TestCase
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
$mailgun->sendMessage('domain', [
'from' => 'bob@example.com',
'to' => 'alice@example.com',
'from' => 'bob@example.com',
'to' => 'alice@example.com',
'subject' => 'Foo',
'text' => 'Bar', ]);
'text' => 'Bar', ]);
}
}

View File

@ -26,7 +26,7 @@ class MailgunTest extends \Mailgun\Tests\MailgunTestCase
$client = new Mailgun('key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
$postData = [
'timestamp' => '1403645220',
'token' => '5egbgr1vjgqxtrnp65xfznchgdccwh5d6i09vijqi3whgowmn6',
'token' => '5egbgr1vjgqxtrnp65xfznchgdccwh5d6i09vijqi3whgowmn6',
'signature' => '9cfc5c41582e51246e73c88d34db3af0a3a2692a76fbab81492842f000256d33',
];
assert($client->verifyWebhookSignature($postData));
@ -37,7 +37,7 @@ class MailgunTest extends \Mailgun\Tests\MailgunTestCase
$client = new Mailgun('key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
$postData = [
'timestamp' => '1403645220',
'token' => 'owyldpe6nxhmrn78epljl6bj0orrki1u3d2v5e6cnlmmuox8jr',
'token' => 'owyldpe6nxhmrn78epljl6bj0orrki1u3d2v5e6cnlmmuox8jr',
'signature' => '9cfc5c41582e51246e73c88d34db3af0a3a2692a76fbab81492842f000256d33',
];
assert(!$client->verifyWebhookSignature($postData));

View File

@ -103,7 +103,7 @@ class BatchMessageTest extends \Mailgun\Tests\MailgunTestCase
public function testAddMultipleBatchRecipients()
{
$message = $this->client->BatchMessage($this->sampleDomain);
for ($i = 0; $i < 100; $i++) {
for ($i = 0; $i < 100; ++$i) {
$message->addToRecipient("$i@samples.mailgun.org", ['first' => 'Test', 'last' => "User $i"]);
}
$messageObj = $message->getMessage();
@ -116,7 +116,7 @@ class BatchMessageTest extends \Mailgun\Tests\MailgunTestCase
$message->setFromAddress('samples@mailgun.org', ['first' => 'Test', 'last' => 'User']);
$message->setSubject('This is the subject of the message!');
$message->setTextBody('This is the text body of the message!');
for ($i = 0; $i < 1001; $i++) {
for ($i = 0; $i < 1001; ++$i) {
$message->addToRecipient("$i@samples.mailgun.org", ['first' => 'Test', 'last' => "User $i"]);
}
$messageObj = $message->getMessage();

View File

@ -53,21 +53,21 @@ class ComplexMessageTest extends \Mailgun\Tests\MailgunTestCase
public function testSendComplexMessage()
{
$message = [
'to' => 'test@test.mailgun.org',
'from' => 'sender@test.mailgun.org',
'to' => 'test@test.mailgun.org',
'from' => 'sender@test.mailgun.org',
'subject' => 'This is my test subject',
'text' => 'Testing!',
'text' => 'Testing!',
];
$files = [
'inline' => [
[
'remoteName' => 'mailgun_icon1.png',
'filePath' => 'tests/TestAssets/mailgun_icon1.png',
'filePath' => 'tests/TestAssets/mailgun_icon1.png',
],
[
'remoteName' => 'mailgun_icon2.png',
'filePath' => 'tests/TestAssets/mailgun_icon2.png',
'filePath' => 'tests/TestAssets/mailgun_icon2.png',
],
],
];
@ -84,27 +84,27 @@ class ComplexMessageTest extends \Mailgun\Tests\MailgunTestCase
foreach ($result->files as $file) {
if ($file['name'] == 'to') {
$this->assertEquals($file['contents'], 'test@test.mailgun.org');
$testCount++;
++$testCount;
}
if ($file['name'] == 'from') {
$this->assertEquals($file['contents'], 'sender@test.mailgun.org');
$testCount++;
++$testCount;
}
if ($file['name'] == 'subject') {
$this->assertEquals($file['contents'], 'This is my test subject');
$testCount++;
++$testCount;
}
if ($file['name'] == 'text') {
$this->assertEquals($file['contents'], 'Testing!');
$testCount++;
++$testCount;
}
if ($file['name'] == 'inline[0]') {
$this->assertEquals($file['filename'], 'mailgun_icon1.png');
$testCount++;
++$testCount;
}
if ($file['name'] == 'inline[1]') {
$this->assertEquals($file['filename'], 'mailgun_icon2.png');
$testCount++;
++$testCount;
}
}

View File

@ -160,11 +160,11 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase
$this->assertEquals(
[
[
'filePath' => '@../TestAssets/mailgun_icon.png',
'filePath' => '@../TestAssets/mailgun_icon.png',
'remoteName' => null,
],
[
'filePath' => '@../TestAssets/rackspace_logo.png',
'filePath' => '@../TestAssets/rackspace_logo.png',
'remoteName' => null,
],
],
@ -181,11 +181,11 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase
$this->assertEquals(
[
[
'filePath' => '@../TestAssets/mailgun_icon.png',
'filePath' => '@../TestAssets/mailgun_icon.png',
'remoteName' => null,
],
[
'filePath' => '@../TestAssets/rackspace_logo.png',
'filePath' => '@../TestAssets/rackspace_logo.png',
'remoteName' => null,
],
],
@ -202,11 +202,11 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase
$this->assertEquals(
[
[
'filePath' => '@../TestAssets/mailgun_icon.png',
'filePath' => '@../TestAssets/mailgun_icon.png',
'remoteName' => 'mg_icon.png',
],
[
'filePath' => '@../TestAssets/rackspace_logo.png',
'filePath' => '@../TestAssets/rackspace_logo.png',
'remoteName' => 'rs_logo.png',
],
],
@ -223,11 +223,11 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase
$this->assertEquals(
[
[
'filePath' => '@../TestAssets/mailgun_icon.png',
'filePath' => '@../TestAssets/mailgun_icon.png',
'remoteName' => 'mg_icon.png',
],
[
'filePath' => '@../TestAssets/rackspace_logo.png',
'filePath' => '@../TestAssets/rackspace_logo.png',
'remoteName' => 'rs_logo.png',
],
],

View File

@ -43,10 +43,10 @@ class StandardMessageTest extends \Mailgun\Tests\MailgunTestCase
public function testSendMessage()
{
$message = ['to' => 'test@test.mailgun.org',
'from' => 'sender@test.mailgun.org',
$message = ['to' => 'test@test.mailgun.org',
'from' => 'sender@test.mailgun.org',
'subject' => 'This is my test subject',
'text' => 'Testing!',
'text' => 'Testing!',
];
$result = $this->client->sendMessage('test.mailgun.org', $message);
$this->assertEquals('test.mailgun.org/messages', $result->http_endpoint_url);