From 7b6523262d92adaf535f7a86c6e7ce0bf91f5785 Mon Sep 17 00:00:00 2001 From: gorokh Date: Fri, 7 Feb 2020 17:36:34 +0300 Subject: [PATCH] fix test backward compatibility with phpunit < v.6 --- src/Model/Service/IntegrationModule.php | 9 ++++++++- src/Test/Helpers/FieldsetTest.php | 5 +++++ .../Unit/Block/Frontend/DaemonCollectorTest.php | 5 +++++ src/Test/Unit/Model/Observer/CustomerTest.php | 5 +++++ src/Test/Unit/Model/Observer/OrderCreateTest.php | 5 +++++ src/Test/Unit/Model/Observer/OrderUpdateTest.php | 5 +++++ src/Test/Unit/Model/Service/CustomerTest.php | 5 +++++ .../Unit/Model/Service/IntegrationModuleTest.php | 5 +++++ .../Unit/Model/Service/InventoriesUploadTest.php | 15 ++++++++++----- src/Test/Unit/Model/Service/OrderTest.php | 5 +++++ 10 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/Model/Service/IntegrationModule.php b/src/Model/Service/IntegrationModule.php index 0d877ab..0a79225 100644 --- a/src/Model/Service/IntegrationModule.php +++ b/src/Model/Service/IntegrationModule.php @@ -3,6 +3,7 @@ namespace Retailcrm\Retailcrm\Model\Service; use Retailcrm\Retailcrm\Helper\Data as Helper; +use Magento\Framework\App\Config\ScopeConfigInterface; class IntegrationModule { @@ -110,9 +111,15 @@ class IntegrationModule } if ($response->isSuccessful() && $active == true) { + + $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT; + $scopeId = 0; + $this->resourceConfig->saveConfig( Helper::XML_PATH_RETAILCRM . 'general/client_id_in_crm', - $this->clientId + $this->clientId, + $scope, + $scopeId ); return true; diff --git a/src/Test/Helpers/FieldsetTest.php b/src/Test/Helpers/FieldsetTest.php index 4b9138c..2fcd6ce 100644 --- a/src/Test/Helpers/FieldsetTest.php +++ b/src/Test/Helpers/FieldsetTest.php @@ -2,6 +2,11 @@ namespace Retailcrm\Retailcrm\Test\Helpers; +// backward compatibility with phpunit < v.6 +if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); +} + class FieldsetTest extends \PHPUnit\Framework\TestCase { protected $elementMock; diff --git a/src/Test/Unit/Block/Frontend/DaemonCollectorTest.php b/src/Test/Unit/Block/Frontend/DaemonCollectorTest.php index fb7e5f3..f264176 100644 --- a/src/Test/Unit/Block/Frontend/DaemonCollectorTest.php +++ b/src/Test/Unit/Block/Frontend/DaemonCollectorTest.php @@ -2,6 +2,11 @@ namespace Retailcrm\Retailcrm\Test\Unit\Block\Frontend; +// backward compatibility with phpunit < v.6 +if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); +} + class DaemonCollectorTest extends \PHPUnit\Framework\TestCase { private $unit; diff --git a/src/Test/Unit/Model/Observer/CustomerTest.php b/src/Test/Unit/Model/Observer/CustomerTest.php index 50f7d12..696f367 100644 --- a/src/Test/Unit/Model/Observer/CustomerTest.php +++ b/src/Test/Unit/Model/Observer/CustomerTest.php @@ -2,6 +2,11 @@ namespace Retailcrm\Retailcrm\Test\Unit\Model\Observer; +// backward compatibility with phpunit < v.6 +if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); +} + class CustomerTest extends \PHPUnit\Framework\TestCase { private $mockApi; diff --git a/src/Test/Unit/Model/Observer/OrderCreateTest.php b/src/Test/Unit/Model/Observer/OrderCreateTest.php index c734619..3417471 100644 --- a/src/Test/Unit/Model/Observer/OrderCreateTest.php +++ b/src/Test/Unit/Model/Observer/OrderCreateTest.php @@ -2,6 +2,11 @@ namespace Retailcrm\Retailcrm\Test\Unit\Observer; +// backward compatibility with phpunit < v.6 +if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); +} + /** * Order create observer test class */ diff --git a/src/Test/Unit/Model/Observer/OrderUpdateTest.php b/src/Test/Unit/Model/Observer/OrderUpdateTest.php index 6ece21b..ffd0792 100644 --- a/src/Test/Unit/Model/Observer/OrderUpdateTest.php +++ b/src/Test/Unit/Model/Observer/OrderUpdateTest.php @@ -2,6 +2,11 @@ namespace Retailcrm\Retailcrm\Test\Unit\Observer; +// backward compatibility with phpunit < v.6 +if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); +} + class OrderUpdateTest extends \PHPUnit\Framework\TestCase { private $unit; diff --git a/src/Test/Unit/Model/Service/CustomerTest.php b/src/Test/Unit/Model/Service/CustomerTest.php index 3a2126d..4e298a4 100644 --- a/src/Test/Unit/Model/Service/CustomerTest.php +++ b/src/Test/Unit/Model/Service/CustomerTest.php @@ -2,6 +2,11 @@ namespace Retailcrm\Retailcrm\Test\Unit\Model\Service; +// backward compatibility with phpunit < v.6 +if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); +} + class CustomerTest extends \PHPUnit\Framework\TestCase { private $mockData; diff --git a/src/Test/Unit/Model/Service/IntegrationModuleTest.php b/src/Test/Unit/Model/Service/IntegrationModuleTest.php index 7679e05..d0e1780 100644 --- a/src/Test/Unit/Model/Service/IntegrationModuleTest.php +++ b/src/Test/Unit/Model/Service/IntegrationModuleTest.php @@ -2,6 +2,11 @@ namespace Retailcrm\Retailcrm\Test\Unit\Model\Service; +// backward compatibility with phpunit < v.6 +if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); +} + class IntegrationModuleTest extends \PHPUnit\Framework\TestCase { private $mockResourceConfig; diff --git a/src/Test/Unit/Model/Service/InventoriesUploadTest.php b/src/Test/Unit/Model/Service/InventoriesUploadTest.php index edbe880..2300c13 100644 --- a/src/Test/Unit/Model/Service/InventoriesUploadTest.php +++ b/src/Test/Unit/Model/Service/InventoriesUploadTest.php @@ -2,6 +2,11 @@ namespace Retailcrm\Retailcrm\Test\Unit\Model\Service; +// backward compatibility with phpunit < v.6 +if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); +} + class InventoriesUploadTest extends \PHPUnit\Framework\TestCase { private $mockApi; @@ -18,12 +23,12 @@ class InventoriesUploadTest extends \PHPUnit\Framework\TestCase 'isConfigured' ]) ->getMock(); - + $this->mockProductRepository = $this->getMockBuilder(\Magento\Catalog\Api\ProductRepositoryInterface::class) ->disableOriginalConstructor() ->setMethods(['getById']) ->getMockForAbstractClass(); - + $this->mockResponse = $this->getMockBuilder(\RetailCrm\Response\ApiResponse::class) ->disableOriginalConstructor() ->setMethods(['isSuccessful']) @@ -88,9 +93,9 @@ class InventoriesUploadTest extends \PHPUnit\Framework\TestCase } public function dataProviderLoadStocks() - { + { $response = $this->getResponseData(); - + return array( array( 'response' => $response['true'] @@ -100,7 +105,7 @@ class InventoriesUploadTest extends \PHPUnit\Framework\TestCase ) ); } - + private function getApiInventories() { return array( diff --git a/src/Test/Unit/Model/Service/OrderTest.php b/src/Test/Unit/Model/Service/OrderTest.php index 322a919..3168b99 100644 --- a/src/Test/Unit/Model/Service/OrderTest.php +++ b/src/Test/Unit/Model/Service/OrderTest.php @@ -2,6 +2,11 @@ namespace Retailcrm\Retailcrm\Test\Unit\Model\Service; +// backward compatibility with phpunit < v.6 +if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); +} + class OrderTest extends \PHPUnit\Framework\TestCase { private $mockProductRepository;