Open Monograph Press  3.3.0
ClosureCommandTest.php
1 <?php
2 
4 
8 
13 {
19  {
20  $c = new ClosureCommand();
21  }
22 
23  public function testExecutesClosure()
24  {
25  $c = new ClosureCommand(array(
26  'closure' => function($command, $api) {
27  $command->set('testing', '123');
28  $request = RequestFactory::getInstance()->create('GET', 'http://www.test.com/');
29  return $request;
30  }
31  ));
32 
33  $client = $this->getServiceBuilder()->get('mock');
34  $c->setClient($client)->prepare();
35  $this->assertEquals('123', $c->get('testing'));
36  $this->assertEquals('http://www.test.com/', $c->getRequest()->getUrl());
37  }
38 
43  public function testMustReturnRequest()
44  {
45  $c = new ClosureCommand(array(
46  'closure' => function($command, $api) {
47  return false;
48  }
49  ));
50 
51  $client = $this->getServiceBuilder()->get('mock');
52  $c->setClient($client)->prepare();
53  }
54 }
Guzzle\Tests\GuzzleTestCase\getServiceBuilder
static getServiceBuilder()
Definition: GuzzleTestCase.php:65
Guzzle\Tests\Service\Command\ClosureCommandTest
Definition: ClosureCommandTest.php:12
Guzzle\Tests\GuzzleTestCase
Definition: GuzzleTestCase.php:22
Guzzle\Tests\Service\Command\ClosureCommandTest\testConstructorValidatesClosure
testConstructorValidatesClosure()
Definition: ClosureCommandTest.php:18
Guzzle\Service\Client
Definition: paymethod/paypal/lib/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php:25
Guzzle\Service\Command\ClosureCommand
Definition: ClosureCommand.php:14
Guzzle\Tests\Service\Command\ClosureCommandTest\testExecutesClosure
testExecutesClosure()
Definition: ClosureCommandTest.php:23
Guzzle\Tests\Service\Command\ClosureCommandTest\testMustReturnRequest
testMustReturnRequest()
Definition: ClosureCommandTest.php:43
Guzzle\Http\Message\RequestFactory
Definition: lib/vendor/guzzle/guzzle/src/Guzzle/Http/Message/RequestFactory.php:14
Guzzle\Http\Message\RequestFactory\getInstance
static getInstance()
Definition: lib/vendor/guzzle/guzzle/src/Guzzle/Http/Message/RequestFactory.php:42
Guzzle\Tests\Service\Command
Definition: AbstractCommandTest.php:3