/** * Retrieves a shard * * @param $shardName * * @return Shard * * @throws Exception\ShardNotFoundException */ public function getShard($shardName) { if (!array_key_exists($shardName, $this->shard)) { $shardData = $this->connector->getShardByName($shardName); $this->shard[$shardName] = ShardHydrator::hydrate($shardData, $this); } return $this->shard[$shardName]; }
/** * @expectedException \Ecn\RiftConnector\Exception\ShardNotFoundException */ public function testGetShardByNameError() { $response = $this->getMock('\\GuzzleHttp\\Message\\ResponseInterface'); $response->method('getStatusCode')->willReturn('200'); $response->method('json')->willReturn($this->getDummyShardList()); $client = $this->getMock('\\GuzzleHttp\\ClientInterface'); $client->method('get')->willReturn($response); $connector = new Connector($client); $shard = $connector->getShardByName('Foo'); }