summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php')
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php
new file mode 100644
index 0000000..d762246
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Service\Command\ClosureCommand;
+use Guzzle\Service\Client;
+
+/**
+ * @covers Guzzle\Service\Command\ClosureCommand
+ */
+class ClosureCommandTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage A closure must be passed in the parameters array
+ */
+ public function testConstructorValidatesClosure()
+ {
+ $c = new ClosureCommand();
+ }
+
+ public function testExecutesClosure()
+ {
+ $c = new ClosureCommand(array(
+ 'closure' => function($command, $api) {
+ $command->set('testing', '123');
+ $request = RequestFactory::getInstance()->create('GET', 'http://www.test.com/');
+ return $request;
+ }
+ ));
+
+ $client = $this->getServiceBuilder()->get('mock');
+ $c->setClient($client)->prepare();
+ $this->assertEquals('123', $c->get('testing'));
+ $this->assertEquals('http://www.test.com/', $c->getRequest()->getUrl());
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ * @expectedExceptionMessage Closure command did not return a RequestInterface object
+ */
+ public function testMustReturnRequest()
+ {
+ $c = new ClosureCommand(array(
+ 'closure' => function($command, $api) {
+ return false;
+ }
+ ));
+
+ $client = $this->getServiceBuilder()->get('mock');
+ $c->setClient($client)->prepare();
+ }
+}