Applied fixes from StyleCI (#177)

This commit is contained in:
David Garcia 2016-09-27 15:23:08 +02:00 committed by Tobias Nyholm
parent aafd84b0ce
commit 6513c12d8c

View File

@ -3,7 +3,7 @@
namespace Mailgun\Tests\Functional; namespace Mailgun\Tests\Functional;
/** /**
* Add attachment with file from memory * Add attachment with file from memory.
* *
* @author Wim Verstuyf <wim.verstuyf@codelicious.be> * @author Wim Verstuyf <wim.verstuyf@codelicious.be>
*/ */
@ -11,14 +11,14 @@ class FileFromMemoryTest extends \PHPUnit_Framework_TestCase
{ {
public function testAddFileFromMemory() public function testAddFileFromMemory()
{ {
$fileValidator = function($files) { $fileValidator = function ($files) {
// Get only the attachments so the properties can be converted to a format we like // Get only the attachments so the properties can be converted to a format we like
$attachments = array_filter($files, function($f) { $attachments = array_filter($files, function ($f) {
return strpos($f['name'], 'attachment') !== false; return strpos($f['name'], 'attachment') !== false;
}); });
// Convert resources to strings // Convert resources to strings
$attachments = array_map(function($f) { $attachments = array_map(function ($f) {
return [ return [
'name' => $f['name'], 'name' => $f['name'],
'contents' => fread($f['contents'], 50), 'contents' => fread($f['contents'], 50),
@ -26,25 +26,25 @@ class FileFromMemoryTest extends \PHPUnit_Framework_TestCase
]; ];
}, $attachments); }, $attachments);
$this->assertContains(['name'=>'attachment[0]', 'contents'=>'File content', 'filename' => 'file1.txt'], $attachments); $this->assertContains(['name' => 'attachment[0]', 'contents' => 'File content', 'filename' => 'file1.txt'], $attachments);
$this->assertContains(['name'=>'attachment[1]', 'contents'=>'File content 2', 'filename' => 'file2.txt'], $attachments); $this->assertContains(['name' => 'attachment[1]', 'contents' => 'File content 2', 'filename' => 'file2.txt'], $attachments);
$this->assertContains(['name'=>'attachment[2]', 'contents'=>'Contents of a text file', 'filename' => 'text_file.txt'], $attachments); $this->assertContains(['name' => 'attachment[2]', 'contents' => 'Contents of a text file', 'filename' => 'text_file.txt'], $attachments);
}; };
$attachments = [ $attachments = [
['filename' => 'file1.txt', 'fileContent' => "File content"], ['filename' => 'file1.txt', 'fileContent' => 'File content'],
['filename' => 'file2.txt', 'fileContent' => "File content 2"], ['filename' => 'file2.txt', 'fileContent' => 'File content 2'],
['filePath' => "./tests/TestAssets/text_file.txt", 'remoteName' => 'text_file.txt'] ['filePath' => './tests/TestAssets/text_file.txt', 'remoteName' => 'text_file.txt'],
]; ];
$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'), array( 'text' => 'Bar', ], [
'attachment' => $attachments 'attachment' => $attachments,
)); ]);
} }
} }