From 6cdf40d583836959b3ddb4df964bcde99aa432dc Mon Sep 17 00:00:00 2001 From: Thomas Hernandez Date: Thu, 13 Feb 2014 14:35:41 -0500 Subject: [PATCH 1/2] Fixed feeds and cleaned tests --- includes/classes/AmazonFeed.php | 52 ++++++------------- temp.xml | 0 .../includes/classes/AmazonCoreTest.php | 2 +- .../includes/classes/AmazonFeedListTest.php | 2 +- .../includes/classes/AmazonFeedResultTest.php | 6 +-- .../includes/classes/AmazonFeedTest.php | 16 +----- .../AmazonFulfillmentOrderCreatorTest.php | 2 +- .../AmazonFulfillmentOrderListTest.php | 2 +- .../classes/AmazonFulfillmentOrderTest.php | 2 +- .../classes/AmazonFulfillmentPreviewTest.php | 2 +- .../classes/AmazonInventoryListTest.php | 2 +- .../classes/AmazonOrderItemListTest.php | 2 +- .../includes/classes/AmazonOrderListTest.php | 4 +- .../includes/classes/AmazonOrderSetTest.php | 4 +- .../includes/classes/AmazonOrderTest.php | 4 +- .../classes/AmazonPackageTrackerTest.php | 2 +- .../classes/AmazonParticipationListTest.php | 2 +- .../classes/AmazonProductInfoTest.php | 2 +- .../classes/AmazonProductListTest.php | 2 +- .../classes/AmazonProductSearchTest.php | 4 +- .../includes/classes/AmazonProductTest.php | 6 +-- .../classes/AmazonReportAcknowledgerTest.php | 2 +- .../includes/classes/AmazonReportListTest.php | 2 +- .../classes/AmazonReportRequestListTest.php | 2 +- .../classes/AmazonReportRequestTest.php | 2 +- .../classes/AmazonReportScheduleListTest.php | 2 +- .../AmazonReportScheduleManagerTest.php | 2 +- .../includes/classes/AmazonReportTest.php | 6 +-- .../classes/AmazonServiceStatusTest.php | 2 +- .../classes/AmazonShipmentItemListTest.php | 2 +- .../classes/AmazonShipmentListTest.php | 2 +- .../classes/AmazonShipmentPlannerTest.php | 2 +- .../includes/classes/AmazonShipmentTest.php | 8 +-- test-cases/test-temp.xml | 1 - 34 files changed, 60 insertions(+), 95 deletions(-) delete mode 100755 temp.xml delete mode 100644 test-cases/test-temp.xml diff --git a/includes/classes/AmazonFeed.php b/includes/classes/AmazonFeed.php index 13f8e9a3..d20e9026 100644 --- a/includes/classes/AmazonFeed.php +++ b/includes/classes/AmazonFeed.php @@ -20,7 +20,7 @@ * Submits feeds to Amazon. * * This Amazon Feeds Core object can submit feeds to Amazon. - * In order to submit a feed, the feed's contents (a filename) + * In order to submit a feed, the feed's contents (as direct input or from a file) * and feed type must be set. Once the feed has been submitted, * the response from Amazon can be viewed with getResponse. */ @@ -59,28 +59,18 @@ public function __construct($s, $mock = false, $m = null, $config = null){ } /** - * Sets the feed content. (Required*) + * Sets the Feed Content. (Required) * - * This method creates a temporary file using the data you provide. It is - * recommended that you use loadFeedFile instead, as there is a good - * chance the data you provide here will be overwritten later. + * Thie method sets the feed's contents from direct input. + * This parameter is required in order to submit a feed to Amazon. * @param string $s

The contents to put in the file.

- * @param string $override [optional]

The path to a file you want to write to. * It can be relative or absolute.

+ * @return boolean FALSE if improper input */ - public function setFeedContent($s, $override = null){ + public function setFeedContent($s){ if (is_string($s) && $s){ - if ($override && file_exists($override) && is_writable($override)){ - if (strpos($override, '/') === 0){ - file_put_contents($override, $s); - } else { - file_put_contents('../../'.$override, $s); - } - $this->loadFeedFile($override); - } else { - file_put_contents('../../temp.xml', $s); - $this->loadFeedFile('temp.xml'); - } + $this->feedContent=$s; + $this->feedMD5 = base64_encode(md5($this->feedContent,true)); } else { return false; } @@ -89,7 +79,7 @@ public function setFeedContent($s, $override = null){ /** * Sets the Feed Content. (Required) * - * This method sets the file path to be sent in the next request. This + * This method loads the contents of a file to send as the feed. This * parameter is required in order to submit a feed to Amazon. * @param string $url

The path to a file you want to use. * It can be relative or absolute.

@@ -97,12 +87,12 @@ public function setFeedContent($s, $override = null){ public function loadFeedFile($path){ if (file_exists($path)){ if (strpos($path, '/') == 0){ - $this->feedContent = $path; + $this->feedContent = file_get_contents($path); } else { - $url = '/var/www/athena/plugins/newAmazon/'.$path; //todo: change to current install dir - $this->feedContent = $url; + $url = __DIR__.'/../../'.$path; //todo: change to current install dir + $this->feedContent = file_get_contents($url); } - $this->feedMD5 = base64_encode(md5(file_get_contents($this->feedContent),true)); + $this->feedMD5 = base64_encode(md5($this->feedContent,true)); } } @@ -263,15 +253,14 @@ public function submitFeed(){ $xml = $this->fetchMockFile()->$path; } else { $headers = $this->genHeader(); - $post = $this->genPost(); - $response = $this->sendRequest("$url?$query",array('Header'=>$headers,'Post'=>$post)); + $response = $this->sendRequest("$url?$query",array('Header'=>$headers,'Post'=>$this->feedContent)); if (!$this->checkResponse($response)){ return false; } //getting Response 100? - if ($response['head'] == 'HTTP/1.1 100 Continue'){ + if ($response['head'] == 'HTTP/1.1 100 Continue' || $response['code'] == '200'){ $body = strstr($response['body'],'<'); $xml = simplexml_load_string($body)->$path; } else { @@ -318,17 +307,6 @@ protected function genHeader(){ return $return; } - /** - * Generates array for Post. - * - * This method creates the Post array to use with cURL. It contains the Feed Content file path. - * @return array - */ - protected function genPost(){ - $return['file'] = '@'.$this->feedContent; - return $return; - } - /** * Checks whether or not the response is OK. * diff --git a/temp.xml b/temp.xml deleted file mode 100755 index e69de29b..00000000 diff --git a/test-cases/includes/classes/AmazonCoreTest.php b/test-cases/includes/classes/AmazonCoreTest.php index 53366b32..55357108 100644 --- a/test-cases/includes/classes/AmazonCoreTest.php +++ b/test-cases/includes/classes/AmazonCoreTest.php @@ -16,7 +16,7 @@ class AmazonCoreTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonServiceStatus('testStore', 'Inbound', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonServiceStatus('testStore', 'Inbound', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonFeedListTest.php b/test-cases/includes/classes/AmazonFeedListTest.php index 187f2004..6a7ecf11 100644 --- a/test-cases/includes/classes/AmazonFeedListTest.php +++ b/test-cases/includes/classes/AmazonFeedListTest.php @@ -16,7 +16,7 @@ class AmazonFeedListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonFeedList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonFeedList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonFeedResultTest.php b/test-cases/includes/classes/AmazonFeedResultTest.php index 7ac24b20..a7c5b1c4 100644 --- a/test-cases/includes/classes/AmazonFeedResultTest.php +++ b/test-cases/includes/classes/AmazonFeedResultTest.php @@ -16,7 +16,7 @@ class AmazonFeedResultTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonFeedResult('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonFeedResult('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** @@ -66,9 +66,9 @@ public function testFetchFeedResult(){ public function testSaveFeed($o){ resetLog(); $this->assertFalse($this->object->saveFeed('mock/saveFeed.xml')); //nothing yet - $o->saveFeed('/var/www/athena/plugins/amazon/newAmazon/test-cases/mock/saveFeed.xml'); + $o->saveFeed(__DIR__.'/../../mock/saveFeed.xml'); $check = parseLog(); - $this->assertEquals('Successfully saved feed #77 at /var/www/athena/plugins/amazon/newAmazon/test-cases/mock/saveFeed.xml',$check[0]); + $this->assertEquals('Successfully saved feed #77 at '.__DIR__.'/../../mock/saveFeed.xml',$check[0]); } } diff --git a/test-cases/includes/classes/AmazonFeedTest.php b/test-cases/includes/classes/AmazonFeedTest.php index 9348dac8..9b864ac0 100644 --- a/test-cases/includes/classes/AmazonFeedTest.php +++ b/test-cases/includes/classes/AmazonFeedTest.php @@ -16,7 +16,7 @@ class AmazonFeedTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonFeed('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonFeed('testStore', true, null, __DIR__.'/../../test-config.php'); } /** @@ -27,18 +27,6 @@ protected function tearDown() { } - /** - * - */ - public function testSetFeedContent() { - $ok = $this->object->setFeedContent('yes','/var/www/athena/plugins/amazon/newAmazon/test-cases/test-temp.xml'); - $this->assertNull($ok); - $this->assertFileExists('/var/www/athena/plugins/amazon/newAmazon/test-cases/test-temp.xml'); - $check = file_get_contents('/var/www/athena/plugins/amazon/newAmazon/test-cases/test-temp.xml'); - $this->assertEquals('yes',$check); - $this->assertFalse($this->object->setFeedContent(null)); - } - public function testSetFeedType(){ $ok = $this->object->setFeedType('string'); $this->assertNull($ok); @@ -105,7 +93,7 @@ public function testSubmitFeed(){ $this->assertFalse($this->object->submitFeed()); //nothing set yet $this->assertFalse($this->object->getResponse()); //no response yet either - $this->object->setFeedContent('yes','/var/www/athena/plugins/amazon/newAmazon/test-cases/test-temp.xml'); + $this->object->setFeedContent('yes'); $this->assertFalse($this->object->submitFeed()); //no feed type set yet $this->object->setFeedType('_MOCK_FEED_'); diff --git a/test-cases/includes/classes/AmazonFulfillmentOrderCreatorTest.php b/test-cases/includes/classes/AmazonFulfillmentOrderCreatorTest.php index 99300c3b..623b01cd 100644 --- a/test-cases/includes/classes/AmazonFulfillmentOrderCreatorTest.php +++ b/test-cases/includes/classes/AmazonFulfillmentOrderCreatorTest.php @@ -16,7 +16,7 @@ class AmazonFulfillmentOrderCreatorTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonFulfillmentOrderCreator('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonFulfillmentOrderCreator('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonFulfillmentOrderListTest.php b/test-cases/includes/classes/AmazonFulfillmentOrderListTest.php index da397b2d..b74cc356 100644 --- a/test-cases/includes/classes/AmazonFulfillmentOrderListTest.php +++ b/test-cases/includes/classes/AmazonFulfillmentOrderListTest.php @@ -16,7 +16,7 @@ class AmazonFulfillmentOrderListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonFulfillmentOrderList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonFulfillmentOrderList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonFulfillmentOrderTest.php b/test-cases/includes/classes/AmazonFulfillmentOrderTest.php index 37c46ab8..e87815b3 100644 --- a/test-cases/includes/classes/AmazonFulfillmentOrderTest.php +++ b/test-cases/includes/classes/AmazonFulfillmentOrderTest.php @@ -16,7 +16,7 @@ class AmazonFulfillmentOrderTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonFulfillmentOrder('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonFulfillmentOrder('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonFulfillmentPreviewTest.php b/test-cases/includes/classes/AmazonFulfillmentPreviewTest.php index fbb5f30a..15337e25 100644 --- a/test-cases/includes/classes/AmazonFulfillmentPreviewTest.php +++ b/test-cases/includes/classes/AmazonFulfillmentPreviewTest.php @@ -16,7 +16,7 @@ class AmazonFulfillmentPreviewTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonFulfillmentPreview('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonFulfillmentPreview('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonInventoryListTest.php b/test-cases/includes/classes/AmazonInventoryListTest.php index 8472040c..5aa33a8e 100644 --- a/test-cases/includes/classes/AmazonInventoryListTest.php +++ b/test-cases/includes/classes/AmazonInventoryListTest.php @@ -16,7 +16,7 @@ class AmazonInventoryListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonInventoryList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonInventoryList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonOrderItemListTest.php b/test-cases/includes/classes/AmazonOrderItemListTest.php index 7c1350b9..49dca3af 100644 --- a/test-cases/includes/classes/AmazonOrderItemListTest.php +++ b/test-cases/includes/classes/AmazonOrderItemListTest.php @@ -16,7 +16,7 @@ class AmazonOrderItemListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonOrderItemList('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonOrderItemList('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonOrderListTest.php b/test-cases/includes/classes/AmazonOrderListTest.php index 60c3bcd9..f8eb0bd3 100644 --- a/test-cases/includes/classes/AmazonOrderListTest.php +++ b/test-cases/includes/classes/AmazonOrderListTest.php @@ -16,7 +16,7 @@ class AmazonOrderListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonOrderList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonOrderList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** @@ -292,7 +292,7 @@ public function testFetchItems(){ $getOne = $this->object->fetchItems('string', 0); //$token will be set to false $this->assertInternalType('object',$getOne); - $o = new AmazonOrderList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $o = new AmazonOrderList('testStore', true, null, __DIR__.'/../../test-config.php'); $this->assertFalse($o->fetchItems()); //not fetched yet for this object } /** diff --git a/test-cases/includes/classes/AmazonOrderSetTest.php b/test-cases/includes/classes/AmazonOrderSetTest.php index f005f816..91c2dae9 100644 --- a/test-cases/includes/classes/AmazonOrderSetTest.php +++ b/test-cases/includes/classes/AmazonOrderSetTest.php @@ -16,7 +16,7 @@ class AmazonOrderSetTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonOrderSet('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonOrderSet('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** @@ -101,7 +101,7 @@ public function testFetchItems(){ $getOne = $this->object->fetchItems('string', 0); //$token will be set to false $this->assertInternalType('object',$getOne); - $o = new AmazonOrderList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $o = new AmazonOrderList('testStore', true, null, __DIR__.'/../../test-config.php'); $this->assertFalse($o->fetchItems()); //not fetched yet for this object } diff --git a/test-cases/includes/classes/AmazonOrderTest.php b/test-cases/includes/classes/AmazonOrderTest.php index f0b76241..4b959741 100644 --- a/test-cases/includes/classes/AmazonOrderTest.php +++ b/test-cases/includes/classes/AmazonOrderTest.php @@ -16,7 +16,7 @@ class AmazonOrderTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonOrder('testStore', null, null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonOrder('testStore', null, null, true, null, __DIR__.'/../../test-config.php'); } /** @@ -34,7 +34,7 @@ public function testSetUp(){ $this->assertArrayHasKey('AmazonOrderId.Id.1',$o); $this->assertEquals('77', $o['AmazonOrderId.Id.1']); - $data = simplexml_load_file('/var/www/athena/plugins/amazon/newAmazon/test-cases/mock/fetchOrder.xml'); + $data = simplexml_load_file(__DIR__.'/../../mock/fetchOrder.xml'); $obj2 = new AmazonOrder('testStore', null, $data->GetOrderResult->Orders->Order); $get = $obj2->getAmazonOrderId(); diff --git a/test-cases/includes/classes/AmazonPackageTrackerTest.php b/test-cases/includes/classes/AmazonPackageTrackerTest.php index 6040bb92..39effb5c 100644 --- a/test-cases/includes/classes/AmazonPackageTrackerTest.php +++ b/test-cases/includes/classes/AmazonPackageTrackerTest.php @@ -16,7 +16,7 @@ class AmazonPackageTrackerTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonPackageTracker('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonPackageTracker('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonParticipationListTest.php b/test-cases/includes/classes/AmazonParticipationListTest.php index 31bd557e..997d5336 100644 --- a/test-cases/includes/classes/AmazonParticipationListTest.php +++ b/test-cases/includes/classes/AmazonParticipationListTest.php @@ -16,7 +16,7 @@ class AmazonParticipationListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonParticipationList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonParticipationList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonProductInfoTest.php b/test-cases/includes/classes/AmazonProductInfoTest.php index 04d676e5..c3174770 100644 --- a/test-cases/includes/classes/AmazonProductInfoTest.php +++ b/test-cases/includes/classes/AmazonProductInfoTest.php @@ -16,7 +16,7 @@ class AmazonProductInfoTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonProductInfo('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonProductInfo('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonProductListTest.php b/test-cases/includes/classes/AmazonProductListTest.php index bfb617d2..9921df58 100644 --- a/test-cases/includes/classes/AmazonProductListTest.php +++ b/test-cases/includes/classes/AmazonProductListTest.php @@ -16,7 +16,7 @@ class AmazonProductListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonProductList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonProductList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonProductSearchTest.php b/test-cases/includes/classes/AmazonProductSearchTest.php index 24f34e89..d0f9f513 100644 --- a/test-cases/includes/classes/AmazonProductSearchTest.php +++ b/test-cases/includes/classes/AmazonProductSearchTest.php @@ -16,7 +16,7 @@ class AmazonProductSearchTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonProductSearch('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonProductSearch('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** @@ -28,7 +28,7 @@ protected function tearDown() { } public function testSetUp(){ - $obj = new AmazonProductSearch('testStore', 'platinum', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $obj = new AmazonProductSearch('testStore', 'platinum', true, null, __DIR__.'/../../test-config.php'); $o = $obj->getOptions(); $this->assertArrayHasKey('Query',$o); diff --git a/test-cases/includes/classes/AmazonProductTest.php b/test-cases/includes/classes/AmazonProductTest.php index ad2fa2b8..0562e8af 100644 --- a/test-cases/includes/classes/AmazonProductTest.php +++ b/test-cases/includes/classes/AmazonProductTest.php @@ -16,7 +16,7 @@ class AmazonProductTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonProduct('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonProduct('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** @@ -28,9 +28,9 @@ protected function tearDown() { } public function testProduct(){ - $data = simplexml_load_file('/var/www/athena/plugins/amazon/newAmazon/test-cases/mock/searchProducts.xml'); + $data = simplexml_load_file(__DIR__.'/../../mock/searchProducts.xml'); $p = $data->ListMatchingProductsResult->Products->Product; - $obj = new AmazonProduct('testStore', $p, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $obj = new AmazonProduct('testStore', $p, true, null, __DIR__.'/../../test-config.php'); $o = $obj->getData(); $this->assertInternalType('array',$o); $this->assertFalse($this->object->getData()); diff --git a/test-cases/includes/classes/AmazonReportAcknowledgerTest.php b/test-cases/includes/classes/AmazonReportAcknowledgerTest.php index 4de3591c..c57dc1b8 100644 --- a/test-cases/includes/classes/AmazonReportAcknowledgerTest.php +++ b/test-cases/includes/classes/AmazonReportAcknowledgerTest.php @@ -16,7 +16,7 @@ class AmazonReportAcknowledgerTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonReportAcknowledger('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonReportAcknowledger('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonReportListTest.php b/test-cases/includes/classes/AmazonReportListTest.php index ea14c875..cd0aa833 100644 --- a/test-cases/includes/classes/AmazonReportListTest.php +++ b/test-cases/includes/classes/AmazonReportListTest.php @@ -16,7 +16,7 @@ class AmazonReportListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonReportList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonReportList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonReportRequestListTest.php b/test-cases/includes/classes/AmazonReportRequestListTest.php index 2399fe93..68947c27 100644 --- a/test-cases/includes/classes/AmazonReportRequestListTest.php +++ b/test-cases/includes/classes/AmazonReportRequestListTest.php @@ -16,7 +16,7 @@ class AmazonReportRequestListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonReportRequestList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonReportRequestList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonReportRequestTest.php b/test-cases/includes/classes/AmazonReportRequestTest.php index 4cf7951b..2af5022a 100644 --- a/test-cases/includes/classes/AmazonReportRequestTest.php +++ b/test-cases/includes/classes/AmazonReportRequestTest.php @@ -16,7 +16,7 @@ class AmazonReportRequestTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonReportRequest('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonReportRequest('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonReportScheduleListTest.php b/test-cases/includes/classes/AmazonReportScheduleListTest.php index b5c446aa..f225e47b 100644 --- a/test-cases/includes/classes/AmazonReportScheduleListTest.php +++ b/test-cases/includes/classes/AmazonReportScheduleListTest.php @@ -16,7 +16,7 @@ class AmazonReportScheduleListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonReportScheduleList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonReportScheduleList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonReportScheduleManagerTest.php b/test-cases/includes/classes/AmazonReportScheduleManagerTest.php index 42d9e1d7..0a5e5e05 100644 --- a/test-cases/includes/classes/AmazonReportScheduleManagerTest.php +++ b/test-cases/includes/classes/AmazonReportScheduleManagerTest.php @@ -16,7 +16,7 @@ class AmazonReportScheduleManagerTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonReportScheduleManager('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonReportScheduleManager('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonReportTest.php b/test-cases/includes/classes/AmazonReportTest.php index ee5f9cff..d17f80f7 100644 --- a/test-cases/includes/classes/AmazonReportTest.php +++ b/test-cases/includes/classes/AmazonReportTest.php @@ -16,7 +16,7 @@ class AmazonReportTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonReport('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonReport('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** @@ -71,8 +71,8 @@ public function testFetchReport(){ * @depends testFetchReport */ public function testSaveReport($o){ - $path = '/var/www/athena/plugins/amazon/newAmazon/test-cases/mock/saveReport.xml'; - $path2 = '/var/www/athena/plugins/amazon/newAmazon/test-cases/mock/fetchReport.xml'; + $path = __DIR__.'/../../mock/saveReport.xml'; + $path2 = __DIR__.'/../../mock/fetchReport.xml'; $o->saveReport($path); $check = parseLog(); $this->assertEquals("Successfully saved report #777 at $path",$check[1]); diff --git a/test-cases/includes/classes/AmazonServiceStatusTest.php b/test-cases/includes/classes/AmazonServiceStatusTest.php index 394738c2..dbaa9532 100644 --- a/test-cases/includes/classes/AmazonServiceStatusTest.php +++ b/test-cases/includes/classes/AmazonServiceStatusTest.php @@ -16,7 +16,7 @@ class AmazonServiceStatusTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonServiceStatus('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonServiceStatus('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonShipmentItemListTest.php b/test-cases/includes/classes/AmazonShipmentItemListTest.php index 37b4a6a0..f925bcc2 100644 --- a/test-cases/includes/classes/AmazonShipmentItemListTest.php +++ b/test-cases/includes/classes/AmazonShipmentItemListTest.php @@ -16,7 +16,7 @@ class AmazonShipmentItemListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonShipmentItemList('testStore', null, true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonShipmentItemList('testStore', null, true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonShipmentListTest.php b/test-cases/includes/classes/AmazonShipmentListTest.php index 2eaed591..d5fd54b4 100644 --- a/test-cases/includes/classes/AmazonShipmentListTest.php +++ b/test-cases/includes/classes/AmazonShipmentListTest.php @@ -16,7 +16,7 @@ class AmazonShipmentListTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonShipmentList('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonShipmentList('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonShipmentPlannerTest.php b/test-cases/includes/classes/AmazonShipmentPlannerTest.php index cf8b284a..7daf0a58 100644 --- a/test-cases/includes/classes/AmazonShipmentPlannerTest.php +++ b/test-cases/includes/classes/AmazonShipmentPlannerTest.php @@ -16,7 +16,7 @@ class AmazonShipmentPlannerTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonShipmentPlanner('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonShipmentPlanner('testStore', true, null, __DIR__.'/../../test-config.php'); } /** diff --git a/test-cases/includes/classes/AmazonShipmentTest.php b/test-cases/includes/classes/AmazonShipmentTest.php index 33548765..67bac230 100644 --- a/test-cases/includes/classes/AmazonShipmentTest.php +++ b/test-cases/includes/classes/AmazonShipmentTest.php @@ -16,7 +16,7 @@ class AmazonShipmentTest extends PHPUnit_Framework_TestCase { */ protected function setUp() { resetLog(); - $this->object = new AmazonShipment('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonShipment('testStore', true, null, __DIR__.'/../../test-config.php'); } /** @@ -167,7 +167,7 @@ public function testSetShipmentId(){ } public function testUsePlan(){ - $planner = new AmazonShipmentPlanner('testStore', true, 'fetchPlan.xml', '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $planner = new AmazonShipmentPlanner('testStore', true, 'fetchPlan.xml', __DIR__.'/../../test-config.php'); $a = array(); $a['Name'] = 'Name'; $a['AddressLine1'] = 'AddressLine1'; @@ -214,7 +214,7 @@ public function testUsePlan(){ */ public function testCreateShipment($o){ resetLog(); - $this->object = new AmazonShipment('testStore',true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonShipment('testStore',true, null, __DIR__.'/../../test-config.php'); $this->assertFalse($this->object->createShipment()); //no ID set $this->object->setShipmentId('55'); @@ -262,7 +262,7 @@ public function testGetShipmentId($o){ */ public function testUpdateShipment($o){ resetLog(); - $this->object = new AmazonShipment('testStore', true, null, '/var/www/athena/plugins/amazon/newAmazon/test-cases/test-config.php'); + $this->object = new AmazonShipment('testStore', true, null, __DIR__.'/../../test-config.php'); $this->assertFalse($this->object->updateShipment()); //no ID set $this->object->setShipmentId('55'); diff --git a/test-cases/test-temp.xml b/test-cases/test-temp.xml deleted file mode 100644 index 396a0ba2..00000000 --- a/test-cases/test-temp.xml +++ /dev/null @@ -1 +0,0 @@ -yes \ No newline at end of file From cff6a8ef4ec74f970089c5a3d0b44a7f5e31ef0e Mon Sep 17 00:00:00 2001 From: Thomas Hernandez Date: Fri, 14 Feb 2014 09:30:15 -0500 Subject: [PATCH 2/2] Fixed: handle 100 continue response --- includes/classes/AmazonCore.php | 3 +++ includes/classes/AmazonFeed.php | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/classes/AmazonCore.php b/includes/classes/AmazonCore.php index 3e35dfa8..d1050d91 100644 --- a/includes/classes/AmazonCore.php +++ b/includes/classes/AmazonCore.php @@ -656,6 +656,9 @@ function fetchURL ($url, $param) { return $return; } + if (is_numeric(strpos($data, 'HTTP/1.1 100 Continue'))) { + $data=str_replace('HTTP/1.1 100 Continue', '', $data); + } $data = preg_split("/\r\n\r\n/",$data, 2, PREG_SPLIT_NO_EMPTY); if (!empty($data)) { $return['head'] = ( isset($data[0]) ? $data[0] : null ); diff --git a/includes/classes/AmazonFeed.php b/includes/classes/AmazonFeed.php index d20e9026..108842f4 100644 --- a/includes/classes/AmazonFeed.php +++ b/includes/classes/AmazonFeed.php @@ -259,12 +259,11 @@ public function submitFeed(){ return false; } - //getting Response 100? - if ($response['head'] == 'HTTP/1.1 100 Continue' || $response['code'] == '200'){ + if (isset($response['code']) && $response['code'] == '200'){ $body = strstr($response['body'],'<'); $xml = simplexml_load_string($body)->$path; } else { - $this->log("Unexpected response: ".$response['code'],'Warning'); + $this->log("Unexpected response: ".print_r($response,true),'Warning'); $xml = simplexml_load_string($response['body'])->$path; }