From 7768850a746194b8426bdd28779517adb288fbc8 Mon Sep 17 00:00:00 2001 From: Angelo Ou Date: Tue, 25 Feb 2025 17:58:55 -0500 Subject: [PATCH 1/2] Create tests for ProductFeedUploads create endpoint --- .../ProductFeedUploads/Create/ReponseTest.php | 21 +++++++++++++ .../ProductFeedUploads/Create/RequestTest.php | 30 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/ReponseTest.php create mode 100644 tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/RequestTest.php diff --git a/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/ReponseTest.php b/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/ReponseTest.php new file mode 100644 index 000000000..2a42b445a --- /dev/null +++ b/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/ReponseTest.php @@ -0,0 +1,21 @@ +assertEquals('facebook-upload-id', $response->id); + $this->assertEquals('success', $response->data['upload_status']); + } +} diff --git a/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/RequestTest.php b/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/RequestTest.php new file mode 100644 index 000000000..d96f13486 --- /dev/null +++ b/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/RequestTest.php @@ -0,0 +1,30 @@ + 'Test Product Feed', + 'schedule' => [ + 'interval' => 'DAILY', + 'url' => 'http://example.com/feed.xml', + ], + ]; + + $request = new Request($product_feed_id, $data); + + $this->assertEquals('POST', $request->get_method()); + $this->assertEquals('/facebook-product-feed-id/uploads', $request->get_path()); + $this->assertEquals($data, $request->get_data()); + } +} From 93e8c091e8b97c72fa47f9e635b2eec5341dfde8 Mon Sep 17 00:00:00 2001 From: Angelo Ou Date: Tue, 25 Feb 2025 19:22:39 -0500 Subject: [PATCH 2/2] Update variable names --- .../ProductFeedUploads/Create/ReponseTest.php | 10 ++++++++-- .../ProductFeedUploads/Create/RequestTest.php | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/ReponseTest.php b/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/ReponseTest.php index 2a42b445a..77e1b644f 100644 --- a/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/ReponseTest.php +++ b/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/ReponseTest.php @@ -12,10 +12,16 @@ class ProductFeedUploadResponseTest extends WP_UnitTestCase { * @return void */ public function test_response() { - $json = '{"id":"facebook-upload-id","data":{"upload_status":"success"}}'; + $json = '{ + "id": "product_feed_upload_id", + "data": { + "upload_status": "success" + } + }'; + $response = new Response($json); - $this->assertEquals('facebook-upload-id', $response->id); + $this->assertEquals('product_feed_upload_id', $response->id); $this->assertEquals('success', $response->data['upload_status']); } } diff --git a/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/RequestTest.php b/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/RequestTest.php index d96f13486..4e7f4f532 100644 --- a/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/RequestTest.php +++ b/tests/Unit/Api/ProductCatalog/ProductFeedUploads/Create/RequestTest.php @@ -12,7 +12,7 @@ class ProductFeedUploadRequestTest extends WP_UnitTestCase { * @return void */ public function test_request() { - $product_feed_id = 'facebook-product-feed-id'; + $product_feed_id = 'product_feed_upload_id'; $data = [ 'name' => 'Test Product Feed', 'schedule' => [ @@ -24,7 +24,7 @@ public function test_request() { $request = new Request($product_feed_id, $data); $this->assertEquals('POST', $request->get_method()); - $this->assertEquals('/facebook-product-feed-id/uploads', $request->get_path()); + $this->assertEquals('/product_feed_upload_id/uploads', $request->get_path()); $this->assertEquals($data, $request->get_data()); } }