Skip to content

Commit

Permalink
20.2.0 MNB-923 Move DB install to XML. MNB-922 Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wsajosh committed Feb 8, 2021
1 parent da29a60 commit 5610308
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 32 deletions.
68 changes: 68 additions & 0 deletions CHANGELOG-PUBLIC.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to Semantic Versioning(http://semver.org/).

## 1.2.1
Fixed composer file

## 1.2.2
Removed version from composer so just uses tagged version on packagist

## 1.2.3
SHQ16-911 resolved shipping carrier validation in cart and checkout

## 1.2.4
M2-19 modified js validation

## 1.2.5
SHQ16-1346 make address fields not mandatory and include region for support for text field region

## 1.2.6
SHQ16-1335 updated docs links in readme and configuration header, SHQ16-1346 make address fields not mandatory and include region for support for text field region, M2-19 modified js validation

## 1.2.7
SHQ16-1617 remove csv from url params

## 20.0.6
M2-20 account for php configuration temp dir

## 20.0.7
M2-23 remove crontab file, not required

## 20.0.8
M2-20 account for upload when no upload_tmp_dir setting in php config

## 20.0.9
M2-23 remove crontab file, not required, M2-20 account for upload when no upload_tmp_dir setting in php config, Updated readme with latest M2 issues and updated support statement

## 20.1.0
M2-23 remove crontab file

## 20.2.3 (2019-05-09)
SHQ18-1978 Trim postcode and ensure condition value is not null


## 20.1.5 (2019-05-09)
SHQ18-1978 Trim postcode and ensure condition value is not null


## 20.1.6 (2020-05-05)
MNB-3 Fix MatrixRate unit tests


## 20.1.7 (2020-06-30)
MNB-455 Submitted by JeroenVanLeusden. Extract condition codes to own method


## 20.1.8 (2020-07-16)
MNB-472 PR from JeroenVanLeusden - Accept -1 in condition from value in CSV import


## 20.1.9 (2020-12-21)
MNB-566 Clear down old date when upload new CSV


## 20.2.0 (2021-02-08)
MNB-923 Move DB install to XML. MNB-922 Fix unit tests


4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ MNB-472 PR from JeroenVanLeusden - Accept -1 in condition from value in CSV impo
MNB-566 Clear down old date when upload new CSV


## 20.2.0 (2021-02-08)
MNB-923 Move DB install to XML. MNB-922 Fix unit tests


15 changes: 8 additions & 7 deletions Test/Unit/Block/Adminhtml/Carrier/Matrixrate/GridTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,43 +35,44 @@
namespace WebShopApps\MatrixRate\Test\Unit\Block\Adminhtml\Carrier\Matrixrate;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use PHPUnit\Framework\TestCase;

class GridTest extends \PHPUnit\Framework\TestCase
class GridTest extends TestCase
{
/**
* @var \WebShopApps\MatrixRate\Block\Adminhtml\Carrier\Matrixrate\Grid
*/
protected $model;

/**
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $storeManagerMock;

/**
* @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Backend\Helper\Data|\PHPUnit\Framework\MockObject\MockObject
*/
protected $backendHelperMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var \PHPUnit\Framework\MockObject\MockObject
*/
protected $matrixrateMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var \PHPUnit\Framework\MockObject\MockObject
*/
protected $context;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var \PHPUnit\Framework\MockObject\MockObject
*/
protected $collectionFactoryMock;

/** @var ObjectManagerHelper */
protected $objectManagerHelper;

protected function setUp()
protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);

Expand Down
6 changes: 3 additions & 3 deletions Test/Unit/Block/Adminhtml/Form/Field/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
*/
namespace WebShopApps\MatrixRate\Test\Unit\Block\Adminhtml\Form\Field;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use PHPUnit\Framework\TestCase;

class ExportTest extends \PHPUnit\Framework\TestCase
class ExportTest extends TestCase
{
/**
* @var \WebShopApps\MatrixRate\Block\Adminhtml\Form\Field\Export
*/
protected $_object;

protected function setUp()
protected function setUp(): void
{
$backendUrl = $this->createMock(\Magento\Backend\Model\UrlInterface::class);
$backendUrl->expects($this->once())->method('getUrl')->with("shqmatrixrate/system/exportMatrixrates", ['website' => 1]);
Expand Down
40 changes: 26 additions & 14 deletions Test/Unit/Block/Adminhtml/Form/Field/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,43 @@
*/
namespace WebShopApps\MatrixRate\Test\Unit\Block\Adminhtml\Form\Field;

class ImportTest extends \PHPUnit\Framework\TestCase
use Magento\Framework\Escaper;
use Magento\Framework\Math\Random;
use PHPUnit\Framework\TestCase;

class ImportTest extends TestCase
{
/**
* @var \WebShopApps\MatrixRate\Block\Adminhtml\Form\Field\Import
*/
protected $object;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var \PHPUnit\Framework\MockObject\MockObject
*/
protected $formMock;

protected function setUp()
protected function setUp(): void
{
$this->formMock = $this->createPartialMock(
\Magento\Framework\Data\Form::class,
['getFieldNameSuffix', 'addSuffixToName', 'getHtmlIdPrefix', 'getHtmlIdSuffix']
);
$this->formMock = $this->getMockBuilder(\Magento\Framework\Data\Form::class)
->addMethods(['getFieldNameSuffix', 'getHtmlIdPrefix', 'getHtmlIdSuffix'])
->onlyMethods(['addSuffixToName'])
->disableOriginalConstructor()
->getMock();
$randomMock = $this->getMockBuilder(Random::class)->disableOriginalConstructor()->getMock();
$randomMock->method('getRandomString')->willReturn('123456abcdefg');
$testData = ['name' => 'test_name', 'html_id' => 'test_html_id'];
$testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->object = $testHelper->getObject(
\WebShopApps\MatrixRate\Block\Adminhtml\Form\Field\Import::class,
['data' => $testData]
[
'data' => $testData,
'_escaper' => $testHelper->getObject(Escaper::class),
'random' => $randomMock
]
);
$this->object->setForm($this->formMock);

}

public function testGetNameWhenFormFiledNameSuffixIsEmpty()
Expand All @@ -82,24 +94,24 @@ public function testGetElementHtml()
$this->any()
)->method(
'getHtmlIdPrefix'
)->will(
$this->returnValue('test_name_prefix')
)->willReturn(
'test_name_prefix'
);
$this->formMock->expects(
$this->any()
)->method(
'getHtmlIdSuffix'
)->will(
$this->returnValue('test_name_suffix')
)->willReturn(
'test_name_suffix'
);
$testString = $this->object->getElementHtml();
$this->assertStringStartsWith(
'<input id="time_condition" type="hidden" name="test_name" value="',
$testString
);
$this->assertStringEndsWith(
$this->assertStringContainsString(
'<input id="test_name_prefixtest_html_idtest_name_suffix" ' .
'name="test_name" data-ui-id="form-element-test_name" value="" type="file"/>',
'name="test_name" data-ui-id="form-element-test_name" value="" type="file"',
$testString
);
}
Expand Down
7 changes: 4 additions & 3 deletions Test/Unit/Model/Config/Backend/MatrixrateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,24 @@
namespace WebShopApps\MatrixRate\Test\Unit\Model\Config\Backend;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use PHPUnit\Framework\TestCase;

class MatrixrateTest extends \PHPUnit\Framework\TestCase
class MatrixrateTest extends TestCase
{
/**
* @var \WebShopApps\MatrixRate\Model\Config\Backend\Matrixrate
*/
protected $model;

/**
* @var \WebShopApps\MatrixRate\Model\ResourceModel\Carrier\MatrixrateFactory|\PHPUnit_Framework_MockObject_MockObject
* @var \WebShopApps\MatrixRate\Model\ResourceModel\Carrier\MatrixrateFactory|\PHPUnit\Framework\MockObject\MockObject
*/
protected $tableateFactoryMock;

/** @var ObjectManagerHelper */
protected $objectManagerHelper;

protected function setUp()
protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);

Expand Down
7 changes: 4 additions & 3 deletions Test/Unit/Model/Config/Source/MatrixrateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,24 @@
namespace WebShopApps\MatrixRate\Test\Unit\Model\Config\Source;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use PHPUnit\Framework\TestCase;

class MatrixrateTest extends \PHPUnit\Framework\TestCase
class MatrixrateTest extends TestCase
{
/**
* @var \WebShopApps\MatrixRate\Model\Config\Source\Matrixrate
*/
protected $model;

/**
* @var \WebShopApps\MatrixRate\Model\Carrier\Matrixrate|\PHPUnit_Framework_MockObject_MockObject
* @var \WebShopApps\MatrixRate\Model\Carrier\Matrixrate|\PHPUnit\Framework\MockObject\MockObject
*/
protected $carrierMatrixrateMock;

/** @var ObjectManagerHelper */
protected $objectManagerHelper;

protected function setUp()
protected function setUp(): void
{
$this->carrierMatrixrateMock = $this->getMockBuilder('\WebShopApps\MatrixRate\Model\Carrier\Matrixrate')
->disableOriginalConstructor()
Expand Down
Binary file removed ZIP/Matrixrates M2-20.1.9.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Setup/InstallSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$installer = $setup;

$installer->startSetup();

$installer->endSetup();
}
}
14 changes: 13 additions & 1 deletion src/etc/db_schema.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
<?xml version="1.0"?>
<!--
~ Shipper HQ
~
~ Thanks to https://github.com/mklooss for writing this file
~
~ @category ShipperHQ
~ @package shq
~ @copyright Copyright (c) 2021 Zowta LTD and Zowta LLC (http://www.ShipperHQ.com)
~ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
~ @author ShipperHQ Team sales@shipperhq.com
-->

<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="webshopapps_matrixrate" comment="WebShopApps MatrixRates" resource="default">
Expand Down Expand Up @@ -33,4 +45,4 @@
<column name="shipping_method" />
</constraint>
</table>
</schema>
</schema>

0 comments on commit 5610308

Please sign in to comment.