Open Monograph Press  3.3.0
VisitorFlyweightTest.php
1 <?php
2 
4 
8 
13 {
15  {
17  $this->assertInstanceOf('Guzzle\Service\Command\LocationVisitor\Request\JsonVisitor', $f->getRequestVisitor('json'));
18  $this->assertInstanceOf('Guzzle\Service\Command\LocationVisitor\Response\JsonVisitor', $f->getResponseVisitor('json'));
19  }
20 
21  public function testCanUseCustomMappings()
22  {
23  $f = new VisitorFlyweight(array());
24  $this->assertEquals(array(), $this->readAttribute($f, 'mappings'));
25  }
26 
32  {
33  VisitorFlyweight::getInstance()->getRequestVisitor('foo');
34  }
35 
36  public function testCachesVisitors()
37  {
38  $f = new VisitorFlyweight();
39  $v1 = $f->getRequestVisitor('json');
40  $this->assertSame($v1, $f->getRequestVisitor('json'));
41  }
42 
43  public function testAllowsAddingVisitors()
44  {
45  $f = new VisitorFlyweight();
46  $j1 = new JsonRequestVisitor();
47  $j2 = new JsonResponseVisitor();
48  $f->addRequestVisitor('json', $j1);
49  $f->addResponseVisitor('json', $j2);
50  $this->assertSame($j1, $f->getRequestVisitor('json'));
51  $this->assertSame($j2, $f->getResponseVisitor('json'));
52  }
53 }
Guzzle\Service\Command\LocationVisitor\VisitorFlyweight
Definition: VisitorFlyweight.php:12
Guzzle\Tests\Service\Command\VisitorFlyweightTest\testAllowsAddingVisitors
testAllowsAddingVisitors()
Definition: VisitorFlyweightTest.php:43
Guzzle\Tests\Service\Command\VisitorFlyweightTest\testCachesVisitors
testCachesVisitors()
Definition: VisitorFlyweightTest.php:36
Guzzle\Service\Command\LocationVisitor\Response\JsonVisitor
Definition: Response/JsonVisitor.php:17
Guzzle\Tests\Service\Command\VisitorFlyweightTest\testCanUseCustomMappings
testCanUseCustomMappings()
Definition: VisitorFlyweightTest.php:21
Guzzle\Service\Command\LocationVisitor\Request\JsonVisitor
Definition: Request/JsonVisitor.php:12
Guzzle\Tests\GuzzleTestCase
Definition: GuzzleTestCase.php:22
Guzzle\Tests\Service\Command\VisitorFlyweightTest\testUsesDefaultMappingsWithGetInstance
testUsesDefaultMappingsWithGetInstance()
Definition: VisitorFlyweightTest.php:14
Guzzle\Service\Command\LocationVisitor\VisitorFlyweight\getInstance
static getInstance()
Definition: VisitorFlyweight.php:52
Guzzle\Tests\Service\Command\VisitorFlyweightTest\testThrowsExceptionWhenRetrievingUnknownVisitor
testThrowsExceptionWhenRetrievingUnknownVisitor()
Definition: VisitorFlyweightTest.php:31
Guzzle\Tests\Service\Command\VisitorFlyweightTest
Definition: VisitorFlyweightTest.php:12
Guzzle\Tests\Service\Command
Definition: AbstractCommandTest.php:3