diff --git a/tests/Unit/Import/Transformer/Quickbooks/ProductTransformerTest.php b/tests/Unit/Import/Transformer/Quickbooks/ProductTransformerTest.php new file mode 100644 index 000000000000..04dbd6ff7312 --- /dev/null +++ b/tests/Unit/Import/Transformer/Quickbooks/ProductTransformerTest.php @@ -0,0 +1,44 @@ +create(1234); + + // Read the JSON string from a file and decode into an associative array + $this->product_data = json_decode( file_get_contents( app_path('/../tests/Mock/Response/Quickbooks/item.json') ), true); + $this->transformer = new ProductTransformer($company); + $this->transformed_data = $this->transformer->transform($this->product_data['Item']); + } + + public function testClassExists() + { + $this->assertInstanceOf(ProductTransformer::class, $this->transformer); + } + + public function testTransformReturnsArray() + { + $this->assertIsArray($this->transformed_data); + } + + public function testTransformHasProperties() + { + $this->assertArrayHasKey('product_key', $this->transformed_data); + $this->assertArrayHasKey('price', $this->transformed_data); + $this->assertTrue(is_numeric($this->transformed_data['price'])); + $this->assertEquals(15, (int) $this->transformed_data['price'] ); + $this->assertEquals((int) $this->product_data['Item']['QtyOnHand'], $this->transformed_data['quantity']); + } +}