Exemplo n.º 1
0
 public function testRememberChampionCacheOnly()
 {
     $champions = file_get_contents('tests/Json/champion.free.json');
     $this->cache->shouldReceive('has')->twice()->with('4be3fe5c15c888d40a1793190d77166b')->andReturn(true);
     $this->cache->shouldReceive('get')->twice()->with('4be3fe5c15c888d40a1793190d77166b')->andReturn($champions);
     $this->client->shouldReceive('baseUrl')->twice();
     $api = new LeagueWrap\Api('key', $this->client);
     $api->setCacheOnly()->remember(60, $this->cache);
     $champion = $api->champion();
     $champion->free();
     $champion->free();
     $this->assertEquals(0, $champion->getRequestCount());
 }
Exemplo n.º 2
0
 public function testRememberChampionCacheOnly()
 {
     $champions = file_get_contents('tests/Json/champion.free.json');
     $this->cache->shouldReceive('has')->twice()->with('39a7ac3476de98ba9d05b2d6824c5d03')->andReturn(true);
     $this->cache->shouldReceive('get')->twice()->with('39a7ac3476de98ba9d05b2d6824c5d03')->andReturn($champions);
     $this->client->shouldReceive('baseUrl')->twice();
     $api = new LeagueWrap\Api('key', $this->client);
     $api->setCacheOnly()->remember(60, $this->cache);
     $champion = $api->champion();
     $champion->free();
     $champion->free();
     $this->assertEquals(0, $champion->getRequestCount());
 }
Exemplo n.º 3
0
 public function testAllRegionsLimit()
 {
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'br')->andReturn(true);
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'eune')->andReturn(true);
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'euw')->andReturn(true);
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'kr')->andReturn(true);
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'lan')->andReturn(true);
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'las')->andReturn(true);
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'na')->andReturn(true);
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'oce')->andReturn(true);
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'ru')->andReturn(true);
     $this->limit1->shouldReceive('setRate')->once()->with(10, 5, 'tr')->andReturn(true);
     $this->limit1->shouldReceive('hit')->once()->with(1)->andReturn(true);
     $this->limit1->shouldReceive('isValid')->once()->andReturn(true);
     $this->limit1->shouldReceive('getRegion')->times(10)->andReturn('br', 'eune', 'euw', 'kr', 'lan', 'las', 'na', 'oce', 'ru', 'tr');
     $this->limit1->shouldReceive('newInstance')->times(10)->andReturn($this->limit1);
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('v1.2/champion', ['freeToPlay' => 'true', 'api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/champion.free.json'));
     $api = new LeagueWrap\Api('key', $this->client);
     $api->limit(10, 5, 'all', $this->limit1);
     $champion = $api->champion();
     $info = $champion->free();
     $this->assertTrue(is_array($info->champions));
 }