From 7b79d85f06dfa5c7db2717368970caf4ccda1e70 Mon Sep 17 00:00:00 2001 From: "Ula D. Beck" Date: Mon, 31 Oct 2022 16:19:54 -0400 Subject: [PATCH] Adds autobillItemVid to TransactionItem --- src/TestFramework/DataFaker.php | 16 +++++++++++++++- src/VindiciaItem.php | 20 ++++++++++++++++++++ tests/VindiciaItemTest.php | 11 +++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/TestFramework/DataFaker.php b/src/TestFramework/DataFaker.php index 9f47f9d0..9f184afb 100644 --- a/src/TestFramework/DataFaker.php +++ b/src/TestFramework/DataFaker.php @@ -96,6 +96,19 @@ public function currency() return $currencies[$this->intBetween(0, count($currencies) - 1)]; } + /** + * Return autobill item vid + * + * @return string + */ + public function autobillItemVid() + { + do { + $result = $this->randomCharacters(self::HEX_CHARACTERS, 40); + } while ($result == 0); + return $result; + } + /** * Return a customer id * @@ -616,7 +629,8 @@ public function itemAsArray($currency) 'quantity' => $this->intBetween(1, 15), 'price' => $this->monetaryAmount($currency), 'sku' => $this->sku(), - 'taxClassification' => $this->taxClassification() + 'taxClassification' => $this->taxClassification(), + 'autoBillItemVid' => $this->autobillItemVid() ); } diff --git a/src/VindiciaItem.php b/src/VindiciaItem.php index ac84e503..197bcd59 100644 --- a/src/VindiciaItem.php +++ b/src/VindiciaItem.php @@ -119,6 +119,26 @@ public function setTaxClassification($value) return $this->setParameter('taxClassification', $value); } + /** + * Get the item autobill item VID + * + * @return null|string + */ + public function getAutoBillItemVid() + { + return $this->getParameter('autoBillItemVid'); + } + + /** + * Set the item autobill item VID + * + * @return null|string + */ + public function setAutoBillItemVid($value) + { + return $this->setParameter('autoBillItemVid', $value); + } + /** * @return void */ diff --git a/tests/VindiciaItemTest.php b/tests/VindiciaItemTest.php index 9c244de6..cfe3ddb6 100644 --- a/tests/VindiciaItemTest.php +++ b/tests/VindiciaItemTest.php @@ -114,6 +114,17 @@ public function testTaxClassification() $this->assertSame($taxClassification, $item->getTaxClassification()); } + /** + * @return void + */ + public function testAutoBillItemVid() + { + $item = new VindiciaItem(); + $autobillItemVid = $this->faker->autobillItemVid(); + $this->assertSame($item, $item->setAutoBillItemVid($autobillItemVid)); + $this->assertSame($autobillItemVid, $item->getAutoBillItemVid()); + } + /** * @expectedException \Omnipay\Vindicia\Exception\InvalidItemException * @expectedExceptionMessage Item is missing name.