init
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Framework\Filesystem\Directory\WriteInterface;
|
||||
|
||||
$importCsv = 'tablerates.csv';
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var Filesystem $fileSystem */
|
||||
$fileSystem = $objectManager->get(Filesystem::class);
|
||||
/** @var WriteInterface $tmpDirectory */
|
||||
$tmpDirectory = $fileSystem->getDirectoryWrite(DirectoryList::SYS_TMP);
|
||||
$importCsvPath = $tmpDirectory->getAbsolutePath($importCsv);
|
||||
|
||||
$fixtureDir = realpath(__DIR__);
|
||||
copy($fixtureDir . DIRECTORY_SEPARATOR . $importCsv, $importCsvPath);
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Framework\Filesystem\Directory\WriteInterface;
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var Filesystem $fileSystem */
|
||||
$fileSystem = $objectManager->get(Filesystem::class);
|
||||
/** @var WriteInterface $tmpDirectory */
|
||||
$tmpDirectory = $fileSystem->getDirectoryWrite(DirectoryList::SYS_TMP);
|
||||
$fileName = 'tablerates.csv';
|
||||
|
||||
$tmpDirectory->delete($fileName);
|
||||
@@ -0,0 +1,2 @@
|
||||
Country,Region/State,"Zip/Postal Code","Weight (and above)","Shipping Price"
|
||||
USA,*,*,10.0000,666.0000
|
||||
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$resource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class);
|
||||
$connection = $resource->getConnection();
|
||||
$resourceModel = $objectManager->create(\Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::class);
|
||||
$entityTable = $resourceModel->getTable('shipping_tablerate');
|
||||
$data =
|
||||
[
|
||||
'website_id' => 1,
|
||||
'dest_country_id' => 'US',
|
||||
'dest_region_id' => 0,
|
||||
'dest_zip' => '*',
|
||||
'condition_name' => 'package_qty',
|
||||
'condition_value' => 1,
|
||||
'price' => 10,
|
||||
'cost' => 10
|
||||
];
|
||||
$connection->query(
|
||||
"INSERT INTO {$entityTable} (`website_id`, `dest_country_id`, `dest_region_id`, `dest_zip`, `condition_name`,"
|
||||
. "`condition_value`, `price`, `cost`) VALUES (:website_id, :dest_country_id, :dest_region_id, :dest_zip,"
|
||||
. " :condition_name, :condition_value, :price, :cost);",
|
||||
$data
|
||||
);
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/**
|
||||
* @var Tablerate $resourceModel
|
||||
*/
|
||||
$resourceModel = $objectManager->create(Tablerate::class);
|
||||
$tableRatesData = [
|
||||
[
|
||||
'website_id' => 1,
|
||||
'dest_country_id' => 'US',
|
||||
'dest_region_id' => 0,
|
||||
'dest_zip' => '*',
|
||||
'condition_name' => 'package_value_with_discount',
|
||||
'condition_value' => 0.00,
|
||||
'price' => 15,
|
||||
'cost' => 0
|
||||
],
|
||||
[
|
||||
'website_id' => 1,
|
||||
'dest_country_id' => 'US',
|
||||
'dest_region_id' => 0,
|
||||
'dest_zip' => '*',
|
||||
'condition_name' => 'package_value_with_discount',
|
||||
'condition_value' => 50.00,
|
||||
'price' => 10,
|
||||
'cost' => 0
|
||||
],
|
||||
[
|
||||
'website_id' => 1,
|
||||
'dest_country_id' => 'US',
|
||||
'dest_region_id' => 0,
|
||||
'dest_zip' => '*',
|
||||
'condition_name' => 'package_value_with_discount',
|
||||
'condition_value' => 100.00,
|
||||
'price' => 5,
|
||||
'cost' => 0
|
||||
]
|
||||
];
|
||||
$columns = [
|
||||
'website_id',
|
||||
'dest_country_id',
|
||||
'dest_region_id',
|
||||
'dest_zip',
|
||||
'condition_name',
|
||||
'condition_value',
|
||||
'price',
|
||||
'cost'
|
||||
];
|
||||
$resourceModel->getConnection()->insertArray($resourceModel->getMainTable(), $columns, $tableRatesData);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
$resourceModel = $objectManager->create(Tablerate::class);
|
||||
$resourceModel->getConnection()->delete($resourceModel->getMainTable());
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$resource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class);
|
||||
$connection = $resource->getConnection();
|
||||
$resourceModel = $objectManager->create(\Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::class);
|
||||
$entityTable = $resourceModel->getTable('shipping_tablerate');
|
||||
$connection->query("DELETE FROM {$entityTable};");
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\App\ResourceConnection;
|
||||
use Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate;
|
||||
use Magento\Store\Api\WebsiteRepositoryInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
|
||||
/** @var WebsiteRepositoryInterface $websiteRepository */
|
||||
$websiteRepository = $objectManager->get(WebsiteRepositoryInterface::class);
|
||||
$website = $websiteRepository->get('test');
|
||||
|
||||
/** @var ResourceConnection $resource */
|
||||
$resource = $objectManager->get(ResourceConnection::class);
|
||||
$connection = $resource->getConnection();
|
||||
$resourceModel = $objectManager->create(Tablerate::class);
|
||||
$entityTable = $resourceModel->getTable('shipping_tablerate');
|
||||
$data =
|
||||
[
|
||||
'website_id' => $website->getId(),
|
||||
'dest_country_id' => 'US',
|
||||
'dest_region_id' => 0,
|
||||
'dest_zip' => '*',
|
||||
'condition_name' => 'package_qty',
|
||||
'condition_value' => 1,
|
||||
'price' => 20,
|
||||
'cost' => 20
|
||||
];
|
||||
$connection->query(
|
||||
"INSERT INTO {$entityTable} (`website_id`, `dest_country_id`, `dest_region_id`, `dest_zip`, `condition_name`,"
|
||||
. "`condition_value`, `price`, `cost`) VALUES (:website_id, :dest_country_id, :dest_region_id, :dest_zip,"
|
||||
. " :condition_name, :condition_value, :price, :cost);",
|
||||
$data
|
||||
);
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$resource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class);
|
||||
$connection = $resource->getConnection();
|
||||
$resourceModel = $objectManager->create(\Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::class);
|
||||
$entityTable = $resourceModel->getTable('shipping_tablerate');
|
||||
$connection->query("DELETE FROM {$entityTable};");
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$resource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class);
|
||||
$connection = $resource->getConnection();
|
||||
$resourceModel = $objectManager->create(\Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::class);
|
||||
$entityTable = $resourceModel->getTable('shipping_tablerate');
|
||||
$data =
|
||||
[
|
||||
'website_id' => 1,
|
||||
'dest_country_id' => 'US',
|
||||
'dest_region_id' => 0,
|
||||
'dest_zip' => '*',
|
||||
'condition_name' => 'package_weight',
|
||||
'condition_value' => 0,
|
||||
'price' => 10,
|
||||
'cost' => 0
|
||||
];
|
||||
$connection->query(
|
||||
"INSERT INTO {$entityTable} (`website_id`, `dest_country_id`, `dest_region_id`, `dest_zip`, `condition_name`,"
|
||||
. "`condition_value`, `price`, `cost`) VALUES (:website_id, :dest_country_id, :dest_region_id, :dest_zip,"
|
||||
. " :condition_name, :condition_value, :price, :cost);",
|
||||
$data
|
||||
);
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/OfflineShipping/_files/tablerates_rollback.php');
|
||||
Reference in New Issue
Block a user