Ejemplo n.º 1
0
 /**
  * @covers Guzzle\Service\Client::setDescription
  */
 public function testSettingServiceDescriptionUpdatesFactories()
 {
     $client = new Mock\MockClient();
     $factory = $this->getMockBuilder('Guzzle\\Service\\Command\\Factory\\MapFactory')->disableOriginalConstructor()->getMock();
     $client->setCommandFactory($factory);
     $description = $this->getMock('Guzzle\\Service\\Description\\ServiceDescription');
     $client->setDescription($description);
     $cf = $this->readAttribute($client, 'commandFactory');
     $this->assertNotSame($factory, $cf);
     $this->assertInstanceOf('Guzzle\\Service\\Command\\Factory\\CompositeFactory', $cf);
     $array = $cf->getIterator()->getArrayCopy();
     $this->assertSame($array[0], $factory);
     $this->assertInstanceOf('Guzzle\\Service\\Command\\Factory\\ServiceDescriptionFactory', $array[1]);
     $this->assertSame($description, $array[1]->getServiceDescription());
     $description2 = $this->getMock('Guzzle\\Service\\Description\\ServiceDescription');
     $client->setDescription($description2);
     $cf = $this->readAttribute($client, 'commandFactory');
     $array = $cf->getIterator()->getArrayCopy();
     $this->assertSame($array[0], $factory);
     $this->assertInstanceOf('Guzzle\\Service\\Command\\Factory\\ServiceDescriptionFactory', $array[1]);
     $this->assertSame($description2, $array[1]->getServiceDescription());
 }
 public function testCreatesCommandsUsingCommandFactory()
 {
     $mockCommand = new MockCommand();
     $client = new Mock\MockClient();
     $mock = $this->getMock('Guzzle\\Service\\Command\\Factory\\FactoryInterface');
     $mock->expects($this->any())->method('factory')->with($this->equalTo('foo'))->will($this->returnValue($mockCommand));
     $client->setCommandFactory($mock);
     $command = $client->getCommand('foo', array('acl' => '123'));
     $this->assertSame($mockCommand, $command);
     $command = $client->getCommand('foo', array('acl' => '123'));
     $this->assertSame($mockCommand, $command);
     $this->assertSame($client, $command->getClient());
 }
 /**
  * @covers Guzzle\Service\Client::getCommandFactory
  * @covers Guzzle\Service\Client::setCommandFactory
  */
 public function testOwnsCommandFactory()
 {
     $client = new Mock\MockClient();
     $this->assertInstanceOf('Guzzle\\Service\\Command\\Factory\\CompositeFactory', $client->getCommandFactory());
     $this->assertSame($client->getCommandFactory(), $client->getCommandFactory());
     $mock = $this->getMock('Guzzle\\Service\\Command\\Factory\\CompositeFactory');
     $client->setCommandFactory($mock);
     $this->assertSame($mock, $client->getCommandFactory());
 }