summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornornholdj <nornholdj@gmail.com>2014-10-22 14:17:50 -0400
committernornholdj <nornholdj@gmail.com>2014-10-22 14:17:50 -0400
commitd9d40f3ce24068d5a0d0fecb4aa9cffcf15c5555 (patch)
tree647689c543d74b2d2cda0ed96f298f0df50f0c1e
parent7a503d6b918832568ff751368aae7be797d47aa1 (diff)
downloadphp-sparkpost-d9d40f3ce24068d5a0d0fecb4aa9cffcf15c5555.zip
php-sparkpost-d9d40f3ce24068d5a0d0fecb4aa9cffcf15c5555.tar.gz
php-sparkpost-d9d40f3ce24068d5a0d0fecb4aa9cffcf15c5555.tar.bz2
MA-946 #time 6h finished adding node-sdk function parity. Started on unit tests and setup test code coverage.
-rw-r--r--.gitignore1
-rw-r--r--RoboFile.php27
-rw-r--r--composer.json5
-rw-r--r--composer.lock512
-rw-r--r--index.php1
-rw-r--r--lib/MessageSystems/Transmission.php173
-rw-r--r--test/transmissionTest.php32
-rw-r--r--test/unit/transmissionTest.php65
8 files changed, 722 insertions, 94 deletions
diff --git a/.gitignore b/.gitignore
index 2e0ac36..8b03c34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
.project
.settings
.buildPath
+test/output/
diff --git a/RoboFile.php b/RoboFile.php
new file mode 100644
index 0000000..cdb49ab
--- /dev/null
+++ b/RoboFile.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * This is project's console commands configuration for Robo task runner.
+ *
+ * @see http://robo.li/
+ */
+class RoboFile extends \Robo\Tasks
+{
+ public function test () {
+// $coverage = new PHP_CodeCoverage();
+// $coverage->start('PHP-SDK Unit Tests');
+// $this->taskPHPUnit('./test/unit/')->run();
+ $res = $this->taskExec('phpunit --coverage-html test/output/report --bootstrap ./vendor/autoload.php ./test/unit')->run();
+
+ // print message when tests passed
+ if ($res->wasSuccessful()) $this->say("All tests passed");
+
+ // alternatively
+ if ($res()) $this->say("All tests passed");
+
+// $coverage->stop();
+// $writer = new PHP_CodeCoverage_Report_HTML;
+// $writer->process($coverage, 'test/output/report');
+
+ return $res();
+ }
+} \ No newline at end of file
diff --git a/composer.json b/composer.json
index d414b4f..bab9bac 100644
--- a/composer.json
+++ b/composer.json
@@ -8,13 +8,14 @@
"email": "info@messagesystems.com"
}
],
- "minimum-stability": "dev",
+ "minimum-stability": "stable",
"require": {
"php": ">=5.6.1",
"guzzlehttp/guzzle": "5.0.1"
},
"require-dev": {
- "phpunit/phpunit": "4.3.*"
+ "phpunit/phpunit": "4.3.*",
+ "codegyre/robo": "0.4.6"
},
"autoload": {
"psr-0": {
diff --git a/composer.lock b/composer.lock
index 1bc5301..ef3132f 100644
--- a/composer.lock
+++ b/composer.lock
@@ -3,7 +3,7 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
- "hash": "bf18d8b18926cb9d83f5564876f42756",
+ "hash": "d5f1714c86afc4c3ef134d8a2f39b529",
"packages": [
{
"name": "guzzlehttp/guzzle",
@@ -65,16 +65,16 @@
},
{
"name": "guzzlehttp/ringphp",
- "version": "dev-master",
+ "version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/RingPHP.git",
- "reference": "bbf23555a557fc91fb5ef6edbd23a1f17188cd4b"
+ "reference": "9e44b565d726d9614cd970319e6eea70ee15bff3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/bbf23555a557fc91fb5ef6edbd23a1f17188cd4b",
- "reference": "bbf23555a557fc91fb5ef6edbd23a1f17188cd4b",
+ "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/9e44b565d726d9614cd970319e6eea70ee15bff3",
+ "reference": "9e44b565d726d9614cd970319e6eea70ee15bff3",
"shasum": ""
},
"require": {
@@ -111,20 +111,20 @@
"homepage": "https://github.com/mtdowling"
}
],
- "time": "2014-10-15 20:34:26"
+ "time": "2014-10-13 00:59:38"
},
{
"name": "guzzlehttp/streams",
- "version": "dev-master",
+ "version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/streams.git",
- "reference": "48be63a56ea8a98ec620eb59ef76bcab77feba55"
+ "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/streams/zipball/48be63a56ea8a98ec620eb59ef76bcab77feba55",
- "reference": "48be63a56ea8a98ec620eb59ef76bcab77feba55",
+ "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
+ "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"shasum": ""
},
"require": {
@@ -161,7 +161,7 @@
"Guzzle",
"stream"
],
- "time": "2014-10-12 19:45:36"
+ "time": "2014-10-12 19:18:40"
},
{
"name": "react/promise",
@@ -210,8 +210,57 @@
],
"packages-dev": [
{
+ "name": "codegyre/robo",
+ "version": "0.4.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Codegyre/Robo.git",
+ "reference": "ba257924e3ff9bdcb9899225e9f24957c7e4b3f3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Codegyre/Robo/zipball/ba257924e3ff9bdcb9899225e9f24957c7e4b3f3",
+ "reference": "ba257924e3ff9bdcb9899225e9f24957c7e4b3f3",
+ "shasum": ""
+ },
+ "require": {
+ "henrikbjorn/lurker": "1.0.*@dev",
+ "php": ">=5.4.0",
+ "symfony/console": "~2.1",
+ "symfony/filesystem": "~2.1",
+ "symfony/finder": "~2.1",
+ "symfony/process": "~2.1"
+ },
+ "require-dev": {
+ "codeception/aspect-mock": "0.4.*",
+ "codeception/codeception": "~2.0",
+ "codeception/verify": "0.2.*"
+ },
+ "bin": [
+ "robo"
+ ],
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Robo\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Davert",
+ "email": "davert.php@resend.cc"
+ }
+ ],
+ "description": "Modern task runner",
+ "time": "2014-10-17 00:55:05"
+ },
+ {
"name": "doctrine/instantiator",
- "version": "dev-master",
+ "version": "1.0.4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
@@ -264,17 +313,78 @@
"time": "2014-10-13 12:58:55"
},
{
+ "name": "henrikbjorn/lurker",
+ "version": "1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/henrikbjorn/Lurker.git",
+ "reference": "a020d45b3bc37810aeafe27343c51af8a74c9419"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/henrikbjorn/Lurker/zipball/a020d45b3bc37810aeafe27343c51af8a74c9419",
+ "reference": "a020d45b3bc37810aeafe27343c51af8a74c9419",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "symfony/config": "~2.2",
+ "symfony/event-dispatcher": "~2.2"
+ },
+ "suggest": {
+ "ext-inotify": ">=0.1.6"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Lurker": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Henrik Bjornskov",
+ "email": "henrik@bjrnskov.dk",
+ "homepage": "http://henrik.bjrnskov.dk"
+ },
+ {
+ "name": "Konstantin Kudryashov",
+ "email": "ever.zet@gmail.com",
+ "homepage": "http://everzet.com"
+ },
+ {
+ "name": "Yaroslav Kiliba",
+ "email": "om.dattaya@gmail.com"
+ }
+ ],
+ "description": "Resource Watcher.",
+ "keywords": [
+ "filesystem",
+ "resource",
+ "watching"
+ ],
+ "time": "2013-05-24 06:47:29"
+ },
+ {
"name": "phpunit/php-code-coverage",
- "version": "2.0.x-dev",
+ "version": "2.0.11",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "62f8cd539ab2e2c25077aeb5f5ed3209acee3612"
+ "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/62f8cd539ab2e2c25077aeb5f5ed3209acee3612",
- "reference": "62f8cd539ab2e2c25077aeb5f5ed3209acee3612",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7",
+ "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7",
"shasum": ""
},
"require": {
@@ -326,7 +436,7 @@
"testing",
"xunit"
],
- "time": "2014-09-01 22:04:15"
+ "time": "2014-08-31 06:33:04"
},
{
"name": "phpunit/php-file-iterator",
@@ -463,7 +573,7 @@
},
{
"name": "phpunit/php-token-stream",
- "version": "dev-master",
+ "version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
@@ -512,16 +622,16 @@
},
{
"name": "phpunit/phpunit",
- "version": "4.3.x-dev",
+ "version": "4.3.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "ed40f21c7418d2f0c16ae4d0ee1e7c832dfa40b3"
+ "reference": "5a0bc4dcbb7340c0a9a9bc3507854a67c564edc4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed40f21c7418d2f0c16ae4d0ee1e7c832dfa40b3",
- "reference": "ed40f21c7418d2f0c16ae4d0ee1e7c832dfa40b3",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5a0bc4dcbb7340c0a9a9bc3507854a67c564edc4",
+ "reference": "5a0bc4dcbb7340c0a9a9bc3507854a67c564edc4",
"shasum": ""
},
"require": {
@@ -582,29 +692,29 @@
"testing",
"xunit"
],
- "time": "2014-10-17 09:27:56"
+ "time": "2014-10-16 16:53:00"
},
{
"name": "phpunit/phpunit-mock-objects",
- "version": "dev-master",
+ "version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
- "reference": "96c5b81f9842f38fe6c73ad0020306cc4862a9e3"
+ "reference": "c63d2367247365f688544f0d500af90a11a44c65"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/96c5b81f9842f38fe6c73ad0020306cc4862a9e3",
- "reference": "96c5b81f9842f38fe6c73ad0020306cc4862a9e3",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65",
+ "reference": "c63d2367247365f688544f0d500af90a11a44c65",
"shasum": ""
},
"require": {
- "doctrine/instantiator": "~1.0,>=1.0.2",
+ "doctrine/instantiator": "~1.0,>=1.0.1",
"php": ">=5.3.3",
"phpunit/php-text-template": "~1.2"
},
"require-dev": {
- "phpunit/phpunit": "4.4.*@dev"
+ "phpunit/phpunit": "~4.3"
},
"suggest": {
"ext-soap": "*"
@@ -612,7 +722,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.4.x-dev"
+ "dev-master": "2.3.x-dev"
}
},
"autoload": {
@@ -637,11 +747,11 @@
"mock",
"xunit"
],
- "time": "2014-10-04 10:04:20"
+ "time": "2014-10-03 05:12:11"
},
{
"name": "sebastian/comparator",
- "version": "dev-master",
+ "version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
@@ -678,11 +788,6 @@
],
"authors": [
{
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- },
- {
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
@@ -693,6 +798,10 @@
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
+ },
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
}
],
"description": "Provides the functionality to compare PHP values for equality",
@@ -706,7 +815,7 @@
},
{
"name": "sebastian/diff",
- "version": "dev-master",
+ "version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
@@ -758,16 +867,16 @@
},
{
"name": "sebastian/environment",
- "version": "dev-master",
+ "version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "205fcef5998953ec69cb79bc1ea9fee1277c8714"
+ "reference": "6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/205fcef5998953ec69cb79bc1ea9fee1277c8714",
- "reference": "205fcef5998953ec69cb79bc1ea9fee1277c8714",
+ "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7",
+ "reference": "6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7",
"shasum": ""
},
"require": {
@@ -804,11 +913,11 @@
"environment",
"hhvm"
],
- "time": "2014-10-08 05:30:43"
+ "time": "2014-10-07 09:23:16"
},
{
"name": "sebastian/exporter",
- "version": "dev-master",
+ "version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
@@ -907,18 +1016,319 @@
"time": "2014-03-07 15:35:33"
},
{
+ "name": "symfony/config",
+ "version": "v2.5.5",
+ "target-dir": "Symfony/Component/Config",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Config.git",
+ "reference": "0316364bfebc8b080077c731a99f189341476bd7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Config/zipball/0316364bfebc8b080077c731a99f189341476bd7",
+ "reference": "0316364bfebc8b080077c731a99f189341476bd7",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "symfony/filesystem": "~2.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Config\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony Config Component",
+ "homepage": "http://symfony.com",
+ "time": "2014-09-23 05:25:11"
+ },
+ {
+ "name": "symfony/console",
+ "version": "v2.5.5",
+ "target-dir": "Symfony/Component/Console",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Console.git",
+ "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Console/zipball/ca053eaa031c93afb68a71e4eb1f4168dfd4a661",
+ "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "psr/log": "~1.0",
+ "symfony/event-dispatcher": "~2.1"
+ },
+ "suggest": {
+ "psr/log": "For using the console logger",
+ "symfony/event-dispatcher": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Console\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony Console Component",
+ "homepage": "http://symfony.com",
+ "time": "2014-09-25 09:53:56"
+ },
+ {
+ "name": "symfony/event-dispatcher",
+ "version": "v2.5.5",
+ "target-dir": "Symfony/Component/EventDispatcher",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/EventDispatcher.git",
+ "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/f6281337bf5f985f585d1db6a83adb05ce531f46",
+ "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "psr/log": "~1.0",
+ "symfony/config": "~2.0",
+ "symfony/dependency-injection": "~2.0,<2.6.0",
+ "symfony/stopwatch": "~2.2"
+ },
+ "suggest": {
+ "symfony/dependency-injection": "",
+ "symfony/http-kernel": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\EventDispatcher\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony EventDispatcher Component",
+ "homepage": "http://symfony.com",
+ "time": "2014-09-28 15:56:11"
+ },
+ {
+ "name": "symfony/filesystem",
+ "version": "v2.5.5",
+ "target-dir": "Symfony/Component/Filesystem",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Filesystem.git",
+ "reference": "4e62fab0060a826561c78b665925b37c870c45f5"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Filesystem/zipball/4e62fab0060a826561c78b665925b37c870c45f5",
+ "reference": "4e62fab0060a826561c78b665925b37c870c45f5",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Filesystem\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony Filesystem Component",
+ "homepage": "http://symfony.com",
+ "time": "2014-09-22 09:14:18"
+ },
+ {
+ "name": "symfony/finder",
+ "version": "v2.5.5",
+ "target-dir": "Symfony/Component/Finder",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Finder.git",
+ "reference": "d5033742b9a6206ef6d06e813870bca18e9205df"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Finder/zipball/d5033742b9a6206ef6d06e813870bca18e9205df",
+ "reference": "d5033742b9a6206ef6d06e813870bca18e9205df",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Finder\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony Finder Component",
+ "homepage": "http://symfony.com",
+ "time": "2014-09-27 08:35:39"
+ },
+ {
+ "name": "symfony/process",
+ "version": "v2.5.5",
+ "target-dir": "Symfony/Component/Process",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Process.git",
+ "reference": "8a1ec96c4e519cee0fb971ea48a1eb7369dda54b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Process/zipball/8a1ec96c4e519cee0fb971ea48a1eb7369dda54b",
+ "reference": "8a1ec96c4e519cee0fb971ea48a1eb7369dda54b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Process\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony Process Component",
+ "homepage": "http://symfony.com",
+ "time": "2014-09-23 05:25:11"
+ },
+ {
"name": "symfony/yaml",
- "version": "dev-master",
+ "version": "v2.5.5",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
- "reference": "499f7d7aa96747ad97940089bd7a1fb24ad8182a"
+ "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/Yaml/zipball/499f7d7aa96747ad97940089bd7a1fb24ad8182a",
- "reference": "499f7d7aa96747ad97940089bd7a1fb24ad8182a",
+ "url": "https://api.github.com/repos/symfony/Yaml/zipball/b1dbc53593b98c2d694ebf383660ac9134d30b96",
+ "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96",
"shasum": ""
},
"require": {
@@ -927,7 +1337,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.5-dev"
}
},
"autoload": {
@@ -951,11 +1361,11 @@
],
"description": "Symfony Yaml Component",
"homepage": "http://symfony.com",
- "time": "2014-10-05 13:53:50"
+ "time": "2014-09-22 09:14:18"
}
],
"aliases": [],
- "minimum-stability": "dev",
+ "minimum-stability": "stable",
"stability-flags": [],
"platform": {
"php": ">=5.6.1"
diff --git a/index.php b/index.php
index 1f8c7a6..39592f0 100644
--- a/index.php
+++ b/index.php
@@ -1,4 +1,5 @@
<?php
+
require_once 'vendor/autoload.php'; // Autoload files using Composer autoload
use MessageSystems\Transmission;
diff --git a/lib/MessageSystems/Transmission.php b/lib/MessageSystems/Transmission.php
index 3039270..513efac 100644
--- a/lib/MessageSystems/Transmission.php
+++ b/lib/MessageSystems/Transmission.php
@@ -8,10 +8,8 @@ class Transmission {
private $config;
private $request;
- /**
- *
- */
- public function __construct() {
+
+ public function __construct($params = null) {
$this->config = Configuration::getConfig();
$this->request = new Client();
$this->model = [
@@ -27,10 +25,31 @@ class Transmission {
'html'=>null,
'text'=>null,
'email_rfc822'=>null,
- 'headers'=>null
+ 'headers'=>null,
+ 'use_draft_template'=>false,
+ ],
+ 'options'=>[
+ 'open_tracking'=>true,
+ 'click_tracking'=>true
],
'recipients'=>null
];
+
+ if(!is_null($params)) {
+ foreach($params as $key=>$value) {
+ if(key_exists($key, $this->model)) {
+ $this->model[$key] = $value;
+ } else if (key_exists($key, $this->model['content'])) {
+ $this->model['content'][$key] = $value;
+ } else if (key_exists($key, $this->model['options'])) {
+ $this->model['options'][$key] = $value;
+ }
+ }
+
+ if (isset($params['recipientList'])) {
+ $this->useRecipientList($params['recipientList']);
+ }
+ }
}
@@ -38,11 +57,29 @@ class Transmission {
return $this->config['protocol'] . '://' . $this->config['host'] . ($this->config['port'] ? ':' . $this->config['port'] : '') . $this->config['baseUrl'];
}
+
+ public function send() {
+ try {
+ $response = $this->request->post($this->getBaseUrl(), [
+ 'json'=>$this->model,
+ "headers"=>['authorization' => $this->config['key']],
+ "verify"=>$this->config['strictSSL']
+ ]);
+
+ $body = $response->json();
+
+ if ($response->getStatusCode() !== 200) {
+ return $body['errors'];
+ }
+ return $body;
+
+ } catch (RequestException $exception) {
+ throw new \Exception('Unable to contact Transmissions API: '. $exception->getMessage());
+ }
+ }
+
/**
*
- * @param unknown $config
- * @param string $transmissionID
- * @param string $callback
* @return multitype:multitype:string
*/
private function fetch ($transmissionID = null) {
@@ -55,7 +92,7 @@ class Transmission {
//make request
try {
$response = $this->request->get($url, [
- "headers"=>['authorization' => $this->config['key']]
+ "headers"=>['authorization' => $this->config['key']],
"verify"=>$this->config['strictSSL']
]);
@@ -80,6 +117,124 @@ class Transmission {
public function find($transmissionID) {
$this->fetch($transmissionID);
}
+
+ public function setMetadata ($meta) {
+ $this->model['metadata'] = $meta;
+ return $this;
+ }
+
+ public function setSubstitutiondata ($subs) {
+ $this->model['substitution_data'] = $subs;
+ return $this;
+ }
+
+ public function setCampaign ($campaignID) {
+ $this->model['campaign_id'] = $campaignID;
+ return $this;
+ }
+
+ public function setDescription ($description) {
+ $this->model['description'] = $description;
+ return $this;
+ }
+
+ public function setReturnPath ($returnPath) {
+ $this->model['return_path'] = $returnPath;
+ return $this;
+ }
+
+ public function setReplyTo ($replyTo) {
+ $this->model['content']['reply_to'] = $replyTo;
+ return $this;
+ }
+
+ public function setSubject ($subject) {
+ $this->model['content']['subject'] = $subject;
+ return $this;
+ }
+
+ public function setFrom ($fromField) {
+ $this->model['content']['from'] = $fromField;
+ return $this;
+ }
+
+ public function setHTMLContent ($html) {
+ $this->model['content']['html'] = $html;
+ return $this;
+ }
+
+ public function setTextContent ($plaintext) {
+ $this->model['content']['text'] = $plaintext;
+ return $this;
+ }
+
+ public function setRfc822Content ($rfc) {
+ $this->model['content']['rfc'] = $rfc;
+ return $this;
+ }
+
+ public function setContentHeaders ($headers) {
+ $this->model['content']['headers'] = $headers;
+ return $this;
+ }
+
+ public function addRecipient ($recipient) {
+ if(!is_array($this->model['recipients'])) {
+ $this->model['recipients'] = [];
+ }
+ $this->model['recipients'].push($recipient);
+ return $this;
+ }
+
+ public function addRecipients ($recipients) {
+ if(!is_array($this->model['recipients'])) {
+ $this->model['recipients'] = [];
+ }
+ $this->model['recipients'] = array_merge($this->model['recipients'], $recipients);
+ return $this;
+ }
+
+ public function useRecipientList ($recipientList) {
+ //reset the recipients field
+ $this->model['recipients'] = [];
+ $this->model['recipients']['list_name'] = $recipientList;
+ return $this;
+ }
+
+ public function useStoredTemplate ($templateID) {
+ $this->model['content']['template_id'] = $templateID;
+ return $this;
+ }
+
+ public function enableClickTracking () {
+ $this->model['opitons']['click_tracking'] = true;
+ return $this;
+ }
+
+ public function disableClickTracking () {
+ $this->model['opitons']['click_tracking'] = false;
+ return $this;
+ }
+
+ public function enableOpenTracking () {
+ $this->model['opitons']['open_tracking'] = true;
+ return $this;
+ }
+
+ public function disableOpenTracking () {
+ $this->model['opitons']['open_tracking'] = false;
+ return $this;
+ }
+
+ public function useDraftTemplate () {
+ $this->model['opitons']['use_draft_template'] = true;
+ return $this;
+ }
+
+ public function usePublishedTemplate () {
+ $this->model['opitons']['use_draft_template'] = false;
+ return $this;
+ }
}
?> \ No newline at end of file
diff --git a/test/transmissionTest.php b/test/transmissionTest.php
deleted file mode 100644
index bae4e2e..0000000
--- a/test/transmissionTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-require_once 'vendor/autoload.php';
-
-use MessageSystems\Transmission;
-use MessageSystems\Configuration;
-
-class TransmissionTest extends PHPUnit_Framework_TestCase {
-
- private $transmission = null;
-
- private static function getMethod($name) {
- $class = new ReflectionClass('\MessageSystems\Transmission');
- $method = $class->getMethod($name);
- $method->setAccessible(true);
- return $method;
- }
-
- /**
- * (non-PHPdoc)
- * @before
- * @see PHPUnit_Framework_TestCase::setUp()
- */
- public function setUp() {
- Configuration::setConfig(['key'=>'blah']);
- $this->transmission = new Transmission();
- }
-
- public function testFetch() {
- $this->assertEquals('', self::getMethod('fetch')->invokeArgs($this->transmission, [null]));
- }
-}
-?> \ No newline at end of file
diff --git a/test/unit/transmissionTest.php b/test/unit/transmissionTest.php
new file mode 100644
index 0000000..f402730
--- /dev/null
+++ b/test/unit/transmissionTest.php
@@ -0,0 +1,65 @@
+<?php
+require_once 'vendor/autoload.php';
+
+use MessageSystems\Transmission;
+use MessageSystems\Configuration;
+use GuzzleHttp\Client;
+use GuzzleHttp\Subscriber\Mock;
+use GuzzleHttp\Message\Response;
+
+
+class TransmissionTest extends PHPUnit_Framework_TestCase {
+
+ private $transmission = null;
+ private $client = null;
+
+ private static function getMethod($name) {
+ $class = new ReflectionClass('\MessageSystems\Transmission');
+ $method = $class->getMethod($name);
+ $method->setAccessible(true);
+ return $method;
+ }
+
+ private static function getProperty($obj, $name) {
+ $class = new ReflectionClass('\MessageSystems\Transmission');
+ $property = $class->getProperty($name);
+ $property->setAccessible(true);
+ return $property->getValue($obj);
+ }
+
+ /**
+ * (non-PHPdoc)
+ * @before
+ * @see PHPUnit_Framework_TestCase::setUp()
+ */
+ public function setUp() {
+ Configuration::setConfig(['key'=>'blah']);
+ $this->transmission = new Transmission();
+ $this->client = new Client();
+ }
+
+ /**
+ * @desc Constructor will not set invalid keys
+ */
+ public function testConstructorWillNotSetInvalidKeys() {
+ $transmission = new Transmission(['blah'=>'blah']);
+ $this->assertArrayNotHasKey('blah', $this->getProperty($transmission, 'model'));
+ }
+
+ public function testConstructorWillSetValidKeys() {
+ $transmission = new Transmission(['description'=>'this is a test', 'text'=>'test txt', 'open_tracking'=>false, 'recipientList'=>'my recip list']);
+ $this->assertArrayHasKey('description', $this->getProperty($transmission, 'model'));
+ $this->assertEquals('this is a test', $this->getProperty($transmission, 'model')['description']);
+ $this->assertEquals('test txt', $this->getProperty($transmission, 'model')['content']['text']);
+ $this->assertEquals(false, $this->getProperty($transmission, 'model')['options']['open_tracking']);
+ $this->assertEquals('my recip list', $this->getProperty($transmission, 'model')['recipients']['list_name']);
+ }
+
+
+// public function testFetch() {
+// $mock = new Mock([new Response(200, ['body'=>['test'=>'This is a test']])]);
+// $this->client->getEmitter()->attach($mock);
+// $this->assertEquals(['test'=>'This is a test'], self::getMethod('fetch')->invokeArgs($this->transmission, [null]));
+// }
+}
+?> \ No newline at end of file