From 2cff1e1a1e71f253284e954d5970a203a8c87cc2 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 8 Apr 2020 16:07:55 +0300 Subject: [PATCH] update testings --- .gitignore | 3 ++- bin/install.sh | 18 ++++++++++++- src/Test/Helpers/FieldsetTest.php | 7 ++--- src/Test/TestCase.php | 26 +++++++++++++++++++ .../Block/Frontend/DaemonCollectorTest.php | 7 ++--- src/Test/Unit/Model/Observer/CustomerTest.php | 7 ++--- .../Unit/Model/Observer/OrderCreateTest.php | 7 ++--- .../Unit/Model/Observer/OrderUpdateTest.php | 7 ++--- src/Test/Unit/Model/Service/CustomerTest.php | 7 ++--- .../Model/Service/IntegrationModuleTest.php | 7 ++--- .../Model/Service/InventoriesUploadTest.php | 7 ++--- src/Test/Unit/Model/Service/OrderTest.php | 7 ++--- 12 files changed, 63 insertions(+), 47 deletions(-) create mode 100644 src/Test/TestCase.php diff --git a/.gitignore b/.gitignore index 14bc68c..4831ed4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/nbproject/private/ \ No newline at end of file +/nbproject/private/ +.idea diff --git a/bin/install.sh b/bin/install.sh index a6d071d..a17938c 100644 --- a/bin/install.sh +++ b/bin/install.sh @@ -15,7 +15,23 @@ magento_clone() { git clone https://github.com/magento/magento2 cd magento2 git checkout $BRANCH - composer update + + touch auth.json + echo ' + { + "http-basic": { + "repo.magento.com": { + "username": "", + "password": "" + } + } + } + ' > auth.json + + sudo sed -e "s??$PUBLIC_KEY?g" --in-place auth.json + sudo sed -e "s??$PRIVATE_KEY?g" --in-place auth.json + + composer install --no-interaction --prefer-dist composer require retailcrm/api-client-php } diff --git a/src/Test/Helpers/FieldsetTest.php b/src/Test/Helpers/FieldsetTest.php index 2fcd6ce..77797ab 100644 --- a/src/Test/Helpers/FieldsetTest.php +++ b/src/Test/Helpers/FieldsetTest.php @@ -2,12 +2,9 @@ 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'); -} +use Retailcrm\Retailcrm\Test\TestCase; -class FieldsetTest extends \PHPUnit\Framework\TestCase +class FieldsetTest extends TestCase { protected $elementMock; protected $authSessionMock; diff --git a/src/Test/TestCase.php b/src/Test/TestCase.php new file mode 100644 index 0000000..0b153a8 --- /dev/null +++ b/src/Test/TestCase.php @@ -0,0 +1,26 @@ +getMockBuilder($originalClassName) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->disableArgumentCloning() + ->getMock(); + } else { + throw new \RuntimeException('Not supported phpunit version'); + } + } +} diff --git a/src/Test/Unit/Block/Frontend/DaemonCollectorTest.php b/src/Test/Unit/Block/Frontend/DaemonCollectorTest.php index f264176..0c43b2c 100644 --- a/src/Test/Unit/Block/Frontend/DaemonCollectorTest.php +++ b/src/Test/Unit/Block/Frontend/DaemonCollectorTest.php @@ -2,12 +2,9 @@ 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'); -} +use Retailcrm\Retailcrm\Test\TestCase; -class DaemonCollectorTest extends \PHPUnit\Framework\TestCase +class DaemonCollectorTest extends TestCase { private $unit; private $customer; diff --git a/src/Test/Unit/Model/Observer/CustomerTest.php b/src/Test/Unit/Model/Observer/CustomerTest.php index 696f367..769b101 100644 --- a/src/Test/Unit/Model/Observer/CustomerTest.php +++ b/src/Test/Unit/Model/Observer/CustomerTest.php @@ -2,12 +2,9 @@ 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'); -} +use Retailcrm\Retailcrm\Test\TestCase; -class CustomerTest extends \PHPUnit\Framework\TestCase +class CustomerTest extends TestCase { private $mockApi; private $mockResponse; diff --git a/src/Test/Unit/Model/Observer/OrderCreateTest.php b/src/Test/Unit/Model/Observer/OrderCreateTest.php index 3417471..675fa34 100644 --- a/src/Test/Unit/Model/Observer/OrderCreateTest.php +++ b/src/Test/Unit/Model/Observer/OrderCreateTest.php @@ -2,15 +2,12 @@ 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'); -} +use Retailcrm\Retailcrm\Test\TestCase; /** * Order create observer test class */ -class OrderCreateTest extends \PHPUnit\Framework\TestCase +class OrderCreateTest extends TestCase { private $unit; private $mockEvent; diff --git a/src/Test/Unit/Model/Observer/OrderUpdateTest.php b/src/Test/Unit/Model/Observer/OrderUpdateTest.php index ffd0792..edfcc17 100644 --- a/src/Test/Unit/Model/Observer/OrderUpdateTest.php +++ b/src/Test/Unit/Model/Observer/OrderUpdateTest.php @@ -2,12 +2,9 @@ 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'); -} +use Retailcrm\Retailcrm\Test\TestCase; -class OrderUpdateTest extends \PHPUnit\Framework\TestCase +class OrderUpdateTest extends TestCase { private $unit; private $objectManager; diff --git a/src/Test/Unit/Model/Service/CustomerTest.php b/src/Test/Unit/Model/Service/CustomerTest.php index 4e298a4..89fb636 100644 --- a/src/Test/Unit/Model/Service/CustomerTest.php +++ b/src/Test/Unit/Model/Service/CustomerTest.php @@ -2,12 +2,9 @@ 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'); -} +use Retailcrm\Retailcrm\Test\TestCase; -class CustomerTest extends \PHPUnit\Framework\TestCase +class CustomerTest extends TestCase { private $mockData; private $mockCustomer; diff --git a/src/Test/Unit/Model/Service/IntegrationModuleTest.php b/src/Test/Unit/Model/Service/IntegrationModuleTest.php index d0e1780..ba87bed 100644 --- a/src/Test/Unit/Model/Service/IntegrationModuleTest.php +++ b/src/Test/Unit/Model/Service/IntegrationModuleTest.php @@ -2,12 +2,9 @@ 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'); -} +use Retailcrm\Retailcrm\Test\TestCase; -class IntegrationModuleTest extends \PHPUnit\Framework\TestCase +class IntegrationModuleTest extends TestCase { private $mockResourceConfig; private $mockApiClient; diff --git a/src/Test/Unit/Model/Service/InventoriesUploadTest.php b/src/Test/Unit/Model/Service/InventoriesUploadTest.php index 2300c13..e82c9fd 100644 --- a/src/Test/Unit/Model/Service/InventoriesUploadTest.php +++ b/src/Test/Unit/Model/Service/InventoriesUploadTest.php @@ -2,12 +2,9 @@ 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'); -} +use Retailcrm\Retailcrm\Test\TestCase; -class InventoriesUploadTest extends \PHPUnit\Framework\TestCase +class InventoriesUploadTest extends TestCase { private $mockApi; private $mockProductRepository; diff --git a/src/Test/Unit/Model/Service/OrderTest.php b/src/Test/Unit/Model/Service/OrderTest.php index 3168b99..5fec64c 100644 --- a/src/Test/Unit/Model/Service/OrderTest.php +++ b/src/Test/Unit/Model/Service/OrderTest.php @@ -2,12 +2,9 @@ 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'); -} +use Retailcrm\Retailcrm\Test\TestCase; -class OrderTest extends \PHPUnit\Framework\TestCase +class OrderTest extends TestCase { private $mockProductRepository; private $mockHelper;