|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Bigcommerce\Test\Unit\Api\Resources; |
| 4 | + |
| 5 | +use Bigcommerce\Api\Client; |
| 6 | +use Bigcommerce\Api\Resources\ShippingZone; |
| 7 | + |
| 8 | +class ShippingZoneTest extends ResourceTestBase |
| 9 | +{ |
| 10 | + public function testCreateShippingZone() |
| 11 | + { |
| 12 | + $input = array( |
| 13 | + 'name' => 'United States', |
| 14 | + 'type' => 'country', |
| 15 | + 'locations' => array( |
| 16 | + array('country_iso2' => 'US'), |
| 17 | + ), |
| 18 | + ); |
| 19 | + $zone = new ShippingZone((object)$input); |
| 20 | + $this->connection->expects($this->once()) |
| 21 | + ->method('post') |
| 22 | + ->with($this->basePath . '/shipping/zones/', (object)$input); |
| 23 | + |
| 24 | + $zone->create(); |
| 25 | + } |
| 26 | + |
| 27 | + public function testUpdateShippingZone() |
| 28 | + { |
| 29 | + $input = array( |
| 30 | + 'name' => 'United States', |
| 31 | + 'type' => 'country', |
| 32 | + 'locations' => array( |
| 33 | + array('country_iso2' => 'US'), |
| 34 | + ), |
| 35 | + ); |
| 36 | + $updateResource = array_merge(['id' => 1], $input); |
| 37 | + $zone = new ShippingZone((object)$updateResource); |
| 38 | + |
| 39 | + $this->connection->expects($this->once()) |
| 40 | + ->method('put') |
| 41 | + ->with($this->basePath . '/shipping/zones/1', (object)$input); |
| 42 | + |
| 43 | + $zone->update(); |
| 44 | + } |
| 45 | + |
| 46 | + public function testGetShippingZone() |
| 47 | + { |
| 48 | + $this->connection->expects($this->once()) |
| 49 | + ->method('get') |
| 50 | + ->with($this->basePath . '/shipping/zones/1'); |
| 51 | + |
| 52 | + Client::getShippingZone(1); |
| 53 | + } |
| 54 | + |
| 55 | + public function testGetShippingZones() |
| 56 | + { |
| 57 | + $this->connection->expects($this->once()) |
| 58 | + ->method('get') |
| 59 | + ->with($this->basePath . '/shipping/zones/'); |
| 60 | + |
| 61 | + Client::getShippingZones(); |
| 62 | + } |
| 63 | + |
| 64 | + public function testDeleteShippingZone() |
| 65 | + { |
| 66 | + |
| 67 | + $this->connection->expects($this->once()) |
| 68 | + ->method('delete') |
| 69 | + ->with($this->basePath . '/shipping/zones/1'); |
| 70 | + |
| 71 | + Client::deleteShippingZone(1); |
| 72 | + } |
| 73 | +} |
0 commit comments