Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions app/code/community/Dhl/OnlineRetoure/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function getPortalId($storeId = null)
if (!$portalId) {
return '';
}

return $portalId;
}

Expand All @@ -81,6 +82,7 @@ public function getUser($storeId = null)
if (!$user) {
return '';
}

return $user;
}

Expand All @@ -96,6 +98,7 @@ public function getPassword($storeId = null)
if (!$password) {
return '';
}

return $password;
}

Expand All @@ -111,6 +114,7 @@ public function getCmsRevocationPage($storeId = null)
if (!$page) {
return '';
}

return $page;
}

Expand Down Expand Up @@ -155,6 +159,7 @@ public function getWsdlUri($storeId = null)
if (!$wsdl) {
return '';
}

return $wsdl;
}

Expand All @@ -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);
}
}
26 changes: 10 additions & 16 deletions app/code/community/Dhl/OnlineRetoure/Test/Helper/ValidateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
41 changes: 25 additions & 16 deletions app/code/community/Dhl/OnlineRetoure/Test/Model/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
32 changes: 0 additions & 32 deletions app/code/community/Dhl/OnlineRetoure/etc/adminhtml.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/code/community/Dhl/OnlineRetoure/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<config>
<modules>
<Dhl_OnlineRetoure>
<version>1.0.0</version>
<version>1.0.1</version>
</Dhl_OnlineRetoure>
</modules>
<global>
Expand Down
Binary file modified doc/Dhl_OnlineRetoure/ChangeLog.pdf
Binary file not shown.
Binary file modified doc/Dhl_OnlineRetoure/OnlineRetoure.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion package.xml → var/package/Dhl_OnlineRetoure-1.0.1.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0"?>
<package><name>Dhl_OnlineRetoure</name><version>1.0.0</version><stability>stable</stability><license>OSL3</license><channel>community</channel><extends></extends><summary>DHL OnlineRetoure</summary><description>This extension enables customers to create return shipping labels for their orders.</description><notes>Official DHL OnlineRetoure extension</notes><authors><author><name>Andr&#xE9; Herrn</name><user>netresearch_dhl</user><email>[email protected]</email></author></authors><date>2016-08-24</date><time>2:06:20</time><compatible></compatible><dependencies><required><php><min>5.4.0</min><max>7.9.0</max></php></required></dependencies><contents><target name="mage"><dir name="doc"><dir name="Dhl_OnlineRetoure"><file name="ChangeLog.pdf" hash="477d147b9ed4e8c151545829711c8153"/><file name="OnlineRetoure.pdf" hash="d5cc6da50671ceb8a077a5d29ed023a6"/></dir></dir><dir name="app"><dir name="locale"><dir name="de_DE"><file name="Dhl_OnlineRetoure.csv" hash="8827dba2b24ad20d403589a9f5ad6c40"/></dir><dir name="en_US"><file name="Dhl_OnlineRetoure.csv" hash="83852549526f195b7ee7358da7e527e8"/></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="dhl_onlineretoure"><dir name="customer"><dir name="address"><file name="edit.phtml" hash="909bf13402710b00597318c98ef221f9"/></dir></dir><dir name="sales"><dir name="order"><dir name="email"><file name="retoure.phtml" hash="b249f02eb551793dc6b8a5528b0a76ab"/><file name="retoure_link.phtml" hash="ba30d09f0ca32fc8666ac616e10ea6dc"/></dir><dir name="info"><file name="buttons.phtml" hash="7f9d67ae24f168d16638938ad2d360f4"/><dir name="buttons"><file name="return.phtml" hash="1e37d7dc6168cf12f5967c22f24d0771"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="dhl_onlineretoure.xml" hash="c62937af58df11714df188c85fa689c0"/></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Dhl"><dir name="OnlineRetoure"><dir name="sql"><dir name="dhl_onlineretoure_setup"><file name="install-1.0.0.php" hash="c72350b1dc363a50ead8c8de0c72c277"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="c782c56c1206357bd8605a3d993c3e5f"/></dir><dir name="Test"><dir name="fixtures"><file name="config.yaml" hash="99d941bee5afaa73462eb39fce513244"/><file name="customers.yaml" hash="3c74c48142de7ab327fd23e83e1f1834"/><file name="orders.yaml" hash="28fb0293aff382a1ff7a028cf79ce285"/></dir><dir name="Controller"><file name="AddressControllerTest.php" hash="51f33ac76e8b2180a299ae757d97e243"/></dir><dir name="Helper"><file name="ValidateTest.php" hash="10ad9bdfd2a43c4f18334fc690a4b502"/></dir><dir name="Model"><file name="ConfigTest.php" hash="ffd5788a606328cb551193a885722148"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Shipping"><file name="MethodsTest.php" hash="6e9dbc7872d789bafe9b882e07963610"/></dir></dir><dir name="Backend"><file name="DeliverynamesTest.php" hash="9e139b29fa5cf2fea19708bd78b04ad4"/></dir></dir></dir><dir name="Soap"><file name="ClientTest.php" hash="0cc86f0a290b48b974f4a1f8832eee29"/></dir></dir><dir name="Block"><dir name="Sales"><dir name="Order"><dir name="Email"><file name="RetoureTest.php" hash="2289ecc5f1e8635d0e95fdf998b916d7"/></dir><dir name="Info"><dir name="Buttons"><file name="ReturnTest.php" hash="738eff0dedfcf5ebc9e1115d5ef59e3a"/></dir></dir></dir></dir><dir name="Customer"><dir name="Address"><file name="EditTest.php" hash="673d3dbfab742fd3b98cc6a4f0edea9f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0f3fe56b9702f7544a326e0435fd5ce9"/><file name="Validate.php" hash="cf7790d5ea158c62cecea91ec9207c9b"/><dir name="Customer"><file name="Address.php" hash="191119fa48a22d695eb86a9727ed7eb9"/></dir></dir><dir name="Model"><file name="Config.php" hash="ce2b80d433d7de8b7b4a349abbb12478"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Shipping"><file name="Methods.php" hash="2a0fd4c416259b25ac166bd59d7d142e"/></dir></dir><dir name="Backend"><file name="Deliverynames.php" hash="6a617724b0911225ecec2466556a527d"/></dir></dir></dir><dir name="Soap"><file name="Client.php" hash="4fa4e048f1f65682f51339552dd1ea76"/><dir name="Header"><file name="Auth.php" hash="5b1bf4d98d0ec1b26fe115a993f3ad3f"/></dir></dir><dir name="Validate"><file name="Exception.php" hash="f0edc305252703199985dc961a0b0e78"/></dir></dir><dir name="controllers"><file name="AddressController.php" hash="86bb0cd6329faf2f8f75baaba5c353db"/></dir><dir name="Block"><dir name="Sales"><dir name="Order"><dir name="Email"><file name="Retoure.php" hash="47454c8cfcd58e0fee0080cf6bd655ec"/></dir><dir name="Info"><dir name="Buttons"><file name="Return.php" hash="fa68d50958894e18a60c0d40ef362947"/></dir></dir></dir></dir><dir name="Adminhtml"><dir name="Form"><dir name="Field"><file name="Deliverynames.php" hash="1edd8b3051ebe4ff305a7bc42e98e36c"/><dir name="Country"><file name="Select.php" hash="eb7c8c59546622f62e8d3b5008f8ebf4"/></dir></dir></dir></dir><dir name="Customer"><dir name="Address"><file name="Edit.php" hash="7cd78a41c83f81f2b47a04c1dc79f18c"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="fc57ed05f6d3bfccec6d68f0fd47bdaf"/><file name="config.xml" hash="84dc7066766843adec55edef3885fb0d"/><file name="system.xml" hash="c54b8a089255ce39be1e747a9a536e91"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Dhl_OnlineRetoure.xml" hash="8db1e63cf0bfd40e8eafdd602aa9fe35"/></dir></dir></dir></target></contents></package>
<package><name>Dhl_OnlineRetoure</name><version>1.0.1</version><stability>stable</stability><license>OSL3</license><channel>community</channel><extends></extends><summary>DHL OnlineRetoure</summary><description>This extension enables customers to create return shipping labels for their orders.</description><notes>Official DHL OnlineRetoure extension</notes><authors><author><name>Andr&#xE9; Herrn</name><user>netresearch_dhl</user><email>[email protected]</email></author></authors><date>2017-10-05</date><time>3:22:48</time><compatible></compatible><dependencies><required><php><min>5.4.0</min><max>7.9.0</max></php></required></dependencies><contents><target name="mage"><dir name="doc"><dir name="Dhl_OnlineRetoure"><file name="ChangeLog.pdf" hash="c55f1e9a1bd009c5f18965f1f45ad079"/><file name="OnlineRetoure.pdf" hash="ba01c24239e6dc386a1a1823ca95e77d"/></dir></dir><dir name="app"><dir name="locale"><dir name="de_DE"><file name="Dhl_OnlineRetoure.csv" hash="8827dba2b24ad20d403589a9f5ad6c40"/></dir><dir name="en_US"><file name="Dhl_OnlineRetoure.csv" hash="83852549526f195b7ee7358da7e527e8"/></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="dhl_onlineretoure"><dir name="customer"><dir name="address"><file name="edit.phtml" hash="909bf13402710b00597318c98ef221f9"/></dir></dir><dir name="sales"><dir name="order"><dir name="email"><file name="retoure.phtml" hash="b249f02eb551793dc6b8a5528b0a76ab"/><file name="retoure_link.phtml" hash="ba30d09f0ca32fc8666ac616e10ea6dc"/></dir><dir name="info"><file name="buttons.phtml" hash="7f9d67ae24f168d16638938ad2d360f4"/><dir name="buttons"><file name="return.phtml" hash="1e37d7dc6168cf12f5967c22f24d0771"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="dhl_onlineretoure.xml" hash="c62937af58df11714df188c85fa689c0"/></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Dhl"><dir name="OnlineRetoure"><dir name="sql"><dir name="dhl_onlineretoure_setup"><file name="install-1.0.0.php" hash="c72350b1dc363a50ead8c8de0c72c277"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="c782c56c1206357bd8605a3d993c3e5f"/></dir><dir name="Test"><dir name="fixtures"><file name="config.yaml" hash="99d941bee5afaa73462eb39fce513244"/><file name="customers.yaml" hash="3c74c48142de7ab327fd23e83e1f1834"/><file name="orders.yaml" hash="28fb0293aff382a1ff7a028cf79ce285"/></dir><dir name="Controller"><file name="AddressControllerTest.php" hash="51f33ac76e8b2180a299ae757d97e243"/></dir><dir name="Helper"><file name="ValidateTest.php" hash="52ecefe944f71b5b58481586048bd704"/></dir><dir name="Model"><file name="ConfigTest.php" hash="af9b12994af0fc0ac022b0c500159a88"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Shipping"><file name="MethodsTest.php" hash="6e9dbc7872d789bafe9b882e07963610"/></dir></dir><dir name="Backend"><file name="DeliverynamesTest.php" hash="9e139b29fa5cf2fea19708bd78b04ad4"/></dir></dir></dir><dir name="Soap"><file name="ClientTest.php" hash="0cc86f0a290b48b974f4a1f8832eee29"/></dir></dir><dir name="Block"><dir name="Sales"><dir name="Order"><dir name="Email"><file name="RetoureTest.php" hash="2289ecc5f1e8635d0e95fdf998b916d7"/></dir><dir name="Info"><dir name="Buttons"><file name="ReturnTest.php" hash="738eff0dedfcf5ebc9e1115d5ef59e3a"/></dir></dir></dir></dir><dir name="Customer"><dir name="Address"><file name="EditTest.php" hash="673d3dbfab742fd3b98cc6a4f0edea9f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0f3fe56b9702f7544a326e0435fd5ce9"/><file name="Validate.php" hash="cf7790d5ea158c62cecea91ec9207c9b"/><dir name="Customer"><file name="Address.php" hash="191119fa48a22d695eb86a9727ed7eb9"/></dir></dir><dir name="Model"><file name="Config.php" hash="8b595df8060946898287ee6c2a267c36"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Shipping"><file name="Methods.php" hash="2a0fd4c416259b25ac166bd59d7d142e"/></dir></dir><dir name="Backend"><file name="Deliverynames.php" hash="6a617724b0911225ecec2466556a527d"/></dir></dir></dir><dir name="Soap"><file name="Client.php" hash="4fa4e048f1f65682f51339552dd1ea76"/><dir name="Header"><file name="Auth.php" hash="5b1bf4d98d0ec1b26fe115a993f3ad3f"/></dir></dir><dir name="Validate"><file name="Exception.php" hash="f0edc305252703199985dc961a0b0e78"/></dir></dir><dir name="controllers"><file name="AddressController.php" hash="86bb0cd6329faf2f8f75baaba5c353db"/></dir><dir name="Block"><dir name="Sales"><dir name="Order"><dir name="Email"><file name="Retoure.php" hash="47454c8cfcd58e0fee0080cf6bd655ec"/></dir><dir name="Info"><dir name="Buttons"><file name="Return.php" hash="fa68d50958894e18a60c0d40ef362947"/></dir></dir></dir></dir><dir name="Adminhtml"><dir name="Form"><dir name="Field"><file name="Deliverynames.php" hash="1edd8b3051ebe4ff305a7bc42e98e36c"/><dir name="Country"><file name="Select.php" hash="eb7c8c59546622f62e8d3b5008f8ebf4"/></dir></dir></dir></dir><dir name="Customer"><dir name="Address"><file name="Edit.php" hash="7cd78a41c83f81f2b47a04c1dc79f18c"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="0a9950dedb5c1033f94b192799654147"/><file name="system.xml" hash="c54b8a089255ce39be1e747a9a536e91"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Dhl_OnlineRetoure.xml" hash="8db1e63cf0bfd40e8eafdd602aa9fe35"/></dir></dir></dir></target></contents></package>