From 1289010a6cb7638f0fb04034fedb0fe1c1886850 Mon Sep 17 00:00:00 2001 From: ikk0 Date: Tue, 3 May 2016 14:07:40 +0200 Subject: [PATCH 01/18] Fixed column description for "website_id" field in cataloginventory_stock_item Currently says "Is Divided into Multiple Boxes for Shipping". That's wrong. :-) Changed it to "Website ID". May need to be put into an upgrade schema instead. --- app/code/Magento/CatalogInventory/Setup/InstallSchema.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogInventory/Setup/InstallSchema.php b/app/code/Magento/CatalogInventory/Setup/InstallSchema.php index 67a126f4a20fc..a19eb9d1cc573 100644 --- a/app/code/Magento/CatalogInventory/Setup/InstallSchema.php +++ b/app/code/Magento/CatalogInventory/Setup/InstallSchema.php @@ -249,7 +249,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 5, ['unsigned' => true, 'nullable' => false, 'default' => 0], - 'Is Divided into Multiple Boxes for Shipping' + 'Website ID' ) ->addIndex( $installer->getIdxName( From 95bc24c215a77c5ae87df1b1a175be6a47a5e43e Mon Sep 17 00:00:00 2001 From: Roman Liukshyn Date: Thu, 4 Aug 2016 18:10:47 +0300 Subject: [PATCH 02/18] MAGETWO-56467: Free shipping threshold fields are mixed up in UPS and Fedex configurations --- app/code/Magento/Fedex/etc/adminhtml/system.xml | 4 ++-- app/code/Magento/Ups/etc/adminhtml/system.xml | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Fedex/etc/adminhtml/system.xml b/app/code/Magento/Fedex/etc/adminhtml/system.xml index 1de61c2c15494..16966322f25f9 100644 --- a/app/code/Magento/Fedex/etc/adminhtml/system.xml +++ b/app/code/Magento/Fedex/etc/adminhtml/system.xml @@ -101,11 +101,11 @@ Magento\Fedex\Model\Source\Freemethod - + Magento\Config\Model\Config\Source\Enabledisable - + validate-number validate-zero-or-greater 1 diff --git a/app/code/Magento/Ups/etc/adminhtml/system.xml b/app/code/Magento/Ups/etc/adminhtml/system.xml index dd83ab7c4ed96..39bd613974d5e 100644 --- a/app/code/Magento/Ups/etc/adminhtml/system.xml +++ b/app/code/Magento/Ups/etc/adminhtml/system.xml @@ -32,12 +32,15 @@ Magento\Ups\Model\Config\Source\Container - + Magento\Config\Model\Config\Source\Enabledisable validate-number validate-zero-or-greater + + 1 + From ce1160fbf7d1d08bc2d0d6f3d4c648074271024b Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Fri, 5 Aug 2016 14:20:57 +0300 Subject: [PATCH 03/18] MAGETWO-56344: [Github] #5902 Braintree doesn't work when using table prefixing --- .../Model/ResourceModel/PaymentToken.php | 2 +- .../Model/ResourceModel/PaymentTokenTest.php | 114 ++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 dev/tests/integration/testsuite/Magento/Vault/Model/ResourceModel/PaymentTokenTest.php diff --git a/app/code/Magento/Vault/Model/ResourceModel/PaymentToken.php b/app/code/Magento/Vault/Model/ResourceModel/PaymentToken.php index e7644080abb7d..b9ffc69cf7fe8 100644 --- a/app/code/Magento/Vault/Model/ResourceModel/PaymentToken.php +++ b/app/code/Magento/Vault/Model/ResourceModel/PaymentToken.php @@ -104,7 +104,7 @@ public function addLinkToOrderPayment($paymentTokenId, $orderPaymentId) $connection = $this->getConnection(); $select = $connection->select() - ->from(InstallSchema::ORDER_PAYMENT_TO_PAYMENT_TOKEN_TABLE) + ->from($this->getTable(InstallSchema::ORDER_PAYMENT_TO_PAYMENT_TOKEN_TABLE)) ->where('order_payment_id = ?', (int) $orderPaymentId) ->where('payment_token_id =?', (int) $paymentTokenId); diff --git a/dev/tests/integration/testsuite/Magento/Vault/Model/ResourceModel/PaymentTokenTest.php b/dev/tests/integration/testsuite/Magento/Vault/Model/ResourceModel/PaymentTokenTest.php new file mode 100644 index 0000000000000..88974f0d9cc5e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Vault/Model/ResourceModel/PaymentTokenTest.php @@ -0,0 +1,114 @@ +objectManager = Bootstrap::getObjectManager(); + $this->order = $this->objectManager->create(Order::class); + $this->paymentToken = $this->objectManager->create(PaymentToken::class); + $this->paymentTokenManagement = $this->objectManager->get(PaymentTokenManagement::class); + + $this->resource = $this->objectManager->get(ResourceConnection::class); + $this->connection = $this->resource->getConnection(); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * @magentoDataFixture Magento/Braintree/_files/paypal_vault_token.php + */ + public function testAddLinkToOrderPaymentExists() + { + $this->order->loadByIncrementId(self::ORDER_INCREMENT_ID); + $paymentToken = $this->paymentTokenManagement + ->getByGatewayToken(self::TOKEN, PayPalConfigProvider::PAYPAL_CODE, self::CUSTOMER_ID); + + $this->connection->insert( + $this->resource->getTableName(InstallSchema::ORDER_PAYMENT_TO_PAYMENT_TOKEN_TABLE), + [ + 'order_payment_id' => $this->order->getPayment()->getEntityId(), + 'payment_token_id' => $paymentToken->getEntityId() + ] + ); + + static::assertTrue( + $this->paymentToken->addLinkToOrderPayment( + $paymentToken->getEntityId(), + $this->order->getPayment()->getEntityId() + ) + ); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * @magentoDataFixture Magento/Braintree/_files/paypal_vault_token.php + */ + public function testAddLinkToOrderPaymentCreate() + { + $this->order->loadByIncrementId(self::ORDER_INCREMENT_ID); + $paymentToken = $this->paymentTokenManagement + ->getByGatewayToken(self::TOKEN, PayPalConfigProvider::PAYPAL_CODE, self::CUSTOMER_ID); + + $select = $this->connection->select() + ->from($this->resource->getTableName(InstallSchema::ORDER_PAYMENT_TO_PAYMENT_TOKEN_TABLE)) + ->where('order_payment_id = ?', (int) $this->order->getPayment()->getEntityId()) + ->where('payment_token_id =?', (int) $paymentToken->getEntityId()); + + static::assertEmpty($this->connection->fetchRow($select)); + static::assertTrue( + $this->paymentToken->addLinkToOrderPayment( + $paymentToken->getEntityId(), + $this->order->getPayment()->getEntityId() + ) + ); + static::assertNotEmpty($this->connection->fetchRow($select)); + } +} From 85ecf121c10912de2e54ccd9acc3b6288fecadf6 Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Mon, 8 Aug 2016 10:15:12 +0300 Subject: [PATCH 04/18] MAGETWO-55953: Exception occurs when tracking shipment with invalid FedEx tracking number - Updated wsdl schema - Refactored response parsing for new schema changes - Refactored unit tests - Refactored tracking details view --- app/code/Magento/Fedex/Model/Carrier.php | 318 +++-- .../Fedex/Test/Unit/Model/CarrierTest.php | 602 +++++++-- ...kService_v5.wsdl => TrackService_v10.wsdl} | 1181 ++++++++++++++--- .../frontend/templates/tracking/details.phtml | 95 ++ .../frontend/templates/tracking/popup.phtml | 180 +-- .../templates/tracking/progress.phtml | 43 + 6 files changed, 1839 insertions(+), 580 deletions(-) rename app/code/Magento/Fedex/etc/wsdl/{TrackService_v5.wsdl => TrackService_v10.wsdl} (63%) create mode 100644 app/code/Magento/Shipping/view/frontend/templates/tracking/details.phtml create mode 100644 app/code/Magento/Shipping/view/frontend/templates/tracking/progress.phtml diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 4f8aae4962db7..b3ffabf74dac3 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -126,6 +126,18 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C 'Key', 'Password', 'MeterNumber', ]; + /** + * Version of tracking service + * @var int + */ + private static $trackServiceVersion = 10; + + /** + * List of TrackReply errors + * @var array + */ + private static $trackingErrors = ['FAILURE', 'ERROR']; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory @@ -193,7 +205,7 @@ public function __construct( $wsdlBasePath = $configReader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_Fedex') . '/wsdl/'; $this->_shipServiceWsdl = $wsdlBasePath . 'ShipService_v10.wsdl'; $this->_rateServiceWsdl = $wsdlBasePath . 'RateService_v10.wsdl'; - $this->_trackServiceWsdl = $wsdlBasePath . 'TrackService_v5.wsdl'; + $this->_trackServiceWsdl = $wsdlBasePath . 'TrackService_v' . self::$trackServiceVersion . '.wsdl'; } /** @@ -371,6 +383,9 @@ public function setRequest(RateRequest $request) */ public function getResult() { + if (!$this->_result) { + $this->_result = $this->_trackFactory->create(); + } return $this->_result; } @@ -646,7 +661,6 @@ protected function _getXmlQuotes() { $r = $this->_rawRequest; $xml = $this->_xmlElFactory->create( - ['data' => ''] ); @@ -1035,9 +1049,16 @@ protected function _getXMLTracking($tracking) 'AccountNumber' => $this->getConfigData('account'), 'MeterNumber' => $this->getConfigData('meter_number'), ], - 'Version' => ['ServiceId' => 'trck', 'Major' => '5', 'Intermediate' => '0', 'Minor' => '0'], - 'PackageIdentifier' => ['Type' => 'TRACKING_NUMBER_OR_DOORTAG', 'Value' => $tracking], - 'IncludeDetailedScans' => 1, + 'Version' => [ + 'ServiceId' => 'trck', + 'Major' => self::$trackServiceVersion, + 'Intermediate' => '0', + 'Minor' => '0', + ], + 'SelectionDetails' => [ + 'PackageIdentifier' => ['Type' => 'TRACKING_NUMBER_OR_DOORTAG', 'Value' => $tracking], + ], + 'ProcessingOptions' => 'INCLUDE_DETAILED_SCANS' ]; $requestString = serialize($trackRequest); $response = $this->_getCachedQuotes($requestString); @@ -1064,114 +1085,45 @@ protected function _getXMLTracking($tracking) /** * Parse tracking response * - * @param string[] $trackingValue + * @param string $trackingValue * @param \stdClass $response * @return void - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - protected function _parseTrackingResponse($trackingValue, $response) + protected function _parseTrackingResponse($trackingValue, \stdClass $response) { - if (is_object($response)) { - if ($response->HighestSeverity == 'FAILURE' || $response->HighestSeverity == 'ERROR') { - $errorTitle = (string)$response->Notifications->Message; - } elseif (isset($response->TrackDetails)) { - $trackInfo = $response->TrackDetails; - $resultArray['status'] = (string)$trackInfo->StatusDescription; - $resultArray['service'] = (string)$trackInfo->ServiceInfo; - $timestamp = isset( - $trackInfo->EstimatedDeliveryTimestamp - ) ? $trackInfo->EstimatedDeliveryTimestamp : $trackInfo->ActualDeliveryTimestamp; - $timestamp = strtotime((string)$timestamp); - if ($timestamp) { - $resultArray['deliverydate'] = date('Y-m-d', $timestamp); - $resultArray['deliverytime'] = date('H:i:s', $timestamp); - } - - $deliveryLocation = isset( - $trackInfo->EstimatedDeliveryAddress - ) ? $trackInfo->EstimatedDeliveryAddress : $trackInfo->ActualDeliveryAddress; - $deliveryLocationArray = []; - if (isset($deliveryLocation->City)) { - $deliveryLocationArray[] = (string)$deliveryLocation->City; - } - if (isset($deliveryLocation->StateOrProvinceCode)) { - $deliveryLocationArray[] = (string)$deliveryLocation->StateOrProvinceCode; - } - if (isset($deliveryLocation->CountryCode)) { - $deliveryLocationArray[] = (string)$deliveryLocation->CountryCode; - } - if ($deliveryLocationArray) { - $resultArray['deliverylocation'] = implode(', ', $deliveryLocationArray); - } - - $resultArray['signedby'] = (string)$trackInfo->DeliverySignatureName; - $resultArray['shippeddate'] = date('Y-m-d', (int)$trackInfo->ShipTimestamp); - if (isset($trackInfo->PackageWeight) && isset($trackInfo->Units)) { - $weight = (string)$trackInfo->PackageWeight; - $unit = (string)$trackInfo->Units; - $resultArray['weight'] = "{$weight} {$unit}"; - } - - $packageProgress = []; - if (isset($trackInfo->Events)) { - $events = $trackInfo->Events; - if (isset($events->Address)) { - $events = [$events]; - } - foreach ($events as $event) { - $tempArray = []; - $tempArray['activity'] = (string)$event->EventDescription; - $timestamp = strtotime((string)$event->Timestamp); - if ($timestamp) { - $tempArray['deliverydate'] = date('Y-m-d', $timestamp); - $tempArray['deliverytime'] = date('H:i:s', $timestamp); - } - if (isset($event->Address)) { - $addressArray = []; - $address = $event->Address; - if (isset($address->City)) { - $addressArray[] = (string)$address->City; - } - if (isset($address->StateOrProvinceCode)) { - $addressArray[] = (string)$address->StateOrProvinceCode; - } - if (isset($address->CountryCode)) { - $addressArray[] = (string)$address->CountryCode; - } - if ($addressArray) { - $tempArray['deliverylocation'] = implode(', ', $addressArray); - } - } - $packageProgress[] = $tempArray; - } - } - - $resultArray['progressdetail'] = $packageProgress; - } + if (in_array($response->HighestSeverity, self::$trackingErrors)) { + $this->appendTrackingError($trackingValue, (string) $response->Notifications->Message); + return; + } else if (empty($response->CompletedTrackDetails) || empty($response->CompletedTrackDetails->TrackDetails)) { + $this->appendTrackingError($trackingValue, __('No available tracking items')); + return; } - if (!$this->_result) { - $this->_result = $this->_trackFactory->create(); + $trackInfo = $response->CompletedTrackDetails->TrackDetails; + + // Fedex can return tracking details as single object instead array + if (is_object($trackInfo)) { + $trackInfo = [$trackInfo]; } - if (isset($resultArray)) { + $result = $this->getResult(); + $carrierTitle = $this->getConfigData('title'); + $counter = 0; + foreach ($trackInfo as $item) { $tracking = $this->_trackStatusFactory->create(); - $tracking->setCarrier('fedex'); - $tracking->setCarrierTitle($this->getConfigData('title')); + $tracking->setCarrier(self::CODE); + $tracking->setCarrierTitle($carrierTitle); $tracking->setTracking($trackingValue); - $tracking->addData($resultArray); - $this->_result->append($tracking); - } else { - $error = $this->_trackErrorFactory->create(); - $error->setCarrier('fedex'); - $error->setCarrierTitle($this->getConfigData('title')); - $error->setTracking($trackingValue); - $error->setErrorMessage( - $errorTitle ? $errorTitle : __('For some reason we can\'t retrieve tracking info right now.') + $tracking->addData($this->processTrackingDetails($item)); + $result->append($tracking); + $counter ++; + } + + // no available tracking details + if (!$counter) { + $this->appendTrackingError( + $trackingValue, __('For some reason we can\'t retrieve tracking info right now.') ); - $this->_result->append($error); } } @@ -1596,4 +1548,166 @@ protected function filterDebugData($data) } return $data; } + + /** + * @param \stdClass $trackInfo + * @return array + */ + private function processTrackingDetails(\stdClass $trackInfo) + { + $result = [ + 'shippeddate' => null, + 'deliverydate' => null, + 'deliverytime' => null, + 'deliverylocation' => null, + 'weight' => null, + 'progressdetail' => [], + ]; + + if (!empty($trackInfo->ShipTimestamp)) { + $datetime = \DateTime::createFromFormat(\DateTime::ISO8601, $trackInfo->ShipTimestamp); + $result['shippeddate'] = $datetime->format('Y-m-d'); + } + + $result['signedby'] = !empty($trackInfo->DeliverySignatureName) ? + (string) $trackInfo->DeliverySignatureName : + null; + + $result['status'] = (!empty($trackInfo->StatusDetail) && !empty($trackInfo->StatusDetail->Description)) ? + (string) $trackInfo->StatusDetail->Description : + null; + $result['service'] = (!empty($trackInfo->Service) && !empty($trackInfo->Service->Description)) ? + (string) $trackInfo->Service->Description : + null; + + $datetime = $this->getDeliveryDateTime($trackInfo); + if ($datetime) { + $result['deliverydate'] = $datetime->format('Y-m-d'); + $result['deliverytime'] = $datetime->format('H:i:s'); + } + + $address = null; + if (!empty($trackInfo->EstimatedDeliveryAddress)) { + $address = $trackInfo->EstimatedDeliveryAddress; + } elseif (!empty($trackInfo->ActualDeliveryAddress)) { + $address = $trackInfo->ActualDeliveryAddress; + } + + if (!empty($address)) { + $result['deliverylocation'] = $this->getDeliveryAddress($address); + } + + if (!empty($trackInfo->PackageWeight)) { + $result['weight'] = sprintf( + '%s %s', + (string) $trackInfo->PackageWeight->Value, + (string) $trackInfo->PackageWeight->Units + ); + } + + if (!empty($trackInfo->Events)) { + $events = $trackInfo->Events; + if (is_object($events)) { + $events = [$trackInfo->Events]; + } + $result['progressdetail'] = $this->processTrackDetailsEvents($events); + } + + return $result; + } + + /** + * Parse delivery datetime from tracking details + * @param \stdClass $trackInfo + * @return \Datetime|null + */ + private function getDeliveryDateTime(\stdClass $trackInfo) + { + $timestamp = null; + if (!empty($trackInfo->EstimatedDeliveryTimestamp)) { + $timestamp = $trackInfo->EstimatedDeliveryTimestamp; + } elseif (!empty($trackInfo->ActualDeliveryTimestamp)) { + $timestamp = $trackInfo->ActualDeliveryTimestamp; + } + + return $timestamp ? \DateTime::createFromFormat(\DateTime::ISO8601, $timestamp) : null; + } + + /** + * Get delivery address details in string representation + * Return City, State, Country Code + * + * @param \stdClass $address + * @return \Magento\Framework\Phrase|string + */ + private function getDeliveryAddress(\stdClass $address) + { + $details = []; + + if (!empty($address->City)) { + $details[] = (string) $address->City; + } + + if (!empty($address->StateOrProvinceCode)) { + $details[] = (string) $address->StateOrProvinceCode; + } + + if (!empty($address->CountryCode)) { + $details[] = (string) $address->CountryCode; + } + + return implode(', ', $details); + } + + /** + * Parse tracking details events from response + * Return list of items in such format: + * ['activity', 'deliverydate', 'deliverytime', 'deliverylocation'] + * + * @param array $events + * @return array + */ + private function processTrackDetailsEvents(array $events) + { + $result = []; + /** @var \stdClass $event */ + foreach ($events as $event) { + $item = [ + 'activity' => (string) $event->EventDescription, + 'deliverydate' => null, + 'deliverytime' => null, + 'deliverylocation' => null + ]; + + if (!empty($event->Timestamp)) { + $datetime = \DateTime::createFromFormat(\DateTime::ISO8601, $event->Timestamp); + $item['deliverydate'] = $datetime->format('Y-m-d'); + $item['deliverytime'] = $datetime->format('H:i:s'); + } + + if (!empty($event->Address)) { + $item['deliverylocation'] = $this->getDeliveryAddress($event->Address); + } + + $result[] = $item; + } + + return $result; + } + + /** + * Append error message to rate result instance + * @param string $trackingValue + * @param string $errorMessage + */ + private function appendTrackingError($trackingValue, $errorMessage) + { + $error = $this->_trackErrorFactory->create(); + $error->setCarrier('fedex'); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setTracking($trackingValue); + $error->setErrorMessage($errorMessage); + $result = $this->getResult(); + $result->append($error); + } } diff --git a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php index 702b6e69098ba..4a54993508c67 100644 --- a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php @@ -5,167 +5,200 @@ */ namespace Magento\Fedex\Test\Unit\Model; +use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; +use Magento\CatalogInventory\Model\StockRegistry; +use Magento\Directory\Helper\Data; +use Magento\Directory\Model\Country; +use Magento\Directory\Model\CountryFactory; +use Magento\Directory\Model\CurrencyFactory; +use Magento\Directory\Model\RegionFactory; use Magento\Fedex\Model\Carrier; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Module\Dir\Reader; +use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\Xml\Security; use Magento\Quote\Model\Quote\Address\RateRequest; +use Magento\Quote\Model\Quote\Address\RateResult\Error as RateResultError; +use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory as RateErrorFactory; +use Magento\Quote\Model\Quote\Address\RateResult\Method; +use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory; +use Magento\Shipping\Model\Rate\Result as RateResult; +use Magento\Shipping\Model\Rate\ResultFactory as RateResultFactory; +use Magento\Shipping\Model\Simplexml\ElementFactory; +use Magento\Shipping\Model\Tracking\Result; +use Magento\Shipping\Model\Tracking\Result\Error; +use Magento\Shipping\Model\Tracking\Result\ErrorFactory; +use Magento\Shipping\Model\Tracking\Result\Status; +use Magento\Shipping\Model\Tracking\Result\StatusFactory; +use Magento\Shipping\Model\Tracking\ResultFactory; +use Magento\Store\Model\Store; +use Magento\Store\Model\StoreManagerInterface; +use PHPUnit_Framework_MockObject_MockObject as MockObject; +use Psr\Log\LoggerInterface; /** - * Class CarrierTest - * @package Magento\Fedex\Model - * TODO refactor me + * CarrierTest contains units test for Fedex carrier methods * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CarrierTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + * @var ObjectManager */ - protected $_helper; + private $helper; /** - * @var \Magento\Fedex\Model\Carrier + * @var Carrier|MockObject */ - protected $_model; + private $model; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ScopeConfigInterface|MockObject */ - protected $scope; + private $scope; /** - * Model under test - * - * @var \Magento\Quote\Model\Quote\Address\RateResult\Error|\PHPUnit_Framework_MockObject_MockObject + * @var Error|MockObject */ - protected $error; + private $error; /** - * @var \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory|\PHPUnit_Framework_MockObject_MockObject + * @var ErrorFactory|MockObject */ - protected $errorFactory; + private $errorFactory; /** - * @return void + * @var ErrorFactory|MockObject + */ + private $trackErrorFactory; + + /** + * @var StatusFactory|MockObject + */ + private $statusFactory; + + /** + * @var Result + */ + private $result; + + /** + * @inheritdoc */ protected function setUp() { - $this->scope = $this->getMockBuilder( - \Magento\Framework\App\Config\ScopeConfigInterface::class - )->disableOriginalConstructor()->getMock(); - - $this->scope->expects($this->any())->method('getValue')->willReturnCallback([$this, 'scopeConfiggetValue']); - $country = $this->getMock( - \Magento\Directory\Model\Country::class, - ['load', 'getData', '__wakeup'], - [], - '', - false - ); - $country->expects($this->any())->method('load')->will($this->returnSelf()); - $countryFactory = $this->getMock(\Magento\Directory\Model\CountryFactory::class, ['create'], [], '', false); - $countryFactory->expects($this->any())->method('create')->will($this->returnValue($country)); - - $rate = $this->getMock(\Magento\Shipping\Model\Rate\Result::class, ['getError'], [], '', false); - $rateFactory = $this->getMock(\Magento\Shipping\Model\Rate\ResultFactory::class, ['create'], [], '', false); - $rateFactory->expects($this->any())->method('create')->will($this->returnValue($rate)); - $this->error = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address\RateResult\Error::class) - ->setMethods(['setCarrier', 'setCarrierTitle', 'setErrorMessage'])->getMock(); - $this->errorFactory = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory::class) - ->disableOriginalConstructor()->setMethods(['create'])->getMock(); - $this->errorFactory->expects($this->any())->method('create')->willReturn($this->error); - - $store = $this->getMock(\Magento\Store\Model\Store::class, ['getBaseCurrencyCode', '__wakeup'], [], '', false); - $storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); - $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); - $priceCurrency = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class)->getMock(); - - $rateMethod = $this->getMock( - \Magento\Quote\Model\Quote\Address\RateResult\Method::class, - null, - ['priceCurrency' => $priceCurrency] - ); - $rateMethodFactory = $this->getMock( - \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory::class, - ['create'], - [], - '', - false - ); - $rateMethodFactory->expects($this->any())->method('create')->will($this->returnValue($rateMethod)); - $this->_model = $this->getMock( - \Magento\Fedex\Model\Carrier::class, - ['_getCachedQuotes', '_debug'], - [ - 'scopeConfig' => $this->scope, - 'rateErrorFactory' => $this->errorFactory, - 'logger' => $this->getMock(\Psr\Log\LoggerInterface::class), - 'xmlSecurity' => new Security(), - 'xmlElFactory' => $this->getMock( - \Magento\Shipping\Model\Simplexml\ElementFactory::class, - [], - [], - '', - false - ), - 'rateFactory' => $rateFactory, - 'rateMethodFactory' => $rateMethodFactory, - 'trackFactory' => $this->getMock( - \Magento\Shipping\Model\Tracking\ResultFactory::class, - [], - [], - '', - false - ), - 'trackErrorFactory' => $this->getMock(\Magento\Shipping\Model\Tracking\Result\ErrorFactory::class, [], [], '', false), - 'trackStatusFactory' => $this->getMock(\Magento\Shipping\Model\Tracking\Result\StatusFactory::class, [], [], '', false), - 'regionFactory' => $this->getMock(\Magento\Directory\Model\RegionFactory::class, [], [], '', false), - 'countryFactory' => $countryFactory, - 'currencyFactory' => $this->getMock(\Magento\Directory\Model\CurrencyFactory::class, [], [], '', false), - 'directoryData' => $this->getMock(\Magento\Directory\Helper\Data::class, [], [], '', false), - 'stockRegistry' => $this->getMock( - \Magento\CatalogInventory\Model\StockRegistry::class, - [], - [], - '', - false - ), - 'storeManager' => $storeManager, - 'configReader' => $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false), - 'productCollectionFactory' => $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, - [], - [], - '', - false - ), - 'data' => [], - ] - ); + $this->helper = new ObjectManager($this); + $this->scope = $this->getMockBuilder(ScopeConfigInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->scope->expects(static::any()) + ->method('getValue') + ->willReturnCallback([$this, 'scopeConfigGetValue']); + + $countryFactory = $this->getCountryFactory(); + $rateFactory = $this->getRateFactory(); + $storeManager = $this->getStoreManager(); + $resultFactory = $this->getResultFactory(); + $this->initRateErrorFactory(); + + $rateMethodFactory = $this->getRateMethodFactory(); + + $this->trackErrorFactory = $this->getMockBuilder(ErrorFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->statusFactory = $this->getMockBuilder(StatusFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $elementFactory = $this->getMockBuilder(ElementFactory::class) + ->disableOriginalConstructor() + ->getMock(); + + $collectionFactory = $this->getMockBuilder(CollectionFactory::class) + ->disableOriginalConstructor() + ->getMock(); + + $regionFactory = $this->getMockBuilder(RegionFactory::class) + ->disableOriginalConstructor() + ->getMock(); + + $currencyFactory = $this->getMockBuilder(CurrencyFactory::class) + ->disableOriginalConstructor() + ->getMock(); + + $data = $this->getMockBuilder(Data::class) + ->disableOriginalConstructor() + ->getMock(); + + $stockRegistry = $this->getMockBuilder(StockRegistry::class) + ->disableOriginalConstructor() + ->getMock(); + + $reader = $this->getMockBuilder(Reader::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $this->getMockBuilder(Carrier::class) + ->setMethods(['_getCachedQuotes', '_debug']) + ->setConstructorArgs( + [ + 'scopeConfig' => $this->scope, + 'rateErrorFactory' => $this->errorFactory, + 'logger' => $this->getMock(LoggerInterface::class), + 'xmlSecurity' => new Security(), + 'xmlElFactory' => $elementFactory, + 'rateFactory' => $rateFactory, + 'rateMethodFactory' => $rateMethodFactory, + 'trackFactory' => $resultFactory, + 'trackErrorFactory' => $this->trackErrorFactory, + 'trackStatusFactory' => $this->statusFactory, + 'regionFactory' => $regionFactory, + 'countryFactory' => $countryFactory, + 'currencyFactory' => $currencyFactory, + 'directoryData' => $data, + 'stockRegistry' => $stockRegistry, + 'storeManager' => $storeManager, + 'configReader' => $reader, + 'productCollectionFactory' => $collectionFactory, + ] + ) + ->getMock(); } + /** + * @covers \Magento\Fedex\Model\Carrier::setRequest + */ public function testSetRequestWithoutCity() { - $requestMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address\RateRequest::class) + $request = $this->getMockBuilder(RateRequest::class) ->disableOriginalConstructor() ->setMethods(['getDestCity']) ->getMock(); - $requestMock->expects($this->once()) + $request->expects($this->once()) ->method('getDestCity') ->willReturn(null); - $this->_model->setRequest($requestMock); + $this->model->setRequest($request); } + /** + * @covers \Magento\Fedex\Model\Carrier::setRequest + */ public function testSetRequestWithCity() { - $requestMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address\RateRequest::class) + $request = $this->getMockBuilder(RateRequest::class) ->disableOriginalConstructor() ->setMethods(['getDestCity']) ->getMock(); - $requestMock->expects($this->exactly(2)) + $request->expects(static::exactly(2)) ->method('getDestCity') ->willReturn('Small Town'); - $this->_model->setRequest($requestMock); + $this->model->setRequest($request); } /** @@ -173,7 +206,7 @@ public function testSetRequestWithCity() * @param $path * @return null|string */ - public function scopeConfiggetValue($path) + public function scopeConfigGetValue($path) { switch ($path) { case 'carriers/fedex/showmethod': @@ -183,53 +216,55 @@ public function scopeConfiggetValue($path) return 'ServiceType'; break; } + return null; } /** + * @param float $amount + * @param string $rateType + * @param float $expected * @dataProvider collectRatesDataProvider */ public function testCollectRatesRateAmountOriginBased($amount, $rateType, $expected) { - $this->scope->expects($this->any())->method('isSetFlag')->will($this->returnValue(true)); + $this->scope->expects(static::any()) + ->method('isSetFlag') + ->willReturn(true); - // @codingStandardsIgnoreStart - $netAmount = new \Magento\Framework\DataObject([]); + $netAmount = new \stdClass(); $netAmount->Amount = $amount; - $totalNetCharge = new \Magento\Framework\DataObject([]); + $totalNetCharge = new \stdClass(); $totalNetCharge->TotalNetCharge = $netAmount; $totalNetCharge->RateType = $rateType; - $ratedShipmentDetail = new \Magento\Framework\DataObject([]); + $ratedShipmentDetail = new \stdClass(); $ratedShipmentDetail->ShipmentRateDetail = $totalNetCharge; - $rate = new \Magento\Framework\DataObject([]); + $rate = new \stdClass(); $rate->ServiceType = 'ServiceType'; $rate->RatedShipmentDetails = [$ratedShipmentDetail]; - $response = new \Magento\Framework\DataObject([]); + $response = new \stdClass(); $response->HighestSeverity = 'SUCCESS'; $response->RateReplyDetails = $rate; - $this->_model->expects($this->any())->method('_getCachedQuotes')->will( - $this->returnValue(serialize($response)) - ); - $request = $this->getMock( - \Magento\Quote\Model\Quote\Address\RateRequest::class, - ['getDestCity'], - [], - '', - false - ); - $request->expects($this->exactly(2)) - ->method('getDestCity') - ->willReturn('Wonderful City'); - foreach ($this->_model->collectRates($request)->getAllRates() as $allRates) { + $this->model->expects(static::any()) + ->method('_getCachedQuotes') + ->willReturn(serialize($response)); + $request = $this->getMockBuilder(RateRequest::class) + ->disableOriginalConstructor() + ->getMock(); + + foreach ($this->model->collectRates($request)->getAllRates() as $allRates) { $this->assertEquals($expected, $allRates->getData('cost')); } - // @codingStandardsIgnoreEnd } + /** + * Get list of rates variations + * @return array + */ public function collectRatesDataProvider() { return [ @@ -246,16 +281,22 @@ public function collectRatesDataProvider() public function testCollectRatesErrorMessage() { - $this->scope->expects($this->once())->method('isSetFlag')->willReturn(false); + $this->scope->expects(static::once()) + ->method('isSetFlag') + ->willReturn(false); - $this->error->expects($this->once())->method('setCarrier')->with('fedex'); - $this->error->expects($this->once())->method('setCarrierTitle'); - $this->error->expects($this->once())->method('setErrorMessage'); + $this->error->expects(static::once()) + ->method('setCarrier') + ->with('fedex'); + $this->error->expects(static::once()) + ->method('setCarrierTitle'); + $this->error->expects(static::once()) + ->method('setErrorMessage'); $request = new RateRequest(); $request->setPackageWeight(1); - $this->assertSame($this->error, $this->_model->collectRates($request)); + static::assertSame($this->error, $this->model->collectRates($request)); } /** @@ -269,11 +310,11 @@ public function testFilterDebugData($data, array $maskFields, $expected) $refClass = new \ReflectionClass(Carrier::class); $property = $refClass->getProperty('_debugReplacePrivateDataKeys'); $property->setAccessible(true); - $property->setValue($this->_model, $maskFields); + $property->setValue($this->model, $maskFields); $refMethod = $refClass->getMethod('filterDebugData'); $refMethod->setAccessible(true); - $result = $refMethod->invoke($this->_model, $data); + $result = $refMethod->invoke($this->model, $data); static::assertEquals($expected, $result); } @@ -312,4 +353,277 @@ public function logDataProvider() ], ]; } + + /** + * @covers \Magento\Fedex\Model\Carrier::getTracking + */ + public function testGetTrackingErrorResponse() + { + $tracking = '123456789012'; + $errorMessage = 'Tracking information is unavailable.'; + + $response = new \stdClass(); + $response->HighestSeverity = 'ERROR'; + $response->Notifications = new \stdClass(); + $response->Notifications->Message = $errorMessage; + + $this->model->expects(static::once()) + ->method('_getCachedQuotes') + ->willReturn(serialize($response)); + + $error = $this->helper->getObject(Error::class); + $this->trackErrorFactory->expects(static::once()) + ->method('create') + ->willReturn($error); + + $this->model->getTracking($tracking); + $tracks = $this->model->getResult()->getAllTrackings(); + + static::assertEquals(1, count($tracks)); + + /** @var Error $current */ + $current = $tracks[0]; + static::assertInstanceOf(Error::class, $current); + static::assertEquals(__($errorMessage), $current->getErrorMessage()); + } + + /** + * @covers \Magento\Fedex\Model\Carrier::getTracking + */ + public function testGetTracking() + { + $tracking = '123456789012'; + + $response = new \stdClass(); + $response->HighestSeverity = 'SUCCESS'; + $response->CompletedTrackDetails = new \stdClass(); + + $trackDetails = new \stdClass(); + $trackDetails->ShipTimestamp = '2016-08-05T14:06:35+00:00'; + $trackDetails->DeliverySignatureName = 'signature'; + + $trackDetails->StatusDetail = new \stdClass(); + $trackDetails->StatusDetail->Description = 'SUCCESS'; + + $trackDetails->Service = new \stdClass(); + $trackDetails->Service->Description = 'ground'; + $trackDetails->EstimatedDeliveryTimestamp = '2016-08-10T10:20:26+00:00'; + + $trackDetails->EstimatedDeliveryAddress = new \stdClass(); + $trackDetails->EstimatedDeliveryAddress->City = 'Culver City'; + $trackDetails->EstimatedDeliveryAddress->StateOrProvinceCode = 'CA'; + $trackDetails->EstimatedDeliveryAddress->CountryCode = 'US'; + + $trackDetails->PackageWeight = new \stdClass(); + $trackDetails->PackageWeight->Value = 23; + $trackDetails->PackageWeight->Units = 'LB'; + + $response->CompletedTrackDetails->TrackDetails = [$trackDetails]; + + $this->model->expects(static::once()) + ->method('_getCachedQuotes') + ->willReturn(serialize($response)); + + $status = $this->helper->getObject(Status::class); + $this->statusFactory->expects(static::once()) + ->method('create') + ->willReturn($status); + + $this->model->getTracking($tracking); + $tracks = $this->model->getResult()->getAllTrackings(); + static::assertEquals(1, count($tracks)); + + $current = $tracks[0]; + $fields = [ + 'signedby', + 'status', + 'service', + 'shippeddate', + 'deliverydate', + 'deliverytime', + 'deliverylocation', + 'weight', + ]; + array_walk($fields, function ($field) use ($current) { + static::assertNotEmpty($current[$field]); + }); + + static::assertEquals('2016-08-10', $current['deliverydate']); + static::assertEquals('10:20:26', $current['deliverytime']); + static::assertEquals('2016-08-05', $current['shippeddate']); + } + + /** + * @covers \Magento\Fedex\Model\Carrier::getTracking + */ + public function testGetTrackingWithEvents() + { + $tracking = '123456789012'; + + $response = new \stdClass(); + $response->HighestSeverity = 'SUCCESS'; + $response->CompletedTrackDetails = new \stdClass(); + + $event = new \stdClass(); + $event->EventDescription = 'Test'; + $event->Timestamp = '2016-08-05T19:14:53+00:00'; + $event->Address = new \stdClass(); + + $event->Address->City = 'Culver City'; + $event->Address->StateOrProvinceCode = 'CA'; + $event->Address->CountryCode = 'US'; + + $trackDetails = new \stdClass(); + $trackDetails->Events = $event; + + $response->CompletedTrackDetails->TrackDetails = $trackDetails; + + $this->model->expects(static::once()) + ->method('_getCachedQuotes') + ->willReturn(serialize($response)); + + $status = $this->helper->getObject(Status::class); + $this->statusFactory->expects(static::once()) + ->method('create') + ->willReturn($status); + + $this->model->getTracking($tracking); + $tracks = $this->model->getResult()->getAllTrackings(); + static::assertEquals(1, count($tracks)); + + $current = $tracks[0]; + static::assertNotEmpty($current['progressdetail']); + static::assertEquals(1, count($current['progressdetail'])); + + $event = $current['progressdetail'][0]; + $fields = ['activity', 'deliverydate', 'deliverytime', 'deliverylocation']; + array_walk($fields, function ($field) use ($event) { + static::assertNotEmpty($event[$field]); + }); + static::assertEquals('2016-08-05', $event['deliverydate']); + static::assertEquals('19:14:53', $event['deliverytime']); + } + + /** + * Init RateErrorFactory and RateResultErrors mocks + * @return void + */ + private function initRateErrorFactory() + { + $this->error = $this->getMockBuilder(RateResultError::class) + ->disableOriginalConstructor() + ->setMethods(['setCarrier', 'setCarrierTitle', 'setErrorMessage']) + ->getMock(); + $this->errorFactory = $this->getMockBuilder(RateErrorFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->errorFactory->expects(static::any()) + ->method('create') + ->willReturn($this->error); + } + + /** + * Creates mock rate result factory + * @return RateResultFactory|MockObject + */ + private function getRateFactory() + { + $rate = $this->getMockBuilder(RateResult::class) + ->disableOriginalConstructor() + ->setMethods(['getError']) + ->getMock(); + $rateFactory = $this->getMockBuilder(RateResultFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $rateFactory->expects(static::any()) + ->method('create') + ->willReturn($rate); + + return $rateFactory; + } + + /** + * Creates mock object for CountryFactory class + * @return CountryFactory|MockObject + */ + private function getCountryFactory() + { + $country = $this->getMockBuilder(Country::class) + ->disableOriginalConstructor() + ->setMethods(['load', 'getData']) + ->getMock(); + $country->expects(static::any()) + ->method('load') + ->willReturnSelf(); + + $countryFactory = $this->getMockBuilder(CountryFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $countryFactory->expects(static::any()) + ->method('create') + ->willReturn($country); + + return $countryFactory; + } + + /** + * Creates mock object for ResultFactory class + * @return ResultFactory|MockObject + */ + private function getResultFactory() + { + $resultFactory = $this->getMockBuilder(ResultFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->result = $this->helper->getObject(Result::class); + $resultFactory->expects(static::any()) + ->method('create') + ->willReturn($this->result); + + return $resultFactory; + } + + /** + * Creates mock object for store manager + * @return StoreManagerInterface|MockObject + */ + private function getStoreManager() + { + $store = $this->getMockBuilder(Store::class) + ->disableOriginalConstructor() + ->setMethods(['getBaseCurrencyCode']) + ->getMock(); + $storeManager = $this->getMock(StoreManagerInterface::class); + $storeManager->expects(static::any()) + ->method('getStore') + ->willReturn($store); + + return $storeManager; + } + + /** + * Creates mock object for rate method factory + * @return MethodFactory|MockObject + */ + private function getRateMethodFactory() + { + $priceCurrency = $this->getMock(PriceCurrencyInterface::class); + $rateMethod = $this->getMockBuilder(Method::class) + ->setConstructorArgs(['priceCurrency' => $priceCurrency]) + ->setMethods(null) + ->getMock(); + $rateMethodFactory = $this->getMockBuilder(MethodFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $rateMethodFactory->expects(static::any()) + ->method('create') + ->willReturn($rateMethod); + + return $rateMethodFactory; + } } diff --git a/app/code/Magento/Fedex/etc/wsdl/TrackService_v5.wsdl b/app/code/Magento/Fedex/etc/wsdl/TrackService_v10.wsdl similarity index 63% rename from app/code/Magento/Fedex/etc/wsdl/TrackService_v5.wsdl rename to app/code/Magento/Fedex/etc/wsdl/TrackService_v10.wsdl index f3ceaf5056a20..3771c1e697888 100644 --- a/app/code/Magento/Fedex/etc/wsdl/TrackService_v5.wsdl +++ b/app/code/Magento/Fedex/etc/wsdl/TrackService_v10.wsdl @@ -1,12 +1,12 @@ - + - + + + - - @@ -14,7 +14,7 @@ Descriptive data for a physical location. May be used as an actual physical address (place to which one could go), or as a container of "address parts" which should be handled as a unit (such as a city-state-ZIP combination within the US). - + Combination of number, street name, etc. At least one line is required for a valid physical address; empty lines should not be included. @@ -44,6 +44,11 @@ The two-letter code used to identify a country. + + + The fully spelt out name of a country. + + Indicates whether this address residential (as opposed to commercial). @@ -51,6 +56,48 @@ + + + Specifies the different appointment times on a specific date. + + + + + + Different appointment time windows on the date specified. + + + + + + + Specifies the details about the appointment time window. + + + + + The description that FedEx Ground uses for the appointment window being specified. + + + + + Specifies the window of time for an appointment. + + + + + + + + The description that FedEx uses for a given appointment window. + + + + + + + + Identifies where a tracking event occurs. @@ -73,11 +120,18 @@ + + + + + + + Identification of a FedEx operating company (transportation). @@ -108,7 +162,7 @@ - Only used in transactions which require identification of the Fed Ex Office integrator. + Only used in transactions which require identification of the FedEx Office integrator. @@ -118,6 +172,79 @@ + + + + + Value used to identify a commodity description; must be unique within the containing shipment. + + + + + + + + + + + This field is used for enterprise transactions. + + + + + + Contains only additional quantitative information other than weight and quantity to calculate duties and taxes. + + + + + + + Defines additional characteristic of commodity used to calculate duties and taxes + + + + + + + + + All data required for this commodity in NAFTA Certificate of Origin. + + + + + + + + + + + True if duplicate packages (more than one package with the same tracking number) have been found, and only limited data will be provided for each one. + + + + + True if additional packages remain to be retrieved. + + + + + Value that must be passed in a TrackNotification request to retrieve the next set of packages (when MoreDataAvailable = true). + + + + + Identifies the total number of available track details across all pages. + + + + + Contains detailed tracking information for the requested packages(s). + + + + The descriptive data for a point-of-contact person. @@ -148,6 +275,11 @@ Identifies the phone extension associated with this contact. + + + Identifies a toll free number, if any, associated with this contact. + + Identifies the pager number associated with this contact. @@ -171,6 +303,84 @@ + + + + + + + + + + + + + Unique identifier for the customer exception request. + + + + + + + + + + + + + Specifies additional description about customs options. This is a required field when the customs options type is "OTHER". + + + + + + + + + + + + + + + + + + + + + + + + + + + Details about the eligibility for a delivery option. + + + + + Type of delivery option. + + + + + Eligibility of the customer for the specific delivery option. + + + + + + + Specifies the different option types for delivery. + + + + + + + + The dimensions of this package and the unit type used for the measurements. @@ -280,6 +490,43 @@ + + + + + + Customer-declared value, with data type and legal values depending on excise condition, used in defining the taxable value of the item. + + + + + + + Specifies different values of eligibility status + + + + + + + + + + Identifies a kind of FedEx facility. + + + + + + + + + + + + + + CM = centimeters, IN = inches @@ -289,6 +536,15 @@ + + + Time Range specified in local time. + + + + + + Identifies the representation of human-readable text. @@ -306,6 +562,73 @@ + + + + + + + + + + + + + + + + + Defined by NAFTA regulations. + + + + + Defined by NAFTA regulations. + + + + + Identification of which producer is associated with this commodity (if multiple producers are used in a single shipment). + + + + + + Date range over which RVC net cost was calculated. + + + + + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + The descriptive data regarding the result of the submitted transaction. @@ -382,7 +705,18 @@ Identification for a FedEx operating company (transportation and non-transportation). + + + + + + + + + + + @@ -394,11 +728,42 @@ + + + + + + + + + When the MoreData field = true in a TrackReply the PagingToken must be sent in the subsequent TrackRequest to retrieve the next page of data. + + + + + Specifies the number of results to display per page when the there is more than one page in the subsequent TrackReply. + + + + + + + + + + + + + + + + + Tracking number and additional shipment data used to identify a unique shipment for proof of delivery. @@ -431,13 +796,115 @@ - - - - - - - + + + + + This contains the severity type of the most severe Notification in the Notifications array. + + + + + Information about the request/reply such was the transaction successful or not, and any additional information relevant to the request and/or reply. There may be multiple Notifications in a reply. + + + + + Contains the CustomerTransactionDetail that is echoed back to the caller for matching requests and replies and a Localization element for defining the language/translation used in the reply data. + + + + + Contains the version of the reply being used. + + + + + True if duplicate packages (more than one package with the same tracking number) have been found, the packages array contains information about each duplicate. Use this information to determine which of the tracking numbers is the one you need and resend your request using the tracking number and TrackingNumberUniqueIdentifier for that package. + + + + + True if additional packages remain to be retrieved. + + + + + Value that must be passed in a TrackNotification request to retrieve the next set of packages (when MoreDataAvailable = true). + + + + + Information about the notifications that are available for this tracking number. If there are duplicates the ship date and destination address information is returned for determining which TrackingNumberUniqueIdentifier to use on a subsequent request. + + + + + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Contains a free form field that is echoed back in the reply to match requests with replies and data that governs the data payload language/translations + + + + + + The tracking number to which the notifications will be triggered from. + + + + + Indicates whether to return tracking information for all associated packages. + + + + + When the MoreDataAvailable field is true in a TrackNotificationReply the PagingToken must be sent in the subsequent TrackNotificationRequest to retrieve the next page of data. + + + + + Use this field when your original request informs you that there are duplicates of this tracking number. If you get duplicates you will also receive some information about each of the duplicate tracking numbers to enable you to chose one and resend that number along with the TrackingNumberUniqueId to get notifications for that tracking number. + + + + + To narrow the search to a period in time the ShipDateRangeBegin and ShipDateRangeEnd can be used to help eliminate duplicates. + + + + + To narrow the search to a period in time the ShipDateRangeBegin and ShipDateRangeEnd can be used to help eliminate duplicates. + + + + + Included in the email notification identifying the requester of this notification. + + + + + Included in the email notification identifying the requester of this notification. + + + + + Who to send the email notifications to and for which events. The notificationRecipientType and NotifyOnShipment fields are not used in this request. + + + + The service type of the package/shipment. @@ -449,11 +916,34 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -465,10 +955,19 @@ + + + + + + + + + FedEx Signature Proof Of Delivery Fax reply. @@ -554,6 +1053,7 @@ + @@ -635,6 +1135,32 @@ + + + + + Specifies the status of the track special instructions requested. + + + + + Time when the status was changed. + + + + + + + + + + + + + + + + Each instance of this data type represents a barcode whose content must be represented as ASCII text (i.e. not binary data). @@ -662,22 +1188,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + The delivery location at the delivered to address. + + + + + + + + + + + + + + + + Detailed tracking information about a particular package. @@ -699,16 +1267,12 @@ When duplicate tracking numbers exist this data is returned with summary information for each of the duplicates. The summary information is used to determine which of the duplicates the intended tracking number is. This identifier is used on a subsequent track request to retrieve the tracking data for the desired tracking number. - + - A code that identifies this type of status. This is the most recent status. - - - - - A human-readable description of this status. + Specifies details about the status of the shipment being tracked. + Used to report the status of a piece of a multiple piece shipment which is no longer traveling with the rest of the packages in the shipment or has not been accounted for. @@ -719,6 +1283,8 @@ Used to convey information such as. 1. FedEx has received information about a package but has not yet taken possession of it. 2. FedEx has handed the package off to a third party for final delivery. 3. The package delivery has been cancelled + + Identifies a FedEx operating company (transportation). @@ -729,24 +1295,34 @@ Identifies operating transportation company that is the specific to the carrier code. + + + Specifies a detailed description about the carrier or the operating company. + + + + + If the package was interlined to a cartage agent, this is the name of the cartage agent. (Returned for CSR SL only.) + + Specifies the FXO production centre contact and address. - + Other related identifiers for this package such as reference numbers. - + - Retained for legacy compatibility only. User/screen friendly description of the Service type (e.g. Priority Overnight). + (Returned for CSR SL only.) - + - Strict representation of the Service type (e.g. PRIORITY_OVERNIGHT). + Specifies details about service such as service description and type. @@ -789,8 +1365,40 @@ The number of packages in this shipment. - - + + + Specifies the details about the SPOC details. + + + + + + + + + + + + + Specifies the reason for return. + + + + + + List of special handlings that applied to this package. (Returned for CSR SL only.) + + + + + (Returned for CSR SL only.) + + + + + Indicates last-known possession of package (Returned for CSR SL only.) + + The address information for the shipper. @@ -801,6 +1409,11 @@ The address of the FedEx pickup location/facility. + + + (Returned for CSR SL only.) + + Estimated package pickup time for shipments that haven't been picked up. @@ -821,16 +1434,54 @@ Total distance package still has to travel. Returned for Custom Critical shipments. + + + Provides additional details about package delivery. + + + + + (Returned for CSR SL only.) + + + + + This is the latest updated destination address. + + The address this package is to be (or has been) delivered. + + + + The address this package is requested to placed on hold. + + + + + (Returned for CSR SL only.) + + The address of the FedEx delivery location/facility. + + + + + Date and time the package should be (or should have been) delivered. (Returned for CSR SL only.) + + + + + Date and time the package would be delivered if the package has appointment delivery as a special service. + + Projected package delivery time based on ship time stamp, service and destination. Not populated if delivery has already occurred. @@ -861,16 +1512,28 @@ User/screen friendly representation of the DeliveryLocationType (delivery location at the delivered to address). Can be returned in localized text. + + + Specifies the number of delivery attempts made to deliver the shipment. + + This is either the name of the person that signed for the package or "Signature not requested" or "Signature on file". - + - True if signed for by signature image is available. + Specifies the details about the count of the packages delivered at the delivery location and the count of the packages at the origin. + + + Specifies the total number of unique addresses on the CRNs in a consolidation. + + + + The types of email notifications that are available for the package. @@ -881,9 +1544,9 @@ Returned for cargo shipments only when they are currently split across vehicles. - + - Indicates redirection eligibility as determined by tracking service, subject to refinement/override by redirect-to-hold service. + Specifies the details about the eligibility for different delivery options. @@ -893,6 +1556,11 @@ + + + + + FedEx scanning information about a package. @@ -928,6 +1596,11 @@ Address information of the station that is responsible for the scan. + + + FedEx location ID where the scan took place. (Returned for CSR SL only.) + + Indicates where the arrival actually occurred. @@ -945,6 +1618,7 @@ + @@ -953,9 +1627,11 @@ + + @@ -1010,123 +1686,11 @@ - - - FedEx Track Notification reply. - - - - - This contains the severity type of the most severe Notification in the Notifications array. - - - - - Information about the request/reply such was the transaction successful or not, and any additional information relevant to the request and/or reply. There may be multiple Notifications in a reply. - - - - - Contains the CustomerTransactionDetail that is echoed back to the caller for matching requests and replies and a Localization element for defining the language/translation used in the reply data. - - - - - Contains the version of the reply being used. - - - - - True if duplicate packages (more than one package with the same tracking number) have been found, the packages array contains information about each duplicate. Use this information to determine which of the tracking numbers is the one you need and resend your request using the tracking number and TrackingNumberUniqueIdentifier for that package. - - - - - True if additional packages remain to be retrieved. - - - - - Value that must be passed in a TrackNotification request to retrieve the next set of packages (when MoreDataAvailable = true). - - - - - Information about the notifications that are available for this tracking number. If there are duplicates the ship date and destination address information is returned for determining which TrackingNumberUniqueIdentifier to use on a subsequent request. - - - - - - - FedEx Track Notification request. - + - - - Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). - - - - - Descriptive data identifying the client submitting the transaction. - - - - - Contains a free form field that is echoed back in the reply to match requests with replies and data that governs the data payload language/translations - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - The tracking number to which the notifications will be triggered from. - - - - - Indicates whether to return tracking information for all associated packages. - - - - - When the MoreDataAvailable field is true in a TrackNotificationReply the PagingToken must be sent in the subsequent TrackNotificationRequest to retrieve the next page of data. - - - - - Use this field when your original request informs you that there are duplicates of this tracking number. If you get duplicates you will also receive some information about each of the duplicate tracking numbers to enable you to chose one and resend that number along with the TrackingNumberUniqueId to get notifications for that tracking number. - - - - - To narrow the search to a period in time the ShipDateRangeBegin and ShipDateRangeEnd can be used to help eliminate duplicates. - - - - - To narrow the search to a period in time the ShipDateRangeBegin and ShipDateRangeEnd can be used to help eliminate duplicates. - - - - - Included in the email notification identifying the requester of this notification. - - - - - Included in the email notification identifying the requester of this notification. - - - - - Who to send the email notifications to and for which events. The notificationRecipientType and NotifyOnShipment fields are not used in this request. - - + + + @@ -1134,18 +1698,41 @@ The type and value of the package identifier that is to be used to retrieve the tracking information for a package. - + - The value to be used to retrieve tracking information for a package. + The type of the Value to be used to retrieve tracking information for a package (e.g. SHIPPER_REFERENCE, PURCHASE_ORDER, TRACKING_NUMBER_OR_DOORTAG, etc..) . - + - The type of the Value to be used to retrieve tracking information for a package (e.g. SHIPPER_REFERENCE, PURCHASE_ORDER, TRACKING_NUMBER_OR_DOORTAG, etc..) . + The value to be used to retrieve tracking information for a package. + + + + + + + + + + + + + + + + + + + + + + + Used to report the status of a piece of a multiple piece shipment which is no longer traveling with the rest of the packages in the shipment or has not been accounted for. @@ -1188,24 +1775,9 @@ Contains the version of the reply being used. - - - True if duplicate packages (more than one package with the same tracking number) have been found, and only limited data will be provided for each one. - - - - - True if additional packages remain to be retrieved. - - - - - Value that must be passed in a TrackNotification request to retrieve the next set of packages (when MoreDataAvailable = true). - - - + - Contains detailed tracking information for the requested packages(s). + Contains detailed tracking entity information. @@ -1235,6 +1807,46 @@ The version of the request being used. + + + Specifies the details needed to select the shipment being requested to be tracked. + + + + + The customer can specify a desired time out value for this particular transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The FedEx operating company (transportation) used for this package's delivery. @@ -1245,7 +1857,7 @@ Identifies operating transportation company that is the specific to the carrier code. - + The type and value of the package identifier that is to be used to retrieve the tracking information for a package or group of packages. @@ -1270,29 +1882,181 @@ For tracking by references information either the account number or destination postal code and country must be provided. + + + Specifies the SPOD account number for the shipment being tracked. + + For tracking by references information either the account number or destination postal code and country must be provided. - + - If false the reply will contain summary/profile data including current status. If true the reply contains profile + detailed scan activity for each package. + Specifies the details about how to retrieve the subsequent pages when there is more than one page in the TrackReply. - + - When the MoreData field = true in a TrackReply the PagingToken must be sent in the subsequent TrackRequest to retrieve the next page of data. + The customer can specify a desired time out value for this particular tracking number. - + + + + + + + Specifies a shorter description for the service that is calculated per the service code. + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Specifies the status and status update time of the track special instructions. + + + + + Specifies the estimated delivery time that was originally estimated when the shipment was shipped. + + + + + Specifies the time the customer requested a change to the shipment. + + + + + The requested appointment time for delivery. + + + + Used when a cargo shipment is split across vehicles. This is used to give the status of each part of the shipment. @@ -1320,6 +2084,26 @@ + + + + + + + + + + + Specifies the details about the status of the track information for the shipments being tracked. + + + + + + + + + Descriptive data that governs data payload language/translations. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. @@ -1368,6 +2152,11 @@ Used in authentication of the sender's identity. + + + This was renamed from cspCredential. + + Credential used to authenticate a specific software application. This value is provided by FedEx after registration. @@ -1402,7 +2191,7 @@ Identifies a system or sub-system which performs an operation. - + Identifies the service business level. @@ -1421,6 +2210,9 @@ + + + @@ -1433,11 +2225,8 @@ - - - - - + + @@ -1446,10 +2235,6 @@ - - - - @@ -1462,11 +2247,15 @@ + + + + - - + + @@ -1474,8 +2263,8 @@ - - + + @@ -1483,8 +2272,8 @@ - - + + @@ -1492,8 +2281,8 @@ - - + + @@ -1504,7 +2293,7 @@ - + - + \ No newline at end of file diff --git a/app/code/Magento/Shipping/view/frontend/templates/tracking/details.phtml b/app/code/Magento/Shipping/view/frontend/templates/tracking/details.phtml new file mode 100644 index 0000000000000..0d84c56599cd2 --- /dev/null +++ b/app/code/Magento/Shipping/view/frontend/templates/tracking/details.phtml @@ -0,0 +1,95 @@ +getData('track'); +$email = $block->getData('storeSupportEmail'); +$fields = [ + 'Status' => 'getStatus', + 'Signed by' => 'getSignedby', + 'Delivered to' => 'getDeliveryLocation', + 'Shipped or billed on' => 'getShippedDate', + 'Service Type' => 'getService', + 'Weight' => 'getWeight', +]; +?> + + + + + + + + + getCarrierTitle()): ?> + + + + + + getErrorMessage()): ?> + + + + + getTrackSummary()): ?> + + + + + getUrl()): ?> + + + + + + $property): ?> + $property())): ?> + + + + + + + + getDeliverydate()): ?> + + + + + + + + + + + + + + +
escapeHtml(__('Order tracking')); ?>
escapeHtml(__('Tracking Number:')); ?>escapeHtml($track->getTracking()); ?>
escapeHtml(__('Carrier:')); ?>escapeHtml($track->getCarrierTitle()); ?>
escapeHtml(__('Error:')); ?> + escapeHtml(__('Tracking information is currently not available. Please ')); ?> + getContactUsEnabled()) : ?> + + escapeHtml(__('contact us')); ?> + + escapeHtml(__(' for more information or ')); ?> + + escapeHtml(__('email us at ')); ?> + +
escapeHtml(__('Info:')); ?>escapeHtml($track->getTrackSummary()); ?>
escapeHtml(__('Track:')); ?> + + escapeUrl($track->getUrl()); ?> + +
escapeHtml(__($title . ':')); ?>escapeHtml($track->$property()); ?>
escapeHtml(__('Delivered on:')); ?> + formatDeliveryDateTime($track->getDeliverydate(), $track->getDeliverytime()); ?> +
+ escapeHtml($track['title']) : $block->escapeHtml(__('N/A'))); ?>: + escapeHtml($track['number']) : ''); ?>
diff --git a/app/code/Magento/Shipping/view/frontend/templates/tracking/popup.phtml b/app/code/Magento/Shipping/view/frontend/templates/tracking/popup.phtml index e9bb00df8b852..c0f9ab3ab8528 100644 --- a/app/code/Magento/Shipping/view/frontend/templates/tracking/popup.phtml +++ b/app/code/Magento/Shipping/view/frontend/templates/tracking/popup.phtml @@ -4,156 +4,60 @@ * See COPYING.txt for license details. */ +use Magento\Framework\View\Element\Template; + // @codingStandardsIgnoreFile +/** @var $block \Magento\Shipping\Block\Tracking\Popup */ + +$results = $block->getTrackingInfo(); ?> - -getTrackingInfo(); ?>
- 0): ?> - $_result): ?> - -
- - 0): ?> - - -
- - - - - - - - - getCarrierTitle()): ?> - - - - - - getErrorMessage()): ?> - - - - - getTrackSummary()): ?> - - - - - getUrl()): ?> - - - - - - getStatus()): ?> - - - - - - - getDeliverydate()): ?> - - - - - - - getSignedby()): ?> - - - - - - - getDeliveryLocation()): ?> - - - - - - - getShippedDate()): ?> - - - - - - - getService()): ?> - - - - - - - getWeight()): ?> - - - - - - - - - - - - - - -
escapeHtml($track->getTracking()); ?>
escapeHtml($track->getCarrierTitle()); ?>
getContactUsEnabled()) : ?>getStoreSupportEmail() ?>
getTrackSummary(); ?>
escapeHtml($track->getUrl()); ?>
getStatus(); ?>
formatDeliveryDateTime($track->getDeliverydate(), $track->getDeliverytime()); ?>
getSignedby(); ?>
getDeliveryLocation(); ?>
getShippedDate(); ?>
getService(); ?>
getWeight(); ?>
escapeHtml($track['title']) : __('N/A')); ?>:escapeHtml($track['number']) : ''); ?>
-
- getProgressdetail())>0): ?> + + $result): ?> + +
escapeHtml(__('Shipment #')) . $shipId; ?>
+ + + $track): ?>
- - - - - - - - - - - - getProgressdetail() as $_detail): ?> - formatDeliveryDate($_detail['deliverydate']) : '') ?> - formatDeliveryTime($_detail['deliverytime'], $_detail['deliverydate']) : '') ?> - - - - - - - - -
+ addChild('shipping.tracking.details.' . $counter, Template::class, [ + 'track' => $track, + 'template' => 'Magento_Shipping::tracking/details.phtml', + 'storeSupportEmail' => $block->getStoreSupportEmail() + ] + ); + ?> + getChildHtml('shipping.tracking.details.' . $counter); ?>
- - - - - - - -
- - - + getProgressdetail())): ?> + addChild('shipping.tracking.progress.'. $counter, Template::class, [ + 'track' => $track, + 'template' => 'Magento_Shipping::tracking/progress.phtml' + ]); + ?> + getChildHtml('shipping.tracking.progress.' . $counter); ?> + + + +
+
escapeHtml(__('There is no tracking available for this shipment.')); ?>
+
+ + -
+
+
escapeHtml(__('There is no tracking available.')); ?>
+
diff --git a/app/code/Magento/Shipping/view/frontend/templates/tracking/progress.phtml b/app/code/Magento/Shipping/view/frontend/templates/tracking/progress.phtml new file mode 100644 index 0000000000000..d5ce13a277f8b --- /dev/null +++ b/app/code/Magento/Shipping/view/frontend/templates/tracking/progress.phtml @@ -0,0 +1,43 @@ +getData('track'); +?> +
+ + + + + + + + + + + + getProgressdetail() as $detail): ?> + formatDeliveryDate($detail['deliverydate']) : ''); ?> + formatDeliveryTime($detail['deliverytime'], $detail['deliverydate']) : ''); ?> + + + + + + + + +
escapeHtml(__('Track history')); ?>
escapeHtml(__('Location')); ?>escapeHtml(__('Date')); ?>escapeHtml(__('Local Time')); ?>escapeHtml(__('Description')); ?>
+ escapeHtml($detail['deliverylocation']) : ''); ?> + + + + + escapeHtml($detail['activity']) : ''); ?> +
+
\ No newline at end of file From e8c3f113dd84342b212280ffc2a44b98bf3c2683 Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Mon, 8 Aug 2016 11:05:38 +0300 Subject: [PATCH 05/18] MAGETWO-55953: Exception occurs when tracking shipment with invalid FedEx tracking number - Fixed failed static tests --- app/code/Magento/Fedex/Model/Carrier.php | 3 +++ app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php | 4 ++++ .../Shipping/view/frontend/templates/tracking/details.phtml | 2 +- .../Shipping/view/frontend/templates/tracking/popup.phtml | 6 +++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index b3ffabf74dac3..753388dc17bed 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -1550,8 +1550,11 @@ protected function filterDebugData($data) } /** + * Parse track details response from Fedex * @param \stdClass $trackInfo * @return array + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ private function processTrackingDetails(\stdClass $trackInfo) { diff --git a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php index 4a54993508c67..612b0b3d6a6cd 100644 --- a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php @@ -224,6 +224,7 @@ public function scopeConfigGetValue($path) * @param string $rateType * @param float $expected * @dataProvider collectRatesDataProvider + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function testCollectRatesRateAmountOriginBased($amount, $rateType, $expected) { @@ -356,6 +357,7 @@ public function logDataProvider() /** * @covers \Magento\Fedex\Model\Carrier::getTracking + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function testGetTrackingErrorResponse() { @@ -389,6 +391,7 @@ public function testGetTrackingErrorResponse() /** * @covers \Magento\Fedex\Model\Carrier::getTracking + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function testGetTracking() { @@ -455,6 +458,7 @@ public function testGetTracking() /** * @covers \Magento\Fedex\Model\Carrier::getTracking + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function testGetTrackingWithEvents() { diff --git a/app/code/Magento/Shipping/view/frontend/templates/tracking/details.phtml b/app/code/Magento/Shipping/view/frontend/templates/tracking/details.phtml index 0d84c56599cd2..d655d96e1dd36 100644 --- a/app/code/Magento/Shipping/view/frontend/templates/tracking/details.phtml +++ b/app/code/Magento/Shipping/view/frontend/templates/tracking/details.phtml @@ -67,7 +67,7 @@ $fields = [ $property): ?> $property())): ?> - escapeHtml(__($title . ':')); ?> + escapeHtml(__($title . ':')); ?> escapeHtml($track->$property()); ?> diff --git a/app/code/Magento/Shipping/view/frontend/templates/tracking/popup.phtml b/app/code/Magento/Shipping/view/frontend/templates/tracking/popup.phtml index c0f9ab3ab8528..412cb4b411a98 100644 --- a/app/code/Magento/Shipping/view/frontend/templates/tracking/popup.phtml +++ b/app/code/Magento/Shipping/view/frontend/templates/tracking/popup.phtml @@ -16,7 +16,7 @@ $results = $block->getTrackingInfo(); $result): ?> -
escapeHtml(__('Shipment #')) . $shipId; ?>
+
escapeHtml(__('Shipment #')) . $shipId; ?>
$track): ?> @@ -29,7 +29,7 @@ $results = $block->getTrackingInfo(); ] ); ?> - getChildHtml('shipping.tracking.details.' . $counter); ?> + getChildHtml('shipping.tracking.details.' . $counter); ?> getProgressdetail())): ?> getTrackingInfo(); 'template' => 'Magento_Shipping::tracking/progress.phtml' ]); ?> - getChildHtml('shipping.tracking.progress.' . $counter); ?> + getChildHtml('shipping.tracking.progress.' . $counter); ?> From ea1fae35d638826d3b1b4362273624f288016fa8 Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Mon, 8 Aug 2016 11:34:48 +0300 Subject: [PATCH 06/18] MAGETWO-55953: Exception occurs when tracking shipment with invalid FedEx tracking number - Changed controversial rule for suppress warning annotation --- app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php index 612b0b3d6a6cd..a042e1e28091c 100644 --- a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php @@ -224,7 +224,7 @@ public function scopeConfigGetValue($path) * @param string $rateType * @param float $expected * @dataProvider collectRatesDataProvider - * @SuppressWarnings(PHPMD.CamelCaseVariableName) + * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ public function testCollectRatesRateAmountOriginBased($amount, $rateType, $expected) { @@ -357,7 +357,7 @@ public function logDataProvider() /** * @covers \Magento\Fedex\Model\Carrier::getTracking - * @SuppressWarnings(PHPMD.CamelCaseVariableName) + * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ public function testGetTrackingErrorResponse() { @@ -391,7 +391,7 @@ public function testGetTrackingErrorResponse() /** * @covers \Magento\Fedex\Model\Carrier::getTracking - * @SuppressWarnings(PHPMD.CamelCaseVariableName) + * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ public function testGetTracking() { @@ -458,7 +458,7 @@ public function testGetTracking() /** * @covers \Magento\Fedex\Model\Carrier::getTracking - * @SuppressWarnings(PHPMD.CamelCaseVariableName) + * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ public function testGetTrackingWithEvents() { From 92c29730de5eb73df8980c1b42cc956a09be7e27 Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Mon, 8 Aug 2016 11:51:59 +0300 Subject: [PATCH 07/18] MAGETWO-55953: Exception occurs when tracking shipment with invalid FedEx tracking number - Added code ignore annotations --- .../Magento/Fedex/Test/Unit/Model/CarrierTest.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php index a042e1e28091c..385ddf8414832 100644 --- a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php @@ -224,7 +224,6 @@ public function scopeConfigGetValue($path) * @param string $rateType * @param float $expected * @dataProvider collectRatesDataProvider - * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ public function testCollectRatesRateAmountOriginBased($amount, $rateType, $expected) { @@ -232,6 +231,7 @@ public function testCollectRatesRateAmountOriginBased($amount, $rateType, $expec ->method('isSetFlag') ->willReturn(true); + // @codingStandardsIgnoreStart $netAmount = new \stdClass(); $netAmount->Amount = $amount; @@ -249,6 +249,7 @@ public function testCollectRatesRateAmountOriginBased($amount, $rateType, $expec $response = new \stdClass(); $response->HighestSeverity = 'SUCCESS'; $response->RateReplyDetails = $rate; + // @codingStandardsIgnoreEnd $this->model->expects(static::any()) ->method('_getCachedQuotes') @@ -357,17 +358,18 @@ public function logDataProvider() /** * @covers \Magento\Fedex\Model\Carrier::getTracking - * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ public function testGetTrackingErrorResponse() { $tracking = '123456789012'; $errorMessage = 'Tracking information is unavailable.'; + // @codingStandardsIgnoreStart $response = new \stdClass(); $response->HighestSeverity = 'ERROR'; $response->Notifications = new \stdClass(); $response->Notifications->Message = $errorMessage; + // @codingStandardsIgnoreEnd $this->model->expects(static::once()) ->method('_getCachedQuotes') @@ -391,12 +393,12 @@ public function testGetTrackingErrorResponse() /** * @covers \Magento\Fedex\Model\Carrier::getTracking - * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ public function testGetTracking() { $tracking = '123456789012'; + // @codingStandardsIgnoreStart $response = new \stdClass(); $response->HighestSeverity = 'SUCCESS'; $response->CompletedTrackDetails = new \stdClass(); @@ -422,6 +424,7 @@ public function testGetTracking() $trackDetails->PackageWeight->Units = 'LB'; $response->CompletedTrackDetails->TrackDetails = [$trackDetails]; + // @codingStandardsIgnoreEnd $this->model->expects(static::once()) ->method('_getCachedQuotes') @@ -458,12 +461,12 @@ public function testGetTracking() /** * @covers \Magento\Fedex\Model\Carrier::getTracking - * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ public function testGetTrackingWithEvents() { $tracking = '123456789012'; + // @codingStandardsIgnoreStart $response = new \stdClass(); $response->HighestSeverity = 'SUCCESS'; $response->CompletedTrackDetails = new \stdClass(); @@ -481,6 +484,7 @@ public function testGetTrackingWithEvents() $trackDetails->Events = $event; $response->CompletedTrackDetails->TrackDetails = $trackDetails; + // @codingStandardsIgnoreEnd $this->model->expects(static::once()) ->method('_getCachedQuotes') From 88f80fd405d5cc81df668b8828d1943280e2f00b Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Mon, 8 Aug 2016 16:54:04 +0300 Subject: [PATCH 08/18] MAGETWO-56115: [Github] #5857 Impossible to configure custom availability gateway validator - Added check for payment info instance availability --- .../Magento/Payment/Model/Method/Adapter.php | 19 +-- .../Test/Unit/Model/Method/AdapterTest.php | 114 ++++++++++-------- 2 files changed, 73 insertions(+), 60 deletions(-) diff --git a/app/code/Magento/Payment/Model/Method/Adapter.php b/app/code/Magento/Payment/Model/Method/Adapter.php index 1d693e11fe51f..07a4dcdef5f3c 100644 --- a/app/code/Magento/Payment/Model/Method/Adapter.php +++ b/app/code/Magento/Payment/Model/Method/Adapter.php @@ -268,14 +268,17 @@ public function isAvailable(CartInterface $quote = null) $checkResult = new DataObject(); $checkResult->setData('is_available', true); try { - $validator = $this->getValidatorPool()->get('availability'); - $result = $validator->validate( - [ - 'payment' => $this->paymentDataObjectFactory->create($this->getInfoInstance()) - ] - ); - - $checkResult->setData('is_available', $result->isValid()); + $infoInstance = $this->getInfoInstance(); + if ($infoInstance !== null) { + $validator = $this->getValidatorPool()->get('availability'); + $result = $validator->validate( + [ + 'payment' => $this->paymentDataObjectFactory->create($infoInstance) + ] + ); + + $checkResult->setData('is_available', $result->isValid()); + } } catch (\Exception $e) { // pass } diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php index b5229b57875f0..d8fefb7345e0f 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php @@ -13,9 +13,12 @@ use Magento\Payment\Gateway\Config\ValueHandlerPoolInterface; use Magento\Payment\Gateway\Data\PaymentDataObjectFactory; use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; +use Magento\Payment\Gateway\Validator\ResultInterface; +use Magento\Payment\Gateway\Validator\ValidatorInterface; use Magento\Payment\Gateway\Validator\ValidatorPoolInterface; use Magento\Payment\Model\InfoInterface; use Magento\Payment\Model\Method\Adapter; +use PHPUnit_Framework_MockObject_MockObject as MockObject; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -23,27 +26,27 @@ class AdapterTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject | ManagerInterface + * @var MockObject|ManagerInterface */ private $eventManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject | ValueHandlerPoolInterface + * @var MockObject|ValueHandlerPoolInterface */ private $valueHandlerPool; /** - * @var \PHPUnit_Framework_MockObject_MockObject | ValidatorPoolInterface + * @var MockObject|ValidatorPoolInterface */ private $validatorPool; /** - * @var \PHPUnit_Framework_MockObject_MockObject | CommandPoolInterface + * @var MockObject|CommandPoolInterface */ private $commandPool; /** - * @var \PHPUnit_Framework_MockObject_MockObject | PaymentDataObjectFactory + * @var MockObject|PaymentDataObjectFactory */ private $paymentDataObjectFactory; @@ -69,21 +72,11 @@ class AdapterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eventManager = $this->getMock( - \Magento\Framework\Event\ManagerInterface::class - ); - $this->valueHandlerPool = $this->getMock( - \Magento\Payment\Gateway\Config\ValueHandlerPoolInterface::class - ); - $this->validatorPool = $this->getMock( - \Magento\Payment\Gateway\Validator\ValidatorPoolInterface::class - ); - $this->commandPool = $this->getMock( - \Magento\Payment\Gateway\Command\CommandPoolInterface::class - ); - $this->paymentDataObjectFactory = $this->getMockBuilder( - \Magento\Payment\Gateway\Data\PaymentDataObjectFactory::class - ) + $this->eventManager = $this->getMock(ManagerInterface::class); + $this->valueHandlerPool = $this->getMock(ValueHandlerPoolInterface::class); + $this->validatorPool = $this->getMock(ValidatorPoolInterface::class); + $this->commandPool = $this->getMock(CommandPoolInterface::class); + $this->paymentDataObjectFactory = $this->getMockBuilder(PaymentDataObjectFactory::class) ->disableOriginalConstructor() ->getMock(); @@ -103,11 +96,12 @@ protected function setUp() ); } + /** + * @covers \Magento\Payment\Model\Method\Adapter::isAvailable + */ public function testIsAvailableNotActive() { - $activeValueHandler = $this->getMock( - \Magento\Payment\Gateway\Config\ValueHandlerInterface::class - ); + $activeValueHandler = $this->getMock(ValueHandlerInterface::class); $this->valueHandlerPool->expects(static::once()) ->method('get') @@ -124,17 +118,16 @@ public function testIsAvailableNotActive() static::assertFalse($this->adapter->isAvailable(null)); } + /** + * @covers \Magento\Payment\Model\Method\Adapter::isAvailable + */ public function testIsAvailableEmptyQuote() { - $activeValueHandler = $this->getMock( - \Magento\Payment\Gateway\Config\ValueHandlerInterface::class - ); - $availabilityValidator = $this->getMock( - \Magento\Payment\Gateway\Validator\ValidatorInterface::class - ); - $paymentDO = $this->getMock(\Magento\Payment\Gateway\Data\PaymentDataObjectInterface::class); - $validationResult = $this->getMock(\Magento\Payment\Gateway\Validator\ResultInterface::class); - $paymentInfo = $this->getMock(\Magento\Payment\Model\InfoInterface::class); + $activeValueHandler = $this->getMock(ValueHandlerInterface::class); + $availabilityValidator = $this->getMock(ValidatorInterface::class); + $paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $validationResult = $this->getMock(ResultInterface::class); + $paymentInfo = $this->getMock(InfoInterface::class); $this->valueHandlerPool->expects(static::once()) ->method('get') @@ -167,24 +160,49 @@ public function testIsAvailableEmptyQuote() static::assertTrue($this->adapter->isAvailable(null)); } + /** + * @covers \Magento\Payment\Model\Method\Adapter::isAvailable + */ + public function testIsAvailableWithEmptyInfoInstance() + { + $activeValueHandler = $this->getMock(ValueHandlerInterface::class); + $this->valueHandlerPool->expects(static::once()) + ->method('get') + ->with('active') + ->willReturn($activeValueHandler); + $activeValueHandler->expects(static::once()) + ->method('handle') + ->with(['field' => 'active']) + ->willReturn(true); + + $this->validatorPool->expects(static::never()) + ->method('get') + ->with('availability'); + + $this->eventManager->expects(static::once()) + ->method('dispatch'); + + static::assertTrue($this->adapter->isAvailable(null)); + } + public function testExecuteCommandWithCommandExecutor() { - /** @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject $eventManager */ + /** @var ManagerInterface|MockObject $eventManager */ $eventManager = $this->getMock( ManagerInterface::class ); - /** @var ValueHandlerPoolInterface|\PHPUnit_Framework_MockObject_MockObject $valueHandlerPool */ + /** @var ValueHandlerPoolInterface|MockObject $valueHandlerPool */ $valueHandlerPool = $this->getMock( ValueHandlerPoolInterface::class ); - /** @var CommandManagerInterface|\PHPUnit_Framework_MockObject_MockObject $commandManager */ + /** @var CommandManagerInterface|MockObject $commandManager */ $commandManager = $this->getMock( CommandManagerInterface::class ); - /** @var PaymentDataObjectFactory|\PHPUnit_Framework_MockObject_MockObject $paymentDataObjectFactory */ + /** @var PaymentDataObjectFactory|MockObject $paymentDataObjectFactory */ $paymentDataObjectFactory = $this->getMockBuilder( PaymentDataObjectFactory::class ) @@ -232,25 +250,17 @@ public function testExecuteCommandWithCommandExecutor() public function testExecuteCommandWithCommandPool() { - /** @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject $eventManager */ - $eventManager = $this->getMock( - ManagerInterface::class - ); + /** @var ManagerInterface|MockObject $eventManager */ + $eventManager = $this->getMock(ManagerInterface::class); - /** @var ValueHandlerPoolInterface|\PHPUnit_Framework_MockObject_MockObject $valueHandlerPool */ - $valueHandlerPool = $this->getMock( - ValueHandlerPoolInterface::class - ); + /** @var ValueHandlerPoolInterface|MockObject $valueHandlerPool */ + $valueHandlerPool = $this->getMock(ValueHandlerPoolInterface::class); - /** @var CommandPoolInterface|\PHPUnit_Framework_MockObject_MockObject $commandPool */ - $commandPool = $this->getMock( - CommandPoolInterface::class - ); + /** @var CommandPoolInterface|MockObject $commandPool */ + $commandPool = $this->getMock(CommandPoolInterface::class); - /** @var PaymentDataObjectFactory|\PHPUnit_Framework_MockObject_MockObject $paymentDataObjectFactory */ - $paymentDataObjectFactory = $this->getMockBuilder( - PaymentDataObjectFactory::class - ) + /** @var PaymentDataObjectFactory|MockObject $paymentDataObjectFactory */ + $paymentDataObjectFactory = $this->getMockBuilder(PaymentDataObjectFactory::class) ->disableOriginalConstructor() ->getMock(); From 90bcc85d6881f3a76df9fb7f7cce6871b438ebc4 Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Tue, 9 Aug 2016 14:38:32 +0300 Subject: [PATCH 09/18] MAGETWO-56342: [Github] #5910 Braintree sandbox errors when using alternative Merchant Account ID --- .../Braintree/Gateway/Config/Config.php | 10 +++++++ .../Gateway/Request/PaymentDataBuilder.php | 2 +- .../Braintree/Model/Ui/ConfigProvider.php | 10 ++++++- .../Request/PaymentDataBuilderTest.php | 3 +-- .../Test/Unit/Model/Ui/ConfigProviderTest.php | 27 +++++++++++++++++-- 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Braintree/Gateway/Config/Config.php b/app/code/Magento/Braintree/Gateway/Config/Config.php index 59cd8f7a75aa3..774b8e365368f 100644 --- a/app/code/Magento/Braintree/Gateway/Config/Config.php +++ b/app/code/Magento/Braintree/Gateway/Config/Config.php @@ -193,4 +193,14 @@ public function getDynamicDescriptors() } return $values; } + + /** + * Get Merchant account ID + * + * @return string + */ + public function getMerchantAccountId() + { + return $this->getValue(self::KEY_MERCHANT_ACCOUNT_ID); + } } diff --git a/app/code/Magento/Braintree/Gateway/Request/PaymentDataBuilder.php b/app/code/Magento/Braintree/Gateway/Request/PaymentDataBuilder.php index 9591d24465487..dd038e1f9f259 100644 --- a/app/code/Magento/Braintree/Gateway/Request/PaymentDataBuilder.php +++ b/app/code/Magento/Braintree/Gateway/Request/PaymentDataBuilder.php @@ -87,7 +87,7 @@ public function build(array $buildSubject) self::ORDER_ID => $order->getOrderIncrementId() ]; - $merchantAccountId = $this->config->getValue(Config::KEY_MERCHANT_ACCOUNT_ID); + $merchantAccountId = $this->config->getMerchantAccountId(); if (!empty($merchantAccountId)) { $result[self::MERCHANT_ACCOUNT_ID] = $merchantAccountId; } diff --git a/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php b/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php index 77c83707bfc67..76788c3c14510 100644 --- a/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php +++ b/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php @@ -5,6 +5,7 @@ */ namespace Magento\Braintree\Model\Ui; +use Magento\Braintree\Gateway\Request\PaymentDataBuilder; use Magento\Checkout\Model\ConfigProviderInterface; use Magento\Braintree\Gateway\Config\Config; use Magento\Braintree\Model\Adapter\BraintreeAdapter; @@ -86,7 +87,14 @@ public function getConfig() public function getClientToken() { if (empty($this->clientToken)) { - $this->clientToken = $this->adapter->generate(); + $params = []; + + $merchantAccountId = $this->config->getMerchantAccountId(); + if (!empty($merchantAccountId)) { + $params[PaymentDataBuilder::MERCHANT_ACCOUNT_ID] = $merchantAccountId; + } + + $this->clientToken = $this->adapter->generate($params); } return $this->clientToken; diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php index 47a9a49670eb4..7d30651c69e42 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php @@ -133,8 +133,7 @@ public function testBuild() ->willReturnMap($additionalData); $this->configMock->expects(static::once()) - ->method('getValue') - ->with(Config::KEY_MERCHANT_ACCOUNT_ID) + ->method('getMerchantAccountId') ->willReturn(self::MERCHANT_ACCOUNT_ID); $this->paymentDO->expects(static::once()) diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php index 9147b0632583a..04846f369eba9 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php @@ -18,8 +18,8 @@ class ConfigProviderTest extends \PHPUnit_Framework_TestCase { const SDK_URL = 'https://js.braintreegateway.com/v2/braintree.js'; - const CLIENT_TOKEN = 'token'; + const MERCHANT_ACCOUNT_ID = '245345'; /** * @var Config|MockObject @@ -76,11 +76,17 @@ public function testGetConfig($config, $expected) /** * @covers \Magento\Braintree\Model\Ui\ConfigProvider::getClientToken + * @dataProvider getClientTokenDataProvider */ - public function testGetClientToken() + public function testGetClientToken($merchantAccountId, $params) { + $this->config->expects(static::once()) + ->method('getMerchantAccountId') + ->willReturn($merchantAccountId); + $this->braintreeAdapter->expects(static::once()) ->method('generate') + ->with($params) ->willReturn(self::CLIENT_TOKEN); static::assertEquals(self::CLIENT_TOKEN, $this->configProvider->getClientToken()); @@ -140,4 +146,21 @@ public function getConfigDataProvider() ] ]; } + + /** + * @return array + */ + public function getClientTokenDataProvider() + { + return [ + [ + 'merchantAccountId' => '', + 'params' => [] + ], + [ + 'merchantAccountId' => self::MERCHANT_ACCOUNT_ID, + 'params' => ['merchantAccountId' => self::MERCHANT_ACCOUNT_ID] + ] + ]; + } } From 4176384134b26cc203a4e6d7eec465b48e33e34d Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Thu, 11 Aug 2016 10:11:33 +0300 Subject: [PATCH 10/18] MAGETWO-54134: CE module depends on EE code - Moved RMA plugins from DHL, Fedex, Usps modules to RMA module - Covered moved plugins by unit tests --- .../Rma/Edit/Tab/General/Shippingmethod.php | 39 -------- app/code/Magento/Dhl/composer.json | 3 +- app/code/Magento/Dhl/etc/di.xml | 4 - .../Rma/Edit/Tab/General/Shippingmethod.php | 39 -------- app/code/Magento/Fedex/composer.json | 3 - app/code/Magento/Fedex/etc/di.xml | 13 --- .../Tab/General/Shipping/Packaging/Plugin.php | 91 ------------------- app/code/Magento/Usps/etc/adminhtml/di.xml | 6 -- 8 files changed, 1 insertion(+), 197 deletions(-) delete mode 100644 app/code/Magento/Dhl/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php delete mode 100644 app/code/Magento/Fedex/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php delete mode 100644 app/code/Magento/Fedex/etc/di.xml delete mode 100644 app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php diff --git a/app/code/Magento/Dhl/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php b/app/code/Magento/Dhl/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php deleted file mode 100644 index acc859ac8c27e..0000000000000 --- a/app/code/Magento/Dhl/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php +++ /dev/null @@ -1,39 +0,0 @@ -_scopeConfig = $scopeConfig; - } - - /** - * @param \Magento\Framework\DataObject $subject - * @param bool $result - * @return bool - */ - public function afterCanDisplayCustomValue(\Magento\Framework\DataObject $subject, $result) - { - $carrierCode = $subject->getShipment()->getCarrierCode(); - if (!$carrierCode) { - return (bool)$result || false; - } - return (bool)$result || (bool)$carrierCode == \Magento\Dhl\Model\Carrier::CODE; - } -} diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index cab7f39538d95..e88cd535952d6 100644 --- a/app/code/Magento/Dhl/composer.json +++ b/app/code/Magento/Dhl/composer.json @@ -16,8 +16,7 @@ "lib-libxml": "*" }, "suggest": { - "magento/module-checkout": "100.2.*", - "magento/module-rma": "100.2.*" + "magento/module-checkout": "100.2.*" }, "type": "magento2-module", "version": "100.2.0-dev", diff --git a/app/code/Magento/Dhl/etc/di.xml b/app/code/Magento/Dhl/etc/di.xml index 25b90ce8850d8..a215c2e821825 100644 --- a/app/code/Magento/Dhl/etc/di.xml +++ b/app/code/Magento/Dhl/etc/di.xml @@ -9,8 +9,4 @@ - - - diff --git a/app/code/Magento/Fedex/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php b/app/code/Magento/Fedex/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php deleted file mode 100644 index 7319a6e9e694c..0000000000000 --- a/app/code/Magento/Fedex/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php +++ /dev/null @@ -1,39 +0,0 @@ -_scopeConfig = $scopeConfig; - } - - /** - * @param \Magento\Framework\DataObject $subject - * @param bool $result - * @return bool - */ - public function afterCanDisplayCustomValue(\Magento\Framework\DataObject $subject, $result) - { - $carrierCode = $subject->getShipment()->getCarrierCode(); - if (!$carrierCode) { - return (bool)$result || false; - } - return (bool)$result || (bool)$carrierCode == \Magento\Fedex\Model\Carrier::CODE; - } -} diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 07c988e280da7..d27d5c1c60d40 100644 --- a/app/code/Magento/Fedex/composer.json +++ b/app/code/Magento/Fedex/composer.json @@ -14,9 +14,6 @@ "magento/framework": "100.2.*", "lib-libxml": "*" }, - "suggest": { - "magento/module-rma": "100.2.*" - }, "type": "magento2-module", "version": "100.2.0-dev", "license": [ diff --git a/app/code/Magento/Fedex/etc/di.xml b/app/code/Magento/Fedex/etc/di.xml deleted file mode 100644 index 454beffacba9d..0000000000000 --- a/app/code/Magento/Fedex/etc/di.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - diff --git a/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php b/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php deleted file mode 100644 index b0a91da7a07bc..0000000000000 --- a/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php +++ /dev/null @@ -1,91 +0,0 @@ -uspsHelper = $uspsHelper; - $this->request = $request; - } - - /** - * Add rule to isGirthAllowed() method - * - * @param \Magento\Framework\DataObject $subject $subject - * @param bool $result - * @return bool - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function afterIsGirthAllowed(\Magento\Framework\DataObject $subject, $result) - { - return $result && $this->uspsHelper->displayGirthValue($this->request->getParam('method')); - } - - /** - * Add rule to isGirthAllowed() method - * - * @param \Magento\Framework\DataObject $subject - * @param \Closure $proceed - * @return array - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function aroundCheckSizeAndGirthParameter(\Magento\Framework\DataObject $subject, \Closure $proceed) - { - $carrier = $subject->getCarrier(); - $size = $subject->getSourceSizeModel(); - - $girthEnabled = false; - $sizeEnabled = false; - if ($carrier && isset($size[0]['value'])) { - if (in_array( - key($subject->getContainers()), - [Carrier::CONTAINER_NONRECTANGULAR, Carrier::CONTAINER_VARIABLE] - ) - ) { - $girthEnabled = true; - } - - if (in_array( - key($subject->getContainers()), - [Carrier::CONTAINER_NONRECTANGULAR, Carrier::CONTAINER_RECTANGULAR, Carrier::CONTAINER_VARIABLE] - ) - ) { - $sizeEnabled = true; - } - } - - return [$girthEnabled, $sizeEnabled]; - } -} diff --git a/app/code/Magento/Usps/etc/adminhtml/di.xml b/app/code/Magento/Usps/etc/adminhtml/di.xml index f098306c6e99b..f60c4d8eb5868 100644 --- a/app/code/Magento/Usps/etc/adminhtml/di.xml +++ b/app/code/Magento/Usps/etc/adminhtml/di.xml @@ -6,12 +6,6 @@ */ --> - - - Magento\Usps\Model\Source\Size - - - Magento\Usps\Model\Source\Size From 62dc9650f6e097a728c40e6b5c38fd1c98f7aa9f Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Thu, 11 Aug 2016 15:11:01 +0300 Subject: [PATCH 11/18] MAGETWO-56745: [Github] PayPal Express Checkout "Display on Shopping Cart -> NO" does not work --- .../Express/InContext/Minicart/Button.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Paypal/Block/Express/InContext/Minicart/Button.php b/app/code/Magento/Paypal/Block/Express/InContext/Minicart/Button.php index 56e32da15c908..6785b95dadeea 100644 --- a/app/code/Magento/Paypal/Block/Express/InContext/Minicart/Button.php +++ b/app/code/Magento/Paypal/Block/Express/InContext/Minicart/Button.php @@ -54,7 +54,6 @@ class Button extends Template implements ShortcutInterface private $session; /** - * Constructor * @param Context $context * @param ResolverInterface $localeResolver * @param ConfigFactory $configFactory @@ -80,6 +79,8 @@ public function __construct( } /** + * Check `in_context` config value + * * @return bool */ private function isInContext() @@ -88,13 +89,27 @@ private function isInContext() } /** + * Check `visible_on_cart` config value + * + * @return bool + */ + private function isVisibleOnCart() + { + return (bool)(int) $this->config->getValue('visible_on_cart'); + } + + /** + * Check is Paypal In-Context Express Checkout button + * should render in cart/mini-cart + * * @return bool */ protected function shouldRender() { return $this->payment->isAvailable($this->session->getQuote()) && $this->isMiniCart - && $this->isInContext(); + && $this->isInContext() + && $this->isVisibleOnCart(); } /** From 697c5ac6a213e73879ffd29c8518332f6b288d1b Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Mon, 15 Aug 2016 14:54:42 +0300 Subject: [PATCH 12/18] MAGETWO-56447: UPS not providing shipping rates for Puerto Rico - Added based on request destination country code for not found countries --- app/code/Magento/Ups/Model/Carrier.php | 4 +- .../Ups/Test/Unit/Model/CarrierTest.php | 47 ++++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Ups/Model/Carrier.php b/app/code/Magento/Ups/Model/Carrier.php index 17c313af9704f..ec14e9db90cec 100644 --- a/app/code/Magento/Ups/Model/Carrier.php +++ b/app/code/Magento/Ups/Model/Carrier.php @@ -325,13 +325,13 @@ public function setRequest(RateRequest $request) $destCountry = self::GUAM_COUNTRY_ID; } - $rowRequest->setDestCountry($this->_countryFactory->create()->load($destCountry)->getData('iso2_code')); + $country = $this->_countryFactory->create()->load($destCountry); + $rowRequest->setDestCountry($country->getData('iso2_code') ?: $destCountry); $rowRequest->setDestRegionCode($request->getDestRegionCode()); if ($request->getDestPostcode()) { $rowRequest->setDestPostal($request->getDestPostcode()); - } else { } $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); diff --git a/app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php index 8f42ea1c8040c..ea46e534ae890 100644 --- a/app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php @@ -7,6 +7,8 @@ use Magento\Quote\Model\Quote\Address\RateRequest; use Magento\Ups\Model\Carrier; +use Magento\Directory\Model\Country; +use PHPUnit_Framework_MockObject_MockObject as MockObject; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -57,7 +59,7 @@ class CarrierTest extends \PHPUnit_Framework_TestCase protected $countryFactory; /** - * @var \Magento\Directory\Model\Country + * @var Country|MockObject */ protected $country; @@ -309,4 +311,47 @@ public function logDataProvider() ] ]; } + + /** + * @covers \Magento\Ups\Model\Carrier::setRequest + * @param string $countryCode + * @param string $foundCountryCode + * @dataProvider countryDataProvider + */ + public function testSetRequest($countryCode, $foundCountryCode) + { + /** @var RateRequest $request */ + $request = $this->helper->getObject(RateRequest::class); + $request->setData([ + 'orig_country' => 'USA', + 'orig_region_code' => 'CA', + 'orig_post_code' => 90230, + 'orig_city' => 'Culver City', + 'dest_country_id' => $countryCode, + ]); + + $this->country->expects(static::at(1)) + ->method('load') + ->with($countryCode) + ->willReturnSelf(); + + $this->country->expects(static::any()) + ->method('getData') + ->with('iso2_code') + ->willReturn($foundCountryCode); + + $this->model->setRequest($request); + } + + /** + * Get list of country variations + * @return array + */ + public function countryDataProvider() + { + return [ + ['countryCode' => 'PR', 'foundCountryCode' => null], + ['countryCode' => 'US', 'foundCountryCode' => 'US'], + ]; + } } From e0575d6ea366c4aa9a4fa8acc0c8fb04ddb01e91 Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Tue, 16 Aug 2016 10:54:08 +0300 Subject: [PATCH 13/18] MAGETWO-55953: Exception occurs when tracking shipment with invalid FedEx tracking number - Get rid of 'enterprise' keyword --- app/code/Magento/Fedex/etc/wsdl/TrackService_v10.wsdl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/code/Magento/Fedex/etc/wsdl/TrackService_v10.wsdl b/app/code/Magento/Fedex/etc/wsdl/TrackService_v10.wsdl index 3771c1e697888..77f53e02a539a 100644 --- a/app/code/Magento/Fedex/etc/wsdl/TrackService_v10.wsdl +++ b/app/code/Magento/Fedex/etc/wsdl/TrackService_v10.wsdl @@ -185,11 +185,7 @@ - - - This field is used for enterprise transactions. - - + From 9f413d68ed39ea2d555f05a11706a4bc856c3c48 Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Thu, 18 Aug 2016 14:18:04 +0300 Subject: [PATCH 14/18] MAGETWO-55953: Exception occurs when tracking shipment with invalid FedEx tracking number - Fixed type hinting --- app/code/Magento/Fedex/Model/Carrier.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 753388dc17bed..3fe23389ea75b 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -1089,9 +1089,12 @@ protected function _getXMLTracking($tracking) * @param \stdClass $response * @return void */ - protected function _parseTrackingResponse($trackingValue, \stdClass $response) + protected function _parseTrackingResponse($trackingValue, $response) { - if (in_array($response->HighestSeverity, self::$trackingErrors)) { + if (!is_object($response) || empty($response->HighestSeverity)) { + $this->appendTrackingError($trackingValue, __('Invalid response from carrier')); + return; + } else if (in_array($response->HighestSeverity, self::$trackingErrors)) { $this->appendTrackingError($trackingValue, (string) $response->Notifications->Message); return; } else if (empty($response->CompletedTrackDetails) || empty($response->CompletedTrackDetails->TrackDetails)) { From f7bf43cc429f42148f3c1d3959f087a133fd417a Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Fri, 19 Aug 2016 15:26:53 +0300 Subject: [PATCH 15/18] MAGETWO-54134: CE module depends on EE code - Removed redundant dependencies --- app/code/Magento/Usps/Model/Carrier.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Usps/Model/Carrier.php b/app/code/Magento/Usps/Model/Carrier.php index 3040d18ad8041..12345f5ab1f6d 100644 --- a/app/code/Magento/Usps/Model/Carrier.php +++ b/app/code/Magento/Usps/Model/Carrier.php @@ -21,17 +21,19 @@ */ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\Carrier\CarrierInterface { - /** - * USPS containers - */ + /** @deprecated */ const CONTAINER_VARIABLE = 'VARIABLE'; + /** @deprecated */ const CONTAINER_FLAT_RATE_BOX = 'FLAT RATE BOX'; + /** @deprecated */ const CONTAINER_FLAT_RATE_ENVELOPE = 'FLAT RATE ENVELOPE'; + /** @deprecated */ const CONTAINER_RECTANGULAR = 'RECTANGULAR'; + /** @deprecated */ const CONTAINER_NONRECTANGULAR = 'NONRECTANGULAR'; /** From 89ee3f9fb74c1704ebe50bf29102bc27dd4b293c Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Fri, 19 Aug 2016 18:10:23 +0300 Subject: [PATCH 16/18] MAGETWO-54134: CE module depends on EE code - Removed plugin --- .../Model/Carrier/AbstractCarrierOnline.php | 3 +- app/code/Magento/Usps/Model/Carrier.php | 28 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php index af310da3064f8..296a3302de786 100644 --- a/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php +++ b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php @@ -596,11 +596,12 @@ protected function _isUSCountry($countyId) * Check whether girth is allowed for the carrier * * @param null|string $countyDest + * @param null|string $carrierMethodCode * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @api */ - public function isGirthAllowed($countyDest = null) + public function isGirthAllowed($countyDest = null, $carrierMethodCode = null) { return false; } diff --git a/app/code/Magento/Usps/Model/Carrier.php b/app/code/Magento/Usps/Model/Carrier.php index 12345f5ab1f6d..d12341659cb6d 100644 --- a/app/code/Magento/Usps/Model/Carrier.php +++ b/app/code/Magento/Usps/Model/Carrier.php @@ -8,11 +8,13 @@ namespace Magento\Usps\Model; +use Magento\Framework\App\ObjectManager; use Magento\Quote\Model\Quote\Address\RateRequest; use Magento\Shipping\Helper\Carrier as CarrierHelper; use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; use Magento\Shipping\Model\Rate\Result; use Magento\Framework\Xml\Security; +use Magento\Usps\Helper\Data as DataHelper; /** * USPS shipping @@ -128,6 +130,11 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C 'USERID' ]; + /** + * @var DataHelper + */ + private $dataHelper; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory @@ -1982,11 +1989,13 @@ public function getDeliveryConfirmationTypes(\Magento\Framework\DataObject $para * Check whether girth is allowed for the USPS * * @param null|string $countyDest + * @param null|string $carrierMethodCode * @return bool */ - public function isGirthAllowed($countyDest = null) + public function isGirthAllowed($countyDest = null, $carrierMethodCode = null) { - return $this->_isUSCountry($countyDest) ? false : true; + return $this->_isUSCountry($countyDest) + && $this->getDataHelper()->displayGirthValue($carrierMethodCode) ? false : true; } /** @@ -2091,4 +2100,19 @@ protected function filterDebugData($data) return $data; } + + /** + * Gets Data helper object + * + * @return DataHelper + * @deprecated + */ + private function getDataHelper() + { + if (!$this->dataHelper) { + $this->dataHelper = ObjectManager::getInstance()->get(DataHelper::class); + } + + return $this->dataHelper; + } } From 3ce8f20bf51f6278d8972eac973ea8c16b978438 Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Thu, 25 Aug 2016 14:24:34 +0300 Subject: [PATCH 17/18] MAGETWO-54134: CE module depends on EE code - Fixed unit test --- .../Usps/Test/Unit/Model/CarrierTest.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php index 1e2e9fd797b05..a79206553c5bc 100644 --- a/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php @@ -6,6 +6,7 @@ namespace Magento\Usps\Test\Unit\Model; use Magento\Quote\Model\Quote\Address\RateRequest; +use Magento\Usps\Helper\Data as DataHelper; use Magento\Usps\Model\Carrier; /** @@ -43,6 +44,11 @@ class CarrierTest extends \PHPUnit_Framework_TestCase */ protected $scope; + /** + * @var DataHelper|\PHPUnit_Framework_MockObject_MockObject + */ + private $dataHelper; + /** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -154,7 +160,14 @@ function ($data) { ]; + $this->dataHelper = $this->getMockBuilder(DataHelper::class) + ->disableOriginalConstructor() + ->setMethods(['displayGirthValue']) + ->getMock(); + $this->carrier = $this->helper->getObject(\Magento\Usps\Model\Carrier::class, $arguments); + + $this->helper->setBackwardCompatibleProperty($this->carrier, 'dataHelper', $this->dataHelper); } /** @@ -324,4 +337,33 @@ public function logDataProvider() ], ]; } + + /** + * @param string $countyCode + * @param string $carrierMethodCode + * @param bool $displayGirthValueResult + * @param bool $result + * @dataProvider isGirthAllowedDataProvider + */ + public function testIsGirthAllowed($countyCode, $carrierMethodCode, $displayGirthValueResult, $result) + { + $this->dataHelper->expects(static::any()) + ->method('displayGirthValue') + ->with($carrierMethodCode) + ->willReturn($displayGirthValueResult); + + self::assertEquals($result, $this->carrier->isGirthAllowed($countyCode, $carrierMethodCode)); + } + + /** + * @return array + */ + public function isGirthAllowedDataProvider() + { + return [ + ['US', 'usps_1', true, false], + ['UK', 'usps_1', true, true], + ['US', 'usps_0', false, true], + ]; + } } From 2653330d93eed56191a97f17095a8e006bbe3602 Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Fri, 26 Aug 2016 16:53:00 +0300 Subject: [PATCH 18/18] MAGETWO-56801: [GITHUB] Fixed column description for "website_id" column #4388 - Upgraded module version --- app/code/Magento/CatalogInventory/etc/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogInventory/etc/module.xml b/app/code/Magento/CatalogInventory/etc/module.xml index 5c7ade1e83cda..2224da524fccc 100644 --- a/app/code/Magento/CatalogInventory/etc/module.xml +++ b/app/code/Magento/CatalogInventory/etc/module.xml @@ -6,7 +6,7 @@ */ --> - +