Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:tig-nl/tig-extension-tig-postnl-…
Browse files Browse the repository at this point in the history
…magento2
  • Loading branch information
tig-kevinvandijk committed Jun 15, 2022
2 parents efdebad + 6e2a155 commit 73f03ca
Show file tree
Hide file tree
Showing 113 changed files with 514 additions and 595 deletions.
56 changes: 17 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,27 @@
sudo: required
dist: trusty
addons:
apt:
packages:
- mysql-server-5.6
- mysql-client-core-5.6
- mysql-client-5.6

language: php

env:
global:
- CODE_COVERAGE=false
- DI_COMPILE=false

services:
- docker
matrix:
# PHP 7.2 is only supported in Magento 2.3.2
# PHP 7.3 is only supported in Magento 2.3.3
include:
- php: 7.2
env: MAGENTO_VERSION=2.3.3
- php: 7.3
env: MAGENTO_VERSION=2.3.4 # DI_COMPILE=true
- php: 7.3
env: MAGENTO_VERSION=2.3.5 CODE_COVERAGE=true

before_script:
- export PATH=$PATH:$HOME/.composer/vendor/bin
- composer config -a -g http-basic.repo.magento.com $MAGENTO_USERNAME $MAGENTO_PASSWORD
- bash Test/Script/ManageDependencies.sh
- bash Test/Script/Setup.sh
- env: MAGENTO_VERSION=2.3.7 DB_VERSION=5.7 TESTS=unit
- env: MAGENTO_VERSION=2.4.3-p1 DB_VERSION=8 TESTS=unit
- env: MAGENTO_VERSION=2.4.4 DB_VERSION=8 TESTS=unit
- env: MAGENTO_VERSION=2.3.7 DB_VERSION=5.7 TESTS=integration
- env: MAGENTO_VERSION=2.4.3-p1 DB_VERSION=8 TESTS=integration
- env: MAGENTO_VERSION=2.4.4 DB_VERSION=8 TESTS=integration

script:
- if [ $CODE_COVERAGE == false ] && [ $DI_COMPILE == true ]; then php /tmp/magento2/bin/magento setup:di:compile; fi # Check for compilation errors
- grunt phpcs
- grunt lint
- grunt exec:phraseTest
- grunt exec:ciTests
- docker pull registry.tig.nl/tig-docker/magento:$MAGENTO_VERSION
- docker run --rm --link mysql:db --link elasticsearch:es --link ampq:ampq -v $(pwd):/code:ro -e DB_NAME=integration registry.tig.nl/tig-docker/magento:$MAGENTO_VERSION test-runner -vv -n -i $MAGENTO_VERSION -m $TESTS
before_script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin registry.tig.nl
- docker run --rm -d --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=true -e MYSQL_USER=integration -e MYSQL_PASSWORD=integration -e MYSQL_DATABASE=integration mysql:$DB_VERSION
- docker run --rm -d --name ampq rabbitmq:3.8
- docker run --rm -d --name elasticsearch -e "discovery.type=single-node" elasticsearch:7.9.3

after_success:
- bash Test/Script/AfterSuccess.sh
after_script:
- docker stop mysql elasticsearch ampq

cache:
directories:
- node_modules
- $HOME/.download_cache
- $HOME/.composer
- $HOME/.cache/composer
2 changes: 1 addition & 1 deletion Block/Adminhtml/Config/Support/SupportTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

class SupportTab extends Template implements RendererInterface
{
const POSTNL_VERSION = '1.12.1';
const POSTNL_VERSION = '1.12.2';

const XPATH_SUPPORTED_MAGENTO_VERSION = 'tig_postnl/supported_magento_version';

Expand Down
3 changes: 2 additions & 1 deletion Block/Adminhtml/Grid/AbstractGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ protected function prepareData()
return null;
}


/**
* @return array
* @return void
*/
// @codingStandardsIgnoreLine
protected function handleItems()
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Renderer/DeepLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private function getBarcodeUrl($shipment)
$params = [
'B=' . $shipment->getMainBarcode(),
'D=' . $address->getCountryId(),
'P=' . str_replace(' ', '', $address->getPostcode()),
'P=' . str_replace(' ', '', (string)$address->getPostcode()),
'T=' . 'B', // Business for backend, which will retuns the Mijn PostNL link.
];

