From 0055001537b9a3fd04e0253b164967df8a80750f Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 17 Mar 2022 18:42:19 +0100 Subject: [PATCH] Replacing with V1.0.1 --- .../Dhl/OnlineRetoure/Model/Config.php | 34 ++++++++++----- .../Test/Helper/ValidateTest.php | 26 +++++------ .../OnlineRetoure/Test/Model/ConfigTest.php | 41 +++++++++++------- .../Dhl/OnlineRetoure/etc/adminhtml.xml | 32 -------------- .../Dhl/OnlineRetoure/etc/config.xml | 2 +- .../Dhl}/etc/modules/Dhl_OnlineRetoure.xml | 0 doc/Dhl_OnlineRetoure/ChangeLog.pdf | Bin 81771 -> 81781 bytes doc/Dhl_OnlineRetoure/OnlineRetoure.pdf | Bin 635543 -> 635543 bytes .../package/Dhl_OnlineRetoure-1.0.1.xml | 2 +- 9 files changed, 60 insertions(+), 77 deletions(-) delete mode 100644 app/code/community/Dhl/OnlineRetoure/etc/adminhtml.xml rename app/{ => code/community/Dhl}/etc/modules/Dhl_OnlineRetoure.xml (100%) rename package.xml => var/package/Dhl_OnlineRetoure-1.0.1.xml (80%) diff --git a/app/code/community/Dhl/OnlineRetoure/Model/Config.php b/app/code/community/Dhl/OnlineRetoure/Model/Config.php index bc594af..cd374e9 100644 --- a/app/code/community/Dhl/OnlineRetoure/Model/Config.php +++ b/app/code/community/Dhl/OnlineRetoure/Model/Config.php @@ -66,6 +66,7 @@ public function getPortalId($storeId = null) if (!$portalId) { return ''; } + return $portalId; } @@ -81,6 +82,7 @@ public function getUser($storeId = null) if (!$user) { return ''; } + return $user; } @@ -96,6 +98,7 @@ public function getPassword($storeId = null) if (!$password) { return ''; } + return $password; } @@ -111,6 +114,7 @@ public function getCmsRevocationPage($storeId = null) if (!$page) { return ''; } + return $page; } @@ -155,6 +159,7 @@ public function getWsdlUri($storeId = null) if (!$wsdl) { return ''; } + return $wsdl; } @@ -168,29 +173,36 @@ public function getAllowedCountryCodes() } /** - * Get allowed shipping methods + * Get allowed shipping methods with or without DHL Versenden functionalities * * @return array */ public function getAllowedShippingMethods() { - return explode(",", Mage::getStoreConfig('shipping/dhlonlineretoure/allowed_shipping_methods')); + $originalMethods = Mage::getStoreConfig('shipping/dhlonlineretoure/allowed_shipping_methods'); + $originalMethods = explode(",", $originalMethods); + + $dhlMethods = array_map( + function ($shippingMethod) { + // calculate DHL Versenden counterpart to original shipping method + return preg_replace('/^[^_]+_(.+)$/', 'dhlversenden_$1', $shippingMethod); + }, + $originalMethods + ); + + $allowedShippingMethods = array_merge($originalMethods, $dhlMethods); + return $allowedShippingMethods; } /** * Check if shipping method is allowed * - * @param string $shippingCode + * @param string $shippingMethod * @return boolean */ - public function isAllowedShippingMethod($shippingCode) + public function isAllowedShippingMethod($shippingMethod) { - if (in_array( - $shippingCode, - $this->getAllowedShippingMethods())) { - return true; - } else { - return false; - } + $allowedShippingMethods = $this->getAllowedShippingMethods(); + return in_array($shippingMethod, $allowedShippingMethods); } } diff --git a/app/code/community/Dhl/OnlineRetoure/Test/Helper/ValidateTest.php b/app/code/community/Dhl/OnlineRetoure/Test/Helper/ValidateTest.php index 4a34d3e..505deea 100644 --- a/app/code/community/Dhl/OnlineRetoure/Test/Helper/ValidateTest.php +++ b/app/code/community/Dhl/OnlineRetoure/Test/Helper/ValidateTest.php @@ -58,29 +58,23 @@ public function testIsAllowedCountryCode() */ public function testIsOrderExisting() { + $helper = $this->getValidateHelper(); + //Order exists by ID - True - $this->assertTrue($this->getValidateHelper()->isOrderIdExisting(11)); + $this->assertTrue($helper->isOrderIdExisting(11)); //Order exists by object - True - $this->assertTrue( - $this->getValidateHelper()->isOrderExisting( - Mage::getModel("sales/order")->load(11) - ) - ); + /** @var Mage_Sales_Model_Order $order */ + $order = Mage::getModel("sales/order")->load(11); + $this->assertTrue($helper->isOrderExisting($order)); //Order exists by ID - False (ID is not existing) - $this->assertFalse($this->getValidateHelper()->isOrderIdExisting(123456789)); + $orderId = 123456789; + $this->assertFalse($helper->isOrderIdExisting($orderId)); //Order exists by object - False (ID is not existing) - $this->assertFalse( - $this->getValidateHelper()->isOrderExisting( - Mage::getModel("sales/order")->load(123456789) - ) - ); - - //No parameters were given -> No Order! - $this->setExpectedException('Exception'); - $this->assertFalse($this->getValidateHelper()->isOrderExisting()); + $order = Mage::getModel("sales/order")->load(123456789); + $this->assertFalse($helper->isOrderExisting($order)); } /** diff --git a/app/code/community/Dhl/OnlineRetoure/Test/Model/ConfigTest.php b/app/code/community/Dhl/OnlineRetoure/Test/Model/ConfigTest.php index 346fabb..5537573 100644 --- a/app/code/community/Dhl/OnlineRetoure/Test/Model/ConfigTest.php +++ b/app/code/community/Dhl/OnlineRetoure/Test/Model/ConfigTest.php @@ -134,25 +134,34 @@ public function testGetAllowedCountryCodes() public function testGetAllowedShippingMethods() { - $mockedShippingMethods = "dhlversenden_flatrate,flatrate_flatrate"; - $this->store->setConfig('shipping/dhlonlineretoure/allowed_shipping_methods', $mockedShippingMethods); - - $allowedShippingMethods = $this->config->getAllowedShippingMethods(); - $this->assertInternalType('array', $allowedShippingMethods); - $this->assertNotEmpty($allowedShippingMethods); - $this->assertEquals( - explode(",", $mockedShippingMethods), - $allowedShippingMethods - ); + $allowedMethods = 'flatrate_flatrate,tablerate_bestway'; + $this->store->setConfig('shipping/dhlonlineretoure/allowed_shipping_methods', $allowedMethods); + + // add same methods with DHL carrier + $allowedMethods = explode(',', $allowedMethods); + $allowedMethods[]= 'dhlversenden_flatrate'; + $allowedMethods[]= 'dhlversenden_bestway'; + + $configuredMethods = $this->config->getAllowedShippingMethods(); + $this->assertInternalType('array', $configuredMethods); + $this->assertNotEmpty($configuredMethods); + $this->assertEquals($allowedMethods, $configuredMethods); } public function testIsAllowedShippingMethod() { - $theGood = "dhlversenden_flatrate"; - $theBad = "flatrate_flatrate"; - $this->store->setConfig('shipping/dhlonlineretoure/allowed_shipping_methods', $theGood); - - $this->assertTrue($this->config->isAllowedShippingMethod($theGood)); - $this->assertFalse($this->config->isAllowedShippingMethod($theBad)); + $notAllowed = 'pickup_pickup'; + $allowedMethods = 'flatrate_flatrate,tablerate_bestway'; + $this->store->setConfig('shipping/dhlonlineretoure/allowed_shipping_methods', $allowedMethods); + + // add same methods with DHL carrier + $allowedMethods = explode(',', $allowedMethods); + $allowedMethods[]= 'dhlversenden_flatrate'; + $allowedMethods[]= 'dhlversenden_bestway'; + + $this->assertFalse($this->config->isAllowedShippingMethod($notAllowed)); + foreach ($allowedMethods as $allowedMethod) { + $this->assertTrue($this->config->isAllowedShippingMethod($allowedMethod)); + } } } diff --git a/app/code/community/Dhl/OnlineRetoure/etc/adminhtml.xml b/app/code/community/Dhl/OnlineRetoure/etc/adminhtml.xml deleted file mode 100644 index 52c6035..0000000 --- a/app/code/community/Dhl/OnlineRetoure/etc/adminhtml.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - Online Return - - - - - - - - - - diff --git a/app/code/community/Dhl/OnlineRetoure/etc/config.xml b/app/code/community/Dhl/OnlineRetoure/etc/config.xml index 370aee8..376638f 100644 --- a/app/code/community/Dhl/OnlineRetoure/etc/config.xml +++ b/app/code/community/Dhl/OnlineRetoure/etc/config.xml @@ -12,7 +12,7 @@ - 1.0.0 + 1.0.1 diff --git a/app/etc/modules/Dhl_OnlineRetoure.xml b/app/code/community/Dhl/etc/modules/Dhl_OnlineRetoure.xml similarity index 100% rename from app/etc/modules/Dhl_OnlineRetoure.xml rename to app/code/community/Dhl/etc/modules/Dhl_OnlineRetoure.xml diff --git a/doc/Dhl_OnlineRetoure/ChangeLog.pdf b/doc/Dhl_OnlineRetoure/ChangeLog.pdf index 1a5d8bd4d671d1d44cb6187425e3f74f6d4c6994..bc247073f3bd625d3b0f86346f3b20f993e1978b 100644 GIT binary patch delta 157 zcmaF;kLBw>mWC~i5f&;SaMtZllk HJ)<1}bId5? delta 147 zcmezRkLC40mWC~i5fVpEe8vlxvSBQxU|V?*;8BLg5dH}O=_k1;Sb0CLS@42;Y)6@V&8(lOoKp3x2f D)}tm9 diff --git a/doc/Dhl_OnlineRetoure/OnlineRetoure.pdf b/doc/Dhl_OnlineRetoure/OnlineRetoure.pdf index 9277d4ce325adfc2f8bdc935d63cd967c5930561..cb797c096a882d32f4bfbd7636d5790831cd63da 100644 GIT binary patch delta 388 zcmbRKRBifGwT2eP7N!>F7M2#)7Pc1l7LF~PPxZLX4Gj!T4ULS9OiZ_b(BoXr&1GP! zZ)l)zWMF8%eW4YnJr|O|bf7@;c3)RcYfRCv{+ty;7;0}Nah_wv5EaejbVRlYV(#G* z&Tl*zYSo%J*Rx=VI<<425yud%p3j+#Zd=%PyQQ4Jn9$UQO$UndZC|#6GmtaB)G5Z; z#5Bg()F?g1$jr<<#@Ns(#@GOi6JiVu%wmj<4S|BD*)hgu#+nKmq-mHQwu#db06foY AtN;K2 delta 388 zcmbRKRBifGwT2eP7N!>F7M2#)7Pc1l7LF~PPxZLX3@nUH3=Iv;3@x^Q(BoXr&1Gbw zZ(yNsWMF8veW4YnJr|O|bf7@;c3)RcYfRCv{+ty;7;0}Nah_wv5EaejbVRlYV(#G* z&Tl*zYSo%J*Rx=VI<<425yud%p3j+#Zd=%PyQQ4Jn9$UQO$UndZC|#6GmtYr#@N&# z#>mJx#>mtp#@NsxK^e$1h%q)Z1Y(oW7$Y;Y+Nv016GI)43QYwK(lksD+r;Sz0Bu!k AzW@LL diff --git a/package.xml b/var/package/Dhl_OnlineRetoure-1.0.1.xml similarity index 80% rename from package.xml rename to var/package/Dhl_OnlineRetoure-1.0.1.xml index 1804a73..cd9801a 100644 --- a/package.xml +++ b/var/package/Dhl_OnlineRetoure-1.0.1.xml @@ -1,2 +1,2 @@ -Dhl_OnlineRetoure1.0.0stableOSL3communityDHL OnlineRetoureThis extension enables customers to create return shipping labels for their orders.Official DHL OnlineRetoure extensionAndré Herrnnetresearch_dhlandre.herrn@netresearch.de2016-08-245.4.07.9.0 +Dhl_OnlineRetoure1.0.1stableOSL3communityDHL OnlineRetoureThis extension enables customers to create return shipping labels for their orders.Official DHL OnlineRetoure extensionAndré Herrnnetresearch_dhlandre.herrn@netresearch.de2017-10-055.4.07.9.0