Вход Регистрация
Файл: vkolhoze.com/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/VisitorFlyweightTest.php
Строк: 81
<?php

namespace GuzzleTestsServiceCommand;

use 
GuzzleServiceCommandLocationVisitorVisitorFlyweight;
use 
GuzzleServiceCommandLocationVisitorRequestJsonVisitor as JsonRequestVisitor;
use 
GuzzleServiceCommandLocationVisitorResponseJsonVisitor as JsonResponseVisitor;

/**
 * @covers GuzzleServiceCommandLocationVisitorVisitorFlyweight
 */
class VisitorFlyweightTest extends GuzzleTestsGuzzleTestCase
{
    public function 
testUsesDefaultMappingsWithGetInstance()
    {
        
$f VisitorFlyweight::getInstance();
        
$this->assertInstanceOf('GuzzleServiceCommandLocationVisitorRequestJsonVisitor'$f->getRequestVisitor('json'));
        
$this->assertInstanceOf('GuzzleServiceCommandLocationVisitorResponseJsonVisitor'$f->getResponseVisitor('json'));
    }

    public function 
testCanUseCustomMappings()
    {
        
$f = new VisitorFlyweight(array());
        
$this->assertEquals(array(), $this->readAttribute($f'mappings'));
    }

    
/**
     * @expectedException InvalidArgumentException
     * @expectedExceptionMessage No request visitor has been mapped for foo
     */
    
public function testThrowsExceptionWhenRetrievingUnknownVisitor()
    {
        
VisitorFlyweight::getInstance()->getRequestVisitor('foo');
    }

    public function 
testCachesVisitors()
    {
        
$f = new VisitorFlyweight();
        
$v1 $f->getRequestVisitor('json');
        
$this->assertSame($v1$f->getRequestVisitor('json'));
    }

    public function 
testAllowsAddingVisitors()
    {
        
$f = new VisitorFlyweight();
        
$j1 = new JsonRequestVisitor();
        
$j2 = new JsonResponseVisitor();
        
$f->addRequestVisitor('json'$j1);
        
$f->addResponseVisitor('json'$j2);
        
$this->assertSame($j1$f->getRequestVisitor('json'));
        
$this->assertSame($j2$f->getResponseVisitor('json'));
    }
}
Онлайн: 2
Реклама