Expand Down
4 changes: 1 addition & 3 deletions Config/Provider/ShippingOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,7 @@ public function isLetterboxPackageActive()
*/
public function canUseBeProducts()
{
if ($this->getConfigFromXpath(self::XPATH_SHIPPING_OPTION_COUNTRY) === 'BE') {
return true;
}
return $this->getConfigFromXpath(self::XPATH_SHIPPING_OPTION_COUNTRY) === 'BE';
}
}
/**
Expand Down
4 changes: 2 additions & 2 deletions Controller/Adminhtml/LabelAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

use TIG\PostNL\Service\Shipment\Labelling\GetLabels;
use TIG\PostNL\Service\Shipment\Packingslip\GetPackingslip;
use TIG\PostNL\Controller\AdminHtml\PdfDownload as GetPdf;
use TIG\PostNL\Controller\Adminhtml\PdfDownload as GetPdf;
use TIG\PostNL\Service\Handler\BarcodeHandler;
use TIG\PostNL\Helper\Tracking\Track;
use \Magento\Sales\Model\Order\Shipment;
Expand Down Expand Up @@ -142,7 +142,7 @@ protected function setPackingslip($shipmentId, $withLabels = true, $confirm = tr
return;
}

if (strlen($packingslip) <= 0) {
if (strlen((string)$packingslip) === 0) {
return;
}

Expand Down
5 changes: 5 additions & 0 deletions Controller/Adminhtml/Order/CreateShipments.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class CreateShipments extends Action
*/
private $errors = [];

/**
* @var OrderCollectionFactory
*/
private $collectionFactory;

