Skip to content

Commit

Permalink
add tests for inventory endpoints
Browse files Browse the repository at this point in the history
inventory endpoints introduced in 31381e2
closes #16
  • Loading branch information
darthmaim committed Jun 27, 2015
1 parent 31381e2 commit 345b357
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/V2/Endpoint/Character/EquipmentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct( GW2Api $api, $apiKey, $character ) {
* {@inheritdoc}
*/
protected function url() {
return 'v2/characters/' . urlencode( $this->character ) . '/equipment';
return 'v2/characters/' . rawurlencode( $this->character ) . '/equipment';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/V2/Endpoint/Character/InventoryEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct( GW2Api $api, $apiKey, $character ) {
* {@inheritdoc}
*/
protected function url() {
return 'v2/characters/' . urlencode( $this->character ) . '/inventory';
return 'v2/characters/' . rawurlencode( $this->character ) . '/inventory';
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/V2/AccountBankEndpointTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace V2;

use TestCase;

class AccountBankEndpointTest extends Testcase {
public function test() {
$endpoint = $this->api()->account('test')->bank();

$this->mockResponse('[null,{"id":46774,"slot":1,"count":1,"upgrades":[24675]}]');
$this->assertEquals(24675, $endpoint->get()[1]->upgrades[0]);
}
}
14 changes: 14 additions & 0 deletions tests/V2/AccountMaterialEndpointTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace V2;

use TestCase;

class AccountMaterialEndpointTest extends Testcase {
public function test() {
$endpoint = $this->api()->account('test')->materials();

$this->mockResponse('[{"id":19699,"category":5,"count":250},{"id":19670,"category":5,"count":0}]');
$this->assertEquals(5, $endpoint->get()[1]->category);
}
}
14 changes: 14 additions & 0 deletions tests/V2/CharacterEquipmentEndpointTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace V2;

use TestCase;

class CharacterEquipmentEndpointTest extends TestCase {
public function test() {
$endpoint = $this->api()->characters('test')->equipment('char');

$this->mockResponse('{"equipment":[{"id":6472,"slot":"Coat"},{"id":6470,"slot":"Boots"}]}');
$this->assertEquals(6472, $endpoint->get()[0]->id);
}
}
14 changes: 14 additions & 0 deletions tests/V2/CharacterInventoryEndpointTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace V2;

use TestCase;

class CharacterInventoryEndpointTest extends TestCase {
public function test() {
$endpoint = $this->api()->characters('test')->inventory('char');

$this->mockResponse('{"bags":[{"id":8941,"size":4,"inventory":[null,{"id":32134,"count":1},null,null]},null]}');
$this->assertEquals(32134, $endpoint->get()[0]->inventory[1]->id);
}
}
14 changes: 14 additions & 0 deletions tests/V2/MaterialEndpointTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace V2;

use TestCase;

class MaterialEndpointTest extends TestCase {
public function test() {
$endpoint = $this->api()->materials();

$this->mockResponse('{"id":5,"name":"Cooking Materials","items":[12134,12238,12147]}');
$this->assertCount(3, $endpoint->get(5)->items);
}
}

0 comments on commit 345b357

Please sign in to comment.