Skip to content

Commit

Permalink
merge develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
tig-rikjonkmans committed Oct 24, 2017
2 parents 2e260b4 + 6aaaa71 commit 2b4e0ef
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 2 deletions.
56 changes: 56 additions & 0 deletions Plugin/Quote/Address/RateRequestPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
*
* ..::..
* ..::::::::::::..
* ::'''''':''::'''''::
* ::.. ..: : ....::
* :::: ::: : : ::
* :::: ::: : ''' ::
* ::::..:::..::.....::
* ''::::::::::::''
* ''::''
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/
namespace TIG\PostNL\Plugin\Quote\Address;

class RateRequestPlugin
{
/**
* When a customer is logged-in and try's to checkout the error is thrown saying 'Please select a shippingmethod'
* This is because of the limitCarrier that is set with 'tig' as value. Later on in the process of the checkout the
* carrier config is requested. Magento will request this like carrier/[carrier_code].
*
* @param $subject
* @param $key
* @param $value
*
* @return array
*/
// @codingStandardsIgnoreLine
public function beforeSetData($subject, $key, $value)
{
if ($key == 'limit_carrier' && $value == 'tig') {
return [$key, 'tig_postnl'];
}

return [$key, $value];
}
}
72 changes: 72 additions & 0 deletions Test/Unit/Plugin/Quote/Address/RateRequestPluginTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

/**
*
* ..::..
* ..::::::::::::..
* ::'''''':''::'''''::
* ::.. ..: : ....::
* :::: ::: : : ::
* :::: ::: : ''' ::
* ::::..:::..::.....::
* ''::::::::::::''
* ''::''
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/
namespace TIG\PostNL\Test\Unit\Plugin\Quote\Address;

use TIG\PostNL\Plugin\Quote\Address\RateRequestPlugin;
use TIG\PostNL\Test\TestCase;

class RateRequestPluginTest extends TestCase
{
public $instanceClass = RateRequestPlugin::class;

public function dataProvider()
{
return [
'TIG PostNL Limit Carrier' => [
'limit_carrier',
'tig',
['limit_carrier','tig_postnl']
],
'FlatRate Limit Carrier' => [
'limit_carrier',
'flatrate',
['limit_carrier','flatrate']
],
];
}

/**
* @param $key
* @param $value
* @param $expected
*
* @dataProvider dataProvider
*/
public function testBeforeSetData($key, $value, $expected)
{
$instance = $this->getInstance();
$result = $instance->beforeSetData(null, $key, $value);

$this->assertEquals($expected, $result);
}
}
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</carriers>
<tig_postnl>
<stability>alpha</stability>
<supported_magento_version>2.1.5</supported_magento_version>
<supported_magento_version>2.1.5 - 2.1.9, 2.2.0</supported_magento_version>
<generalconfiguration_extension_status>
<modus>0</modus>
<customer_number_test>11223344</customer_number_test>
Expand Down
4 changes: 4 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<plugin name="TIG_PostNL_Config_Source_Allmethods" type="TIG\PostNL\Plugin\Config\Source\AllMethodsPlugin" sortOrder="1"/>
</type>

<type name="\Magento\Quote\Model\Quote\Address\RateRequest">
<plugin name="TIG_PostNL_Address_RateRequest" type="TIG\PostNL\Plugin\Quote\Address\RateRequestPlugin" sortOrder="1"/>
</type>

<type name="TIG\PostNL\Logging\Log">
<arguments>
<argument name="name" xsi:type="string">postnl_logging</argument>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:TIG_PostNL:etc/tig_module.xsd">
<module name="TIG_PostNL" setup_version="1.1.5" stability="alpha">
<module name="TIG_PostNL" setup_version="1.1.6" stability="alpha">
<sequence>
<module name="Magento_Shipping"/>
<module name="Magento_Directory"/>
Expand Down

0 comments on commit 2b4e0ef

Please sign in to comment.