|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Bigcommerce\Test\Unit\Api\Resources; |
| 4 | + |
| 5 | +use Bigcommerce\Api\Client; |
| 6 | +use Bigcommerce\Api\Resources\ShippingMethod; |
| 7 | + |
| 8 | +class ShippingMethodTest extends ResourceTestBase |
| 9 | +{ |
| 10 | + public function testCreateShippingMethod() |
| 11 | + { |
| 12 | + $input = array( |
| 13 | + "name" => "USPS Endicia", |
| 14 | + "type" => "endicia", |
| 15 | + "settings" => array( |
| 16 | + "carrier_options" => array( |
| 17 | + "delivery_services" => array( |
| 18 | + "PriorityExpress", |
| 19 | + "PriorityMailExpressInternational", |
| 20 | + "FirstClassPackageInternationalService", |
| 21 | + "Priority", |
| 22 | + "PriorityMailInternational", |
| 23 | + "First", |
| 24 | + "ParcelSelect", |
| 25 | + "MediaMail" |
| 26 | + ), |
| 27 | + "packaging" => array( |
| 28 | + "FlatRateLegalEnvelope", |
| 29 | + "FlatRatePaddedEnvelope", |
| 30 | + "Parcel", |
| 31 | + "SmallFlatRateBox", |
| 32 | + "MediumFlatRateBox", |
| 33 | + "LargeFlatRateBox", |
| 34 | + "FlatRateEnvelope", |
| 35 | + "RegionalRateBoxA", |
| 36 | + "RegionalRateBoxB" |
| 37 | + ), |
| 38 | + "show_transit_time" => true, |
| 39 | + ) |
| 40 | + ), |
| 41 | + "enabled" => true |
| 42 | + ); |
| 43 | + $method = new ShippingMethod((object)$input); |
| 44 | + $this->connection->expects($this->once()) |
| 45 | + ->method('post') |
| 46 | + ->with($this->basePath . '/shipping/zones/1/methods', (object)$input); |
| 47 | + |
| 48 | + $method->create(1); |
| 49 | + } |
| 50 | + |
| 51 | + public function testUpdateShippingMethod() |
| 52 | + { |
| 53 | + $input = array( |
| 54 | + "name" => "Ship by Weight", |
| 55 | + "type" => "weight", |
| 56 | + "settings" => array( |
| 57 | + "default_cost" => 1, |
| 58 | + "default_cost_type" => "fixed_amount", |
| 59 | + "range" => array( |
| 60 | + array( |
| 61 | + "lower_limit" => 0, |
| 62 | + "upper_limit" => 20, |
| 63 | + "shipping_cost" => 8 |
| 64 | + ) |
| 65 | + ) |
| 66 | + ), |
| 67 | + "enabled" => true |
| 68 | + ); |
| 69 | + $updateResource = array_merge(array('id' => 1), $input); |
| 70 | + $method = new ShippingMethod((object)$updateResource); |
| 71 | + $this->connection->expects($this->once()) |
| 72 | + ->method('put') |
| 73 | + ->with($this->basePath . '/shipping/zones/1/methods/1', (object)$input); |
| 74 | + |
| 75 | + $method->update(1); |
| 76 | + } |
| 77 | + |
| 78 | + public function testGetShippingMethod() |
| 79 | + { |
| 80 | + $this->connection->expects($this->once()) |
| 81 | + ->method('get') |
| 82 | + ->with($this->basePath . '/shipping/zones/1/methods/2'); |
| 83 | + |
| 84 | + Client::getShippingMethod(1, 2); |
| 85 | + } |
| 86 | + |
| 87 | + public function testGetShippingMethods() |
| 88 | + { |
| 89 | + $this->connection->expects($this->once()) |
| 90 | + ->method('get') |
| 91 | + ->with($this->basePath . '/shipping/zones/1/methods'); |
| 92 | + |
| 93 | + Client::getShippingMethods(1); |
| 94 | + } |
| 95 | + |
| 96 | + public function testDeleteShippingMethod() |
| 97 | + { |
| 98 | + |
| 99 | + $this->connection->expects($this->once()) |
| 100 | + ->method('delete') |
| 101 | + ->with($this->basePath . '/shipping/zones/1/methods/2'); |
| 102 | + |
| 103 | + Client::deleteShippingMethod(1, 2); |
| 104 | + } |
| 105 | +} |
0 commit comments