/**
* @param Context $context
* @param Filter $filter
Expand Down
2 changes: 1 addition & 1 deletion Helper/AbstractTracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected function generateTrackAndTraceUrl(OrderAddressInterface $address, $tra
$params = [
'B' => $trackingNumber,
'D' => $address->getCountryId(),
'P' => str_replace(' ', '', $address->getPostcode()),
'P' => str_replace(' ', '', $address->getPostcode() ?? ''),
'T' => $type,
'L' => $language
];
Expand Down
4 changes: 2 additions & 2 deletions Helper/Tracking/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function send()
try {
$this->trackAndTraceEmail->sendMessage();
} catch (MailException $exception) {
$this->logging->addCritical($exception->getLogMessage());
$this->logging->critical($exception->getLogMessage());
}
}

Expand Down Expand Up @@ -158,7 +158,7 @@ public function set($shipment, $url)
$address = $shipment->getShippingAddress();
$transport->addTo($address->getEmail(), $address->getFirstname() . ' ' . $address->getLastname());
$transport = $this->addBccEmail($transport);
$this->logging->addInfo('Track And Trace email build for :' . $address->getEmail());
$this->logging->info('Track And Trace email build for :' . $address->getEmail());
$this->trackAndTraceEmail = $transport->getTransport();
}
// @codingStandardsIgnoreEnd
Expand Down
4 changes: 2 additions & 2 deletions Helper/Tracking/Track.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function send($shipment)
*/
private function addTrackingNumbersToShipment($shipment, $trackingNumbers)
{
$this->logging->addDebug('Adding trackingnumbers to shipment_id : '. $shipment->getId(), $trackingNumbers);
$this->logging->debug('Adding trackingnumbers to shipment_id : '. $shipment->getId(), $trackingNumbers);

$shipment = $this->resetTrackingKey($shipment);
foreach ($trackingNumbers as $number) {
Expand All @@ -217,7 +217,7 @@ private function addTrackingNumbersToShipment($shipment, $trackingNumbers)
private function addReturnTrackingNumbersToShipment($postNLShipment)
{
$shipment = $postNLShipment->getShipment();
$this->logging->addDebug('Adding return trackingnumbers to shipment_id : '. $shipment->getId());
$this->logging->debug('Adding return trackingnumbers to shipment_id : '. $shipment->getId());
$returnItems = $this->getList($postNLShipment);

foreach ($returnItems as $item) {
Expand Down
3 changes: 2 additions & 1 deletion Logging/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/
namespace TIG\PostNL\Logging;

use Monolog\DateTimeImmutable;
use Monolog\Logger;
use TIG\PostNL\Config\Provider\LoggingConfiguration;

Expand Down Expand Up @@ -64,7 +65,7 @@ public function __construct(
*
* @return bool
*/
public function addRecord($level, $message, array $context = [])
public function addRecord($level, $message, array $context = [], DateTimeImmutable $dateTimeImmutable = null):bool
{
if (!$this->logConfig->canLog($level)) {
return false;
Expand Down
1 change: 1 addition & 0 deletions Model/ResourceModel/Tablerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public function uploadAndImport(DataObject $object, $importData)
$this->logger->critical($exception);
throw new PostnlException(__('An error occurred while importing the table rates.'), 'POSTNL-0251');
}
return $this;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Service/Carrier/Price/Filter/CountryFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ private function hasRowZipCode($destPostcode, $rowPostcode)
}

/**
* @param $postcode
* @param string $postcode
*
* @return mixed
* @return string
*/
private function normalizeZipCode($postcode)
{
return str_replace(' ', '', $postcode);
return str_replace(' ', '', (string)$postcode);
}
}
2 changes: 1 addition & 1 deletion Service/Carrier/Price/Matrixrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function __construct(
*/
public function getRate(RateRequest $request, $parcelType, $store = null)
{
$matrixrateCollection = $this->matrixrateCollection->addOrder('subtotal', 'DESC');
$matrixrateCollection = $this->matrixrateCollection->addOrder('subtotal', 'DESC')->addOrder('weight', 'DESC');
$this->shippingVatEnabled = $this->taxHelper->shippingPriceIncludesTax($store);
$parcelType = $parcelType ?: 'regular';
$collection = $matrixrateCollection->toArray();
Expand Down
9 changes: 6 additions & 3 deletions Service/Import/Matrixrate/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,12 @@ private function validateHeaders($header)
*/
private function deleteData()
{
$this->matrixrateCollection->addFieldToFilter('website_id', $this->websiteId);
$this->matrixrateCollection->clear();
$this->matrixrateCollection->walk('delete');
$deleteWebsiteData = clone $this->matrixrateCollection;

$deleteWebsiteData->addFieldToFilter('website_id', $this->websiteId);
$deleteWebsiteData->clear();
$deleteWebsiteData->walk('delete');

$this->importData = [];
}

Expand Down
2 changes: 1 addition & 1 deletion Service/Shipment/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private function getDefaultShipmentData(ShipmentInterface $shipment, $address, $
{
$deliveryDate = $shipment->getDeliveryDate();
$postnlOrder = $shipment->getPostNLOrder();
$shipmentType = $postnlOrder->getType();
$shipmentType = $postnlOrder ? $postnlOrder->getType() : '';

if (!$deliveryDate) {
$deliveryDate = $this->getDeliveryDateFromPostNLOrder($shipment);
Expand Down
2 changes: 1 addition & 1 deletion Service/Shipment/Label/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function orderLabels($labels)
if (is_array($label)) {
return false;
}
if (strtoupper($label->getType()) == ProductInfo::SHIPMENT_TYPE_GP) {
if (strtoupper((string)$label->getType()) == ProductInfo::SHIPMENT_TYPE_GP) {
$this->globalPackLabels[] = $label;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Service/Shipment/Label/Merge.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private function mergeA6Labels($labels, $createNewPdf)
* therefore check if there are A6 labels to merge.
*/
if (!empty($a6Labels)) {
$a6result = $this->a6Merger->files($a6Labels, $createNewPdf);
$a6result = $this->a6Merger->files($a6Labels, true);
$a4result->concatPdf($a6result);
}

Expand Down
40 changes: 0 additions & 40 deletions Service/Shipment/Label/SizeInterface.php

This file was deleted.

2 changes: 1 addition & 1 deletion Service/Shipment/Labelling/GenerateAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private function callEndpoint(ShipmentInterface $postNlShipment, $currentShipmen
}

if (!is_object($response) || !isset($responseShipments->ResponseShipment)) {
throw new PostNLException(sprintf('Invalid generateLabel response: %1', var_export($response, true)));
throw new PostNLException(sprintf('Invalid generateLabel response: %s', var_export($response, true)));
}

return $responseShipments->ResponseShipment;
Expand Down
Loading

0 comments on commit 73f03ca

Please sign in to comment.