mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-07 09:17:35 +00:00
Merge branch 'magento-commerce:2.4-develop' into gl-graphql-api-enhancements
This commit is contained in:
650 files changed
+7957
-4227
No files matched your search
@@ -46,7 +46,7 @@ class SeverityTest extends TestCase
|
||||
/** @var Column|MockObject $columnMock */
|
||||
$columnMock = $this->getMockBuilder(Column::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getIndex'])
|
||||
->addMethods(['getIndex'])
|
||||
->getMock();
|
||||
$columnMock->expects($this->exactly(5))->method('getIndex')->willReturn('index');
|
||||
$this->sut->setColumn($columnMock);
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Magento\AdminNotification\Test\Unit\Block;
|
||||
|
||||
use Magento\AdminNotification\Block\ToolbarEntry;
|
||||
use Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -26,6 +28,17 @@ class ToolbarEntryTest extends TestCase
|
||||
protected function _getBlockInstance($unreadNotifications)
|
||||
{
|
||||
$objectManagerHelper = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$objectManagerHelper->prepareObjectManager($objects);
|
||||
// mock collection of unread notifications
|
||||
$notificationList = $this->createPartialMock(
|
||||
Unread::class,
|
||||
@@ -52,6 +65,18 @@ class ToolbarEntryTest extends TestCase
|
||||
{
|
||||
$helper = new ObjectManager($this);
|
||||
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$helper->prepareObjectManager($objects);
|
||||
|
||||
// 1. Create mocks
|
||||
$notificationList = $this->createMock(Unread::class);
|
||||
|
||||
|
||||
+5
-2
@@ -225,13 +225,15 @@ class AdvancedPricingTest extends TestCase
|
||||
'initWebsites',
|
||||
'initCategories'
|
||||
];
|
||||
$mockAddMethods = [
|
||||
'_headerColumns'
|
||||
];
|
||||
$mockMethods = array_merge($constructorMethods, [
|
||||
'_customHeadersMapping',
|
||||
'_prepareEntityCollection',
|
||||
'_getEntityCollection',
|
||||
'getWriter',
|
||||
'getExportData',
|
||||
'_headerColumns',
|
||||
'_customFieldsMapping',
|
||||
'getItemsPerPage',
|
||||
'paginateCollection',
|
||||
@@ -243,7 +245,8 @@ class AdvancedPricingTest extends TestCase
|
||||
$this->advancedPricing = $this->getMockBuilder(
|
||||
AdvancedPricing::class
|
||||
)
|
||||
->setMethods($mockMethods)
|
||||
->addMethods($mockAddMethods)
|
||||
->onlyMethods($mockMethods)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
foreach ($constructorMethods as $method) {
|
||||
|
||||
@@ -67,14 +67,13 @@ class ClientResolverTest extends TestCase
|
||||
$clientOptionsMock = $this->getMockForAbstractClass(ClientOptionsInterface::class);
|
||||
|
||||
$this->objectManager->expects($this->exactly(2))->method('create')
|
||||
->withConsecutive(
|
||||
[$this->equalTo('engineFactoryClass')],
|
||||
[$this->equalTo('engineOptionClass')]
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
$factoryMock,
|
||||
$clientOptionsMock
|
||||
);
|
||||
->willReturnCallback(function ($className) use ($factoryMock, $clientOptionsMock) {
|
||||
if ($className == 'engineFactoryClass') {
|
||||
return $factoryMock;
|
||||
} elseif ($className == 'engineOptionClass') {
|
||||
return $clientOptionsMock;
|
||||
}
|
||||
});
|
||||
|
||||
$clientOptionsMock->expects($this->once())->method('prepareClientOptions')
|
||||
->with([])
|
||||
|
||||
@@ -58,12 +58,11 @@ class ConfigOptionsListTest extends TestCase
|
||||
$this->objectManager = new ObjectManager($this);
|
||||
$this->connectionValidatorMock = $this->getMockBuilder(ConnectionValidator::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->getMock();
|
||||
|
||||
$this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
|
||||
$this->model = $this->objectManager->getObject(
|
||||
@@ -171,7 +170,7 @@ class ConfigOptionsListTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCreateConfigDataProvider()
|
||||
public static function getCreateConfigDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
+2
-1
@@ -49,7 +49,8 @@ class SubscriptionStatusLabelTest extends TestCase
|
||||
$this->subscriptionStatusProviderMock = $this->createMock(SubscriptionStatusProvider::class);
|
||||
$this->contextMock = $this->createMock(Context::class);
|
||||
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
|
||||
->setMethods(['getComment', 'getElementHtml'])
|
||||
->addMethods(['getComment'])
|
||||
->onlyMethods(['getElementHtml'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ class VerticalTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
|
||||
->setMethods(['getComment', 'getLabel', 'getHint', 'getElementHtml'])
|
||||
->addMethods(['getComment', 'getLabel', 'getHint'])
|
||||
->onlyMethods(['getElementHtml'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
|
||||
@@ -100,10 +100,10 @@ class UpdateTest extends TestCase
|
||||
$this->flagManagerMock
|
||||
->expects($this->exactly(2 * $isExecuted))
|
||||
->method('deleteFlag')
|
||||
->withConsecutive(
|
||||
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE],
|
||||
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE]
|
||||
);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE] => $this->flagManagerMock,
|
||||
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE] => $this->flagManagerMock
|
||||
});
|
||||
$this->configWriterMock
|
||||
->expects($this->exactly((int)$isExecuted))
|
||||
->method('delete')
|
||||
@@ -143,7 +143,7 @@ class UpdateTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function executeWithEmptyReverseCounterDataProvider()
|
||||
public static function executeWithEmptyReverseCounterDataProvider()
|
||||
{
|
||||
return [
|
||||
[null],
|
||||
@@ -189,7 +189,7 @@ class UpdateTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function executeRegularScenarioDataProvider()
|
||||
public static function executeRegularScenarioDataProvider()
|
||||
{
|
||||
return [
|
||||
'The last attempt with command execution result False' => [
|
||||
|
||||
+17
-8
@@ -126,10 +126,15 @@ class SubscriptionUpdateHandlerTest extends TestCase
|
||||
$this->flagManagerMock
|
||||
->expects($this->once())
|
||||
->method('saveFlag')
|
||||
->withConsecutive(
|
||||
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue],
|
||||
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url]
|
||||
);
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($url) {
|
||||
if ($arg1 == SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE
|
||||
&& $arg2 == $this->attemptsInitValue) {
|
||||
return true;
|
||||
} elseif ($arg1 == SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE && $arg2 == $url) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$this->configWriterMock
|
||||
->expects($this->once())
|
||||
->method('save')
|
||||
@@ -160,10 +165,14 @@ class SubscriptionUpdateHandlerTest extends TestCase
|
||||
$this->flagManagerMock
|
||||
->expects($this->exactly(2))
|
||||
->method('saveFlag')
|
||||
->withConsecutive(
|
||||
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url],
|
||||
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue]
|
||||
);
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($url) {
|
||||
if ($arg1 == SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE
|
||||
&& $arg2 == $this->attemptsInitValue) {
|
||||
return true;
|
||||
} elseif ($arg1 == SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE && $arg2 == $url) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
$this->configWriterMock
|
||||
->expects($this->once())
|
||||
->method('save')
|
||||
|
||||
@@ -132,26 +132,18 @@ class ExportDataHandlerTest extends TestCase
|
||||
$this->directoryMock
|
||||
->expects($this->exactly(4))
|
||||
->method('delete')
|
||||
->withConsecutive(
|
||||
[$tmpFilesDirectoryPath],
|
||||
[$archiveRelativePath]
|
||||
);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[$tmpFilesDirectoryPath] => true,
|
||||
[$archiveRelativePath] => true
|
||||
});
|
||||
|
||||
$this->directoryMock
|
||||
->expects($this->exactly(4))
|
||||
->method('getAbsolutePath')
|
||||
->withConsecutive(
|
||||
[$tmpFilesDirectoryPath],
|
||||
[$tmpFilesDirectoryPath],
|
||||
[$archiveRelativePath],
|
||||
[$archiveRelativePath]
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
$archiveSource,
|
||||
$archiveSource,
|
||||
$archiveAbsolutePath,
|
||||
$archiveAbsolutePath
|
||||
);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[$tmpFilesDirectoryPath] => $archiveSource,
|
||||
[$archiveRelativePath] => $archiveAbsolutePath
|
||||
});
|
||||
|
||||
$this->reportWriterMock
|
||||
->expects($this->once())
|
||||
@@ -161,14 +153,10 @@ class ExportDataHandlerTest extends TestCase
|
||||
$this->directoryMock
|
||||
->expects($this->exactly(2))
|
||||
->method('isExist')
|
||||
->withConsecutive(
|
||||
[$tmpFilesDirectoryPath],
|
||||
[$archiveRelativePath]
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
true,
|
||||
true
|
||||
);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[$tmpFilesDirectoryPath] => true,
|
||||
[$archiveRelativePath] => true
|
||||
});
|
||||
|
||||
$this->directoryMock
|
||||
->expects($this->once())
|
||||
@@ -208,7 +196,7 @@ class ExportDataHandlerTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function prepareExportDataDataProvider()
|
||||
public static function prepareExportDataDataProvider()
|
||||
{
|
||||
return [
|
||||
'Data source for archive is directory' => [true],
|
||||
@@ -237,11 +225,10 @@ class ExportDataHandlerTest extends TestCase
|
||||
$this->directoryMock
|
||||
->expects($this->exactly(3))
|
||||
->method('delete')
|
||||
->withConsecutive(
|
||||
[$tmpFilesDirectoryPath],
|
||||
[$tmpFilesDirectoryPath],
|
||||
[$archivePath]
|
||||
);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[$tmpFilesDirectoryPath] => true,
|
||||
[$archivePath] => true
|
||||
});
|
||||
$this->directoryMock
|
||||
->expects($this->exactly(2))
|
||||
->method('getAbsolutePath')
|
||||
|
||||
@@ -47,7 +47,8 @@ class BaseUrlConfigPluginTest extends TestCase
|
||||
$this->subscriptionUpdateHandlerMock = $this->createMock(SubscriptionUpdateHandler::class);
|
||||
$this->configValueMock = $this->getMockBuilder(Value::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['isValueChanged', 'getPath', 'getScope', 'getOldValue'])
|
||||
->addMethods(['getPath', 'getScope'])
|
||||
->onlyMethods(['isValueChanged', 'getOldValue'])
|
||||
->getMock();
|
||||
$this->objectManagerHelper = new ObjectManagerHelper($this);
|
||||
$this->plugin = $this->objectManagerHelper->getObject(
|
||||
@@ -88,7 +89,7 @@ class BaseUrlConfigPluginTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function afterSavePluginIsNotApplicableDataProvider()
|
||||
public static function afterSavePluginIsNotApplicableDataProvider()
|
||||
{
|
||||
return [
|
||||
'Value has not been changed' => [
|
||||
|
||||
@@ -61,17 +61,17 @@ class ReportWriterTest extends TestCase
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $reportName = 'testReport';
|
||||
private static $reportName = 'testReport';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $providerName = 'testProvider';
|
||||
private static $providerName = 'testProvider';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $providerClass = 'Magento\Analytics\Provider';
|
||||
private static $providerClass = 'Magento\Analytics\Provider';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
@@ -116,7 +116,7 @@ class ReportWriterTest extends TestCase
|
||||
$this->providerFactoryMock
|
||||
->expects($this->once())
|
||||
->method('create')
|
||||
->with($this->providerClass)
|
||||
->with(self::$providerClass)
|
||||
->willReturn($this->reportProviderMock);
|
||||
$parameterName = isset(reset($configData)[0]['parameters']['name'])
|
||||
? reset($configData)[0]['parameters']['name']
|
||||
@@ -135,10 +135,16 @@ class ReportWriterTest extends TestCase
|
||||
$errorStreamMock
|
||||
->expects($this->exactly(2))
|
||||
->method('writeCsv')
|
||||
->withConsecutive(
|
||||
[array_keys($expectedFileData[0])],
|
||||
[$expectedFileData[0]]
|
||||
);
|
||||
->willReturnCallback(function (...$args) use ($expectedFileData) {
|
||||
static $index = 0;
|
||||
$expectedArgs = [
|
||||
[array_keys($expectedFileData[0])],
|
||||
[$expectedFileData[0]]
|
||||
];
|
||||
$index++;
|
||||
return $args === $expectedArgs[$index - 1] ? null : null;
|
||||
});
|
||||
|
||||
$errorStreamMock->expects($this->once())->method('unlock');
|
||||
$errorStreamMock->expects($this->once())->method('close');
|
||||
if ($parameterName) {
|
||||
@@ -195,15 +201,15 @@ class ReportWriterTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function writeDataProvider(): array
|
||||
public static function writeDataProvider(): array
|
||||
{
|
||||
$configData = [
|
||||
'providers' => [
|
||||
[
|
||||
'name' => $this->providerName,
|
||||
'class' => $this->providerClass,
|
||||
'name' => self::$providerName,
|
||||
'class' => self::$providerClass,
|
||||
'parameters' => [
|
||||
'name' => $this->reportName
|
||||
'name' => self::$reportName
|
||||
],
|
||||
]
|
||||
]
|
||||
@@ -260,17 +266,17 @@ class ReportWriterTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function writeErrorFileDataProvider(): array
|
||||
public static function writeErrorFileDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'configData' => [
|
||||
'providers' => [
|
||||
[
|
||||
'name' => $this->providerName,
|
||||
'class' => $this->providerClass,
|
||||
'name' => self::$providerName,
|
||||
'class' => self::$providerClass,
|
||||
'parameters' => [
|
||||
'name' => $this->reportName
|
||||
'name' => self::$reportName
|
||||
],
|
||||
]
|
||||
]
|
||||
|
||||
@@ -134,14 +134,13 @@ class JoinAssemblerTest extends TestCase
|
||||
|
||||
$this->nameResolverMock
|
||||
->method('getAlias')
|
||||
->withConsecutive(
|
||||
[$queryConfigMock['source']],
|
||||
[$queryConfigMock['source']['link-source'][0]]
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
$queryConfigMock['source']['alias'],
|
||||
$queryConfigMock['source']['link-source'][0]['alias']
|
||||
);
|
||||
->willReturnCallback(function ($arg1) use ($queryConfigMock) {
|
||||
if ($arg1 == $queryConfigMock['source']) {
|
||||
return $queryConfigMock['source']['alias'];
|
||||
} elseif ($arg1 == $queryConfigMock['source']['link-source'][0]) {
|
||||
return $queryConfigMock['source']['link-source'][0]['alias'];
|
||||
}
|
||||
});
|
||||
$this->nameResolverMock->expects($this->once())
|
||||
->method('getName')
|
||||
->with($queryConfigMock['source']['link-source'][0])
|
||||
@@ -192,8 +191,12 @@ class JoinAssemblerTest extends TestCase
|
||||
}
|
||||
$this->conditionResolverMock
|
||||
->method('getFilter')
|
||||
->withConsecutive(...$withArgs)
|
||||
->willReturnOnConsecutiveCalls(...$willReturnArgs);
|
||||
->willReturnCallback(function ($withArgs) use ($willReturnArgs) {
|
||||
static $callCount = 0;
|
||||
$returnValue = $willReturnArgs[$callCount] ?? null;
|
||||
$callCount++;
|
||||
return $returnValue;
|
||||
});
|
||||
|
||||
$this->selectBuilderMock->expects($this->once())
|
||||
->method('setFilters')
|
||||
@@ -211,7 +214,7 @@ class JoinAssemblerTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function assembleNotEmptyDataProvider(): array
|
||||
public static function assembleNotEmptyDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -48,6 +48,10 @@ class SelectHydratorTest extends TestCase
|
||||
*/
|
||||
private $objectManagerHelper;
|
||||
|
||||
/**
|
||||
* @var expressionMock
|
||||
*/
|
||||
private static $expressionMock;
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
@@ -70,6 +74,8 @@ class SelectHydratorTest extends TestCase
|
||||
'objectManager' => $this->objectManagerMock
|
||||
]
|
||||
);
|
||||
|
||||
self::$expressionMock = $this->createMock(\JsonSerializable::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +131,9 @@ class SelectHydratorTest extends TestCase
|
||||
}
|
||||
$this->selectMock
|
||||
->method('setPart')
|
||||
->withConsecutive(...$withArgs);
|
||||
->willReturnCallback(function (...$withArgs) {
|
||||
return null;
|
||||
});
|
||||
|
||||
$this->assertSame($this->selectMock, $this->selectHydrator->recreate($selectParts));
|
||||
}
|
||||
@@ -133,7 +141,7 @@ class SelectHydratorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function recreateWithoutExpressionDataProvider(): array
|
||||
public static function recreateWithoutExpressionDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'Select without expressions' => [
|
||||
@@ -203,7 +211,9 @@ class SelectHydratorTest extends TestCase
|
||||
}
|
||||
$this->selectMock
|
||||
->method('setPart')
|
||||
->withConsecutive(...$withArgs);
|
||||
->willReturnCallback(function (...$withArgs) {
|
||||
return null;
|
||||
});
|
||||
|
||||
$this->assertSame($this->selectMock, $this->selectHydrator->recreate($selectParts));
|
||||
}
|
||||
@@ -211,9 +221,8 @@ class SelectHydratorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function recreateWithExpressionDataProvider(): array
|
||||
public static function recreateWithExpressionDataProvider(): array
|
||||
{
|
||||
$expressionMock = $this->createMock(\JsonSerializable::class);
|
||||
|
||||
return [
|
||||
'Select without expressions' => [
|
||||
@@ -245,13 +254,13 @@ class SelectHydratorTest extends TestCase
|
||||
],
|
||||
[
|
||||
'table_name',
|
||||
$expressionMock,
|
||||
self::$expressionMock,
|
||||
'alias_2'
|
||||
]
|
||||
]
|
||||
],
|
||||
'expectedExpressions' => [
|
||||
$expressionMock
|
||||
self::$expressionMock
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
+6
-3
@@ -52,8 +52,11 @@ class DoneButtonTest extends TestCase
|
||||
$uuid = 'some standard uuid string';
|
||||
$this->requestMock->expects($this->exactly(2))
|
||||
->method('getParam')
|
||||
->withConsecutive(['uuid'], ['buttons'])
|
||||
->willReturnOnConsecutiveCalls($uuid, $buttonsParam);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['uuid'] => $uuid,
|
||||
['buttons'] => $buttonsParam,
|
||||
});
|
||||
|
||||
$this->bulkStatusMock->expects($this->once())
|
||||
->method('getOperationsCountByBulkIdAndStatus')
|
||||
->with($uuid, OperationInterface::STATUS_TYPE_RETRIABLY_FAILED)
|
||||
@@ -65,7 +68,7 @@ class DoneButtonTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonDataProvider()
|
||||
public static function getButtonDataProvider()
|
||||
{
|
||||
return [
|
||||
[1, 0, []],
|
||||
|
||||
@@ -147,7 +147,18 @@ class BulkManagementTest extends TestCase
|
||||
$operation->expects($this->exactly(2))->method('getTopicName')
|
||||
->willReturnOnConsecutiveCalls($topicNames[0], $topicNames[1]);
|
||||
$this->publisher->expects($this->exactly(2))->method('publish')
|
||||
->withConsecutive([$topicNames[0], [$operation]], [$topicNames[1], [$operation]])->willReturn(null);
|
||||
->willReturnCallback(function (...$args) use ($topicNames, $operation) {
|
||||
static $index = 0;
|
||||
$expectedArgs = [
|
||||
[$topicNames[0], [$operation]],
|
||||
[$topicNames[1], [$operation]]
|
||||
];
|
||||
$index++;
|
||||
if ($args === $expectedArgs[$index - 1]) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
$this->assertTrue(
|
||||
$this->bulkManagement->scheduleBulk($bulkUuid, [$operation, $operation], $description, $userId)
|
||||
);
|
||||
@@ -290,8 +301,14 @@ class BulkManagementTest extends TestCase
|
||||
$operationCollection = $this->createMock(Collection::class);
|
||||
$this->operationCollectionFactory->expects($this->once())->method('create')->willReturn($operationCollection);
|
||||
$operationCollection->expects($this->exactly(2))->method('addFieldToFilter')
|
||||
->withConsecutive(['bulk_uuid', ['eq' => $bulkUuid]], ['error_code', ['in' => $errorCodes]])
|
||||
->willReturnSelf();
|
||||
->willReturnCallback(function ($key, $value) use ($bulkUuid, $errorCodes, $operationCollection) {
|
||||
if ($key == 'bulk_uuid' && $value == ['eq' => $bulkUuid]) {
|
||||
return $operationCollection;
|
||||
} elseif ($key == 'error_code' && $value == ['in' => $errorCodes]) {
|
||||
return $operationCollection;
|
||||
}
|
||||
});
|
||||
|
||||
$operation = $this->getMockBuilder(Operation::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
@@ -335,8 +352,13 @@ class BulkManagementTest extends TestCase
|
||||
$operationCollection = $this->createMock(Collection::class);
|
||||
$this->operationCollectionFactory->expects($this->once())->method('create')->willReturn($operationCollection);
|
||||
$operationCollection->expects($this->exactly(2))->method('addFieldToFilter')
|
||||
->withConsecutive(['bulk_uuid', ['eq' => $bulkUuid]], ['error_code', ['in' => $errorCodes]])
|
||||
->willReturnSelf();
|
||||
->willReturnCallback(function ($key, $value) use ($bulkUuid, $errorCodes, $operationCollection) {
|
||||
if ($key == 'bulk_uuid' && $value == ['eq' => $bulkUuid]) {
|
||||
return $operationCollection;
|
||||
} elseif ($key == 'error_code' && $value == ['in' => $errorCodes]) {
|
||||
return $operationCollection;
|
||||
}
|
||||
});
|
||||
$operation = $this->getMockBuilder(Operation::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
|
||||
@@ -118,8 +118,13 @@ class BulkStatusTest extends TestCase
|
||||
$this->operationCollectionFactory->expects($this->once())->method('create')->willReturn($operationCollection);
|
||||
$operationCollection
|
||||
->method('addFieldToFilter')
|
||||
->withConsecutive(['bulk_uuid', $bulkUuid], ['status', $failureCodes])
|
||||
->willReturnOnConsecutiveCalls($operationCollection, $operationCollection);
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($bulkUuid, $operationCollection, $failureCodes) {
|
||||
if ($arg1 == 'bulk_uuid' && $arg2 == $bulkUuid) {
|
||||
return $operationCollection;
|
||||
} elseif ($arg1 == 'status' && $arg2 == $failureCodes) {
|
||||
return $operationCollection;
|
||||
}
|
||||
});
|
||||
$operationCollection->expects($this->once())->method('getItems')->willReturn([$this->operationMock]);
|
||||
$this->assertEquals([$this->operationMock], $this->model->getFailedOperationsByBulkId($bulkUuid, $failureType));
|
||||
}
|
||||
@@ -137,8 +142,13 @@ class BulkStatusTest extends TestCase
|
||||
$this->operationCollectionFactory->expects($this->once())->method('create')->willReturn($operationCollection);
|
||||
$operationCollection
|
||||
->method('addFieldToFilter')
|
||||
->withConsecutive(['bulk_uuid', $bulkUuid], ['status', $status])
|
||||
->willReturnOnConsecutiveCalls($operationCollection, $operationCollection);
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($bulkUuid, $operationCollection, $status) {
|
||||
if ($arg1 == 'bulk_uuid' && $arg2 == $bulkUuid) {
|
||||
return $operationCollection;
|
||||
} elseif ($arg1 == 'status' && $arg2 == $status) {
|
||||
return $operationCollection;
|
||||
}
|
||||
});
|
||||
$operationCollection
|
||||
->expects($this->once())
|
||||
->method('getSize')
|
||||
@@ -163,12 +173,13 @@ class BulkStatusTest extends TestCase
|
||||
$operationCollection
|
||||
->expects($this->exactly(3))
|
||||
->method('addFieldToFilter')
|
||||
->withConsecutive(
|
||||
['bulk_uuid', $bulkUuid],
|
||||
['bulk_uuid', $bulkUuid],
|
||||
['status', $status]
|
||||
)
|
||||
->willReturnSelf();
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($bulkUuid, $operationCollection, $status) {
|
||||
if ($arg1 == 'bulk_uuid' && $arg2 == $bulkUuid) {
|
||||
return $operationCollection;
|
||||
} elseif ($arg1 == 'status' && $arg2 == $status) {
|
||||
return $operationCollection;
|
||||
}
|
||||
});
|
||||
$operationCollection
|
||||
->expects($this->exactly(2))
|
||||
->method('getSize')
|
||||
@@ -247,7 +258,7 @@ class BulkStatusTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFailedOperationsByBulkIdDataProvider(): array
|
||||
public static function getFailedOperationsByBulkIdDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[1, [1]],
|
||||
@@ -322,8 +333,13 @@ class BulkStatusTest extends TestCase
|
||||
|
||||
$completeOperationCollection
|
||||
->method('addFieldToFilter')
|
||||
->withConsecutive(['bulk_uuid', $bulkUuid], ['status', OperationInterface::STATUS_TYPE_COMPLETE])
|
||||
->willReturnOnConsecutiveCalls($completeOperationCollection, $completeOperationCollection);
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($bulkUuid, $completeOperationCollection) {
|
||||
if ($arg1 == 'bulk_uuid' && $arg2 == $bulkUuid) {
|
||||
return $completeOperationCollection;
|
||||
} elseif ($arg1 == 'status' && $arg2 == OperationInterface::STATUS_TYPE_COMPLETE) {
|
||||
return $completeOperationCollection;
|
||||
}
|
||||
});
|
||||
$completeOperationCollection->method('getSize')->willReturn(5);
|
||||
$this->assertEquals(BulkSummaryInterface::IN_PROGRESS, $this->model->getBulkStatus($bulkUuid));
|
||||
}
|
||||
|
||||
+2
-2
@@ -88,7 +88,7 @@ class CreateTest extends TestCase
|
||||
->method('getConnection')->with($connectionName)->willReturn($connection);
|
||||
$connection->expects($this->once())->method('beginTransaction')->willReturnSelf();
|
||||
$operation = $this->getMockBuilder(OperationInterface::class)
|
||||
->setMethods(['getData'])
|
||||
->addMethods(['getData'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$operationList->expects($this->once())->method('getItems')->willReturn([$operation]);
|
||||
@@ -123,7 +123,7 @@ class CreateTest extends TestCase
|
||||
->method('getConnection')->with($connectionName)->willReturn($connection);
|
||||
$connection->expects($this->once())->method('beginTransaction')->willReturnSelf();
|
||||
$operation = $this->getMockBuilder(OperationInterface::class)
|
||||
->setMethods(['getData'])
|
||||
->addMethods(['getData'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$operationList->expects($this->once())->method('getItems')->willReturn([$operation]);
|
||||
|
||||
@@ -155,10 +155,16 @@ class RoleTest extends TestCase
|
||||
$aclMock = $this->createMock(Acl::class);
|
||||
$aclMock
|
||||
->method('addRole')
|
||||
->withConsecutive(
|
||||
[$this->anything(), null],
|
||||
[$this->anything(), '1']
|
||||
);
|
||||
->willReturnCallback(function (...$args) {
|
||||
static $index = 0;
|
||||
$expectedArgs = [
|
||||
[$this->anything(), null],
|
||||
[$this->anything(), '1']
|
||||
];
|
||||
$returnValue = null;
|
||||
$index++;
|
||||
return $args === $expectedArgs[$index - 1] ? $returnValue : null;
|
||||
});
|
||||
|
||||
$this->model->populateAcl($aclMock);
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ class RuleTest extends TestCase
|
||||
* Test populating acl rule from cache.
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function testPopulateAclFromCache(): void
|
||||
{
|
||||
@@ -117,17 +118,23 @@ class RuleTest extends TestCase
|
||||
$aclMock->method('hasResource')->willReturn(true);
|
||||
$aclMock
|
||||
->method('allow')
|
||||
->withConsecutive(
|
||||
['1', null, null],
|
||||
['1', 'Magento_Backend::all', null],
|
||||
['2', 1, null]
|
||||
);
|
||||
->willReturnCallback(function ($arg1, $arg2, $arg3) {
|
||||
if ($arg1 == '1' && $arg2 === null && $arg3 === null) {
|
||||
return null;
|
||||
} elseif ($arg1 == '1' && $arg2 == 'Magento_Backend::all' && $arg3 === null) {
|
||||
return null;
|
||||
} elseif ($arg1 == '2' && $arg2 == 1 && $arg3 === null) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
$aclMock
|
||||
->method('deny')
|
||||
->withConsecutive(
|
||||
['3', 1, null]
|
||||
);
|
||||
->willReturnCallback(function ($arg1, $arg2, $arg3) {
|
||||
if ($arg1 == '3' && $arg2 == 1 && is_null($arg3)) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
$aclMock
|
||||
->method('getResources')
|
||||
|
||||
@@ -35,7 +35,7 @@ class RulesTest extends TestCase
|
||||
/**
|
||||
* Test constants
|
||||
*/
|
||||
const TEST_ROLE_ID = 13;
|
||||
private const TEST_ROLE_ID = 13;
|
||||
|
||||
/**
|
||||
* @var Rules
|
||||
@@ -89,12 +89,12 @@ class RulesTest extends TestCase
|
||||
{
|
||||
$this->contextMock = $this->getMockBuilder(Context::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getResources'])
|
||||
->onlyMethods(['getResources'])
|
||||
->getMock();
|
||||
|
||||
$this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getConnection', 'getTableName'])
|
||||
->onlyMethods(['getConnection', 'getTableName'])
|
||||
->getMock();
|
||||
|
||||
$this->contextMock->expects($this->once())
|
||||
@@ -103,7 +103,7 @@ class RulesTest extends TestCase
|
||||
|
||||
$this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->resourceConnectionMock->expects($this->once())
|
||||
@@ -117,22 +117,22 @@ class RulesTest extends TestCase
|
||||
|
||||
$this->aclBuilderMock = $this->getMockBuilder(Builder::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getConfigCache'])
|
||||
->addMethods(['getConfigCache'])
|
||||
->getMock();
|
||||
|
||||
$this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->rootResourceMock = $this->getMockBuilder(RootResource::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
|
||||
$this->aclDataCacheMock = $this->getMockBuilder(CacheInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->aclBuilderMock->method('getConfigCache')
|
||||
@@ -140,7 +140,7 @@ class RulesTest extends TestCase
|
||||
|
||||
$this->rulesModelMock = $this->getMockBuilder(RulesModel::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getRoleId'])
|
||||
->addMethods(['getRoleId'])
|
||||
->getMock();
|
||||
|
||||
$this->rulesModelMock->method('getRoleId')
|
||||
@@ -189,7 +189,7 @@ class RulesTest extends TestCase
|
||||
|
||||
$exceptionPhrase = $this->getMockBuilder(Phrase::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['render'])
|
||||
->onlyMethods(['render'])
|
||||
->getMock();
|
||||
|
||||
$exceptionPhrase->method('render')->willReturn('TestException');
|
||||
|
||||
@@ -70,8 +70,10 @@ class MassactionKeyTest extends TestCase
|
||||
): void {
|
||||
$this->requestMock
|
||||
->method('getPost')
|
||||
->withConsecutive(['massaction_prepare_key'], ['key'])
|
||||
->willReturnOnConsecutiveCalls('key', $postData);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['massaction_prepare_key'] => 'key',
|
||||
['key'] => $postData
|
||||
});
|
||||
$this->requestMock->expects($this->once())
|
||||
->method('setPostValue')
|
||||
->with('key', $convertedData);
|
||||
@@ -82,7 +84,7 @@ class MassactionKeyTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function beforeDispatchDataProvider(): array
|
||||
public static function beforeDispatchDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'post_data_is_array' => [['key'], ['key']],
|
||||
|
||||
@@ -84,8 +84,10 @@ class FrontNameResolverTest extends TestCase
|
||||
{
|
||||
$this->configMock
|
||||
->method('getValue')
|
||||
->withConsecutive(['admin/url/use_custom_path'], ['admin/url/custom_path'])
|
||||
->willReturnOnConsecutiveCalls(true, 'expectedValue');
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['admin/url/use_custom_path'] => true,
|
||||
['admin/url/custom_path'] => 'expectedValue'
|
||||
});
|
||||
$this->assertEquals('expectedValue', $this->model->getFrontName());
|
||||
}
|
||||
|
||||
@@ -200,7 +202,7 @@ class FrontNameResolverTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function hostsDataProvider(): array
|
||||
public static function hostsDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'withoutPort' => [
|
||||
|
||||
@@ -15,6 +15,7 @@ use Magento\Framework\App\Response\Http;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Magento\Framework\App\Response\FileFactory;
|
||||
|
||||
class FileFactoryTest extends TestCase
|
||||
{
|
||||
@@ -46,6 +47,14 @@ class FileFactoryTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$helper = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
FileFactory::class,
|
||||
$this->createMock(FileFactory::class)
|
||||
]
|
||||
];
|
||||
$helper->prepareObjectManager($objects);
|
||||
|
||||
$this->_responseMock = $this->createPartialMock(
|
||||
Http::class,
|
||||
['setRedirect', '__wakeup']
|
||||
|
||||
@@ -21,6 +21,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHe
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class MenuTest extends TestCase
|
||||
{
|
||||
/**
|
||||
@@ -73,6 +76,8 @@ class MenuTest extends TestCase
|
||||
->getMock();
|
||||
|
||||
$objectManagerHelper = new ObjectManagerHelper($this);
|
||||
$objectManagerHelper->prepareObjectManager();
|
||||
|
||||
$this->menu = $objectManagerHelper->getObject(
|
||||
Menu::class,
|
||||
[
|
||||
|
||||
@@ -14,11 +14,13 @@ use Magento\Backend\Block\Page\System\Config\Robots\Reset;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\View\Helper\SecureHtmlRenderer;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @deprecated Original class is deprecated
|
||||
* @see Reset
|
||||
*/
|
||||
class ResetTest extends TestCase
|
||||
{
|
||||
@@ -37,6 +39,13 @@ class ResetTest extends TestCase
|
||||
$this->configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
|
||||
|
||||
$objectHelper = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
SecureHtmlRenderer::class,
|
||||
$this->createMock(SecureHtmlRenderer::class)
|
||||
]
|
||||
];
|
||||
$objectHelper->prepareObjectManager($objects);
|
||||
$context = $objectHelper->getObject(
|
||||
Context::class,
|
||||
['scopeConfig' => $this->configMock]
|
||||
|
||||
@@ -8,6 +8,8 @@ declare(strict_types=1);
|
||||
namespace Magento\Backend\Test\Unit\Block\Widget\Button;
|
||||
|
||||
use Magento\Backend\Block\Widget\Button\SplitButton;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -16,6 +18,17 @@ class SplitTest extends TestCase
|
||||
public function testHasSplit()
|
||||
{
|
||||
$objectManagerHelper = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$objectManagerHelper->prepareObjectManager($objects);
|
||||
/** @var SplitButton $block */
|
||||
$block = $objectManagerHelper->getObject(SplitButton::class);
|
||||
$this->assertTrue($block->hasSplit());
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Magento\Backend\Test\Unit\Block\Widget;
|
||||
|
||||
use Magento\Backend\Block\Widget\Button;
|
||||
use Magento\Backend\Model\Url;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\View\Layout;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
@@ -49,6 +51,18 @@ class ButtonTest extends TestCase
|
||||
];
|
||||
|
||||
$objectManagerHelper = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$objectManagerHelper->prepareObjectManager($objects);
|
||||
|
||||
$this->_blockMock = $objectManagerHelper->getObject(Button::class, $arguments);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,11 @@ namespace Magento\Backend\Test\Unit\Block\Widget;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form;
|
||||
use Magento\Backend\Block\Widget\Form\Element\ElementCreator;
|
||||
use Magento\Framework\Data\Form as DataForm;
|
||||
use Magento\Framework\Json\Helper\Data;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -28,19 +32,38 @@ class FormTest extends TestCase
|
||||
/** @var UrlInterface|MockObject */
|
||||
protected $urlBuilder;
|
||||
|
||||
/** @var Data */
|
||||
protected $jsonHelperMock;
|
||||
|
||||
/** @var ElementCreator */
|
||||
protected $creatorStub;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->prepareContext();
|
||||
|
||||
$this->dataForm = $this->getMockBuilder(\Magento\Framework\Data\Form::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([
|
||||
->addMethods([
|
||||
'setParent',
|
||||
'setBaseUrl',
|
||||
'addCustomAttribute',
|
||||
'setBaseUrl'
|
||||
])
|
||||
->onlyMethods(['addCustomAttribute'])
|
||||
->getMock();
|
||||
|
||||
$this->jsonHelperMock = $this->getMockBuilder(Data::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
/** @var ObjectManagerInterface|MockObject $objectManagerMock */
|
||||
$objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
|
||||
$objectManagerMock->expects($this->exactly(3))
|
||||
->method('get')
|
||||
->willReturn($this->jsonHelperMock);
|
||||
ObjectManager::setInstance($objectManagerMock);
|
||||
|
||||
$this->creatorStub = $this->createMock(ElementCreator::class);
|
||||
|
||||
$this->model = new Form(
|
||||
$this->context
|
||||
);
|
||||
|
||||
@@ -66,28 +66,26 @@ class DateTest extends TestCase
|
||||
{
|
||||
$this->mathRandomMock = $this->getMockBuilder(Random::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getUniqueHash'])
|
||||
->onlyMethods(['getUniqueHash'])
|
||||
->getMock();
|
||||
|
||||
$this->localeResolverMock = $this->getMockBuilder(ResolverInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->dateTimeFormatterMock = $this
|
||||
->getMockBuilder(DateTimeFormatterInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->columnMock = $this->getMockBuilder(Column::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getTimezone', 'getHtmlId', 'getId'])
|
||||
->addMethods(['getTimezone'])
|
||||
->onlyMethods(['getHtmlId', 'getId'])
|
||||
->getMock();
|
||||
|
||||
$this->localeDateMock = $this->getMockBuilder(TimezoneInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->escaperMock = $this->getMockBuilder(Escaper::class)
|
||||
@@ -111,7 +109,7 @@ class DateTest extends TestCase
|
||||
|
||||
$this->repositoryMock = $this->getMockBuilder(Repository::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getUrlWithParams'])
|
||||
->onlyMethods(['getUrlWithParams'])
|
||||
->getMock();
|
||||
|
||||
$this->contextMock->expects($this->once())
|
||||
|
||||
@@ -66,28 +66,29 @@ class DatetimeTest extends TestCase
|
||||
{
|
||||
$this->mathRandomMock = $this->getMockBuilder(Random::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getUniqueHash'])
|
||||
->onlyMethods(['getUniqueHash'])
|
||||
->getMock();
|
||||
|
||||
$this->localeResolverMock = $this->getMockBuilder(ResolverInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->dateTimeFormatterMock = $this
|
||||
->getMockBuilder(DateTimeFormatterInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->columnMock = $this->getMockBuilder(Column::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getTimezone', 'getHtmlId', 'getId', 'getFilterTime'])
|
||||
->addMethods(['getTimezone','getFilterTime'])
|
||||
->onlyMethods(['getHtmlId', 'getId'])
|
||||
->getMock();
|
||||
|
||||
$this->localeDateMock = $this->getMockBuilder(TimezoneInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->escaperMock = $this->getMockBuilder(Escaper::class)
|
||||
@@ -111,7 +112,7 @@ class DatetimeTest extends TestCase
|
||||
|
||||
$this->repositoryMock = $this->getMockBuilder(Repository::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getUrlWithParams'])
|
||||
->onlyMethods(['getUrlWithParams'])
|
||||
->getMock();
|
||||
|
||||
$this->contextMock->expects($this->once())
|
||||
|
||||
+4
-3
@@ -38,12 +38,13 @@ class AbstractRendererTest extends TestCase
|
||||
$this->dataObjectMock = $this->createPartialMock(DataObject::class, ['getData']);
|
||||
$this->columnMock = $this->getMockBuilder(Column::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getEditable', 'getIndex', 'getEditOnly', 'getId'])
|
||||
->addMethods(['getEditable', 'getIndex', 'getEditOnly'])
|
||||
->onlyMethods(['getId'])
|
||||
->getMock();
|
||||
$this->renderer =
|
||||
$this->getMockBuilder(AbstractRenderer::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(null)
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ class AbstractRendererTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function renderDataProvider()
|
||||
public static function renderDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -103,7 +103,7 @@ class ColumnTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSortableDataProvider()
|
||||
public static function getSortableDataProvider()
|
||||
{
|
||||
return ['zero' => ['0'], 'false' => [false], 'null' => [null]];
|
||||
}
|
||||
@@ -394,7 +394,7 @@ class ColumnTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columnGroupedDataProvider()
|
||||
public static function columnGroupedDataProvider()
|
||||
{
|
||||
return [[[], false], [['grouped' => 0], false], [['grouped' => 1], true]];
|
||||
}
|
||||
@@ -408,7 +408,7 @@ class ColumnTest extends TestCase
|
||||
/** @var $rendererMock */
|
||||
$rendererMock = $this->getMockBuilder(AbstractRenderer::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['renderExport', 'render'])
|
||||
->onlyMethods(['renderExport', 'render'])
|
||||
->getMock();
|
||||
|
||||
$rendererMock->expects($this->any())->method('renderExport')->willReturnCallback(
|
||||
@@ -425,7 +425,7 @@ class ColumnTest extends TestCase
|
||||
|
||||
$frameCallbackHostObject = $this->getMockBuilder(Widget::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['decorate'])
|
||||
->addMethods(['decorate'])
|
||||
->getMock();
|
||||
|
||||
$frameCallbackHostObject->expects($this->any())
|
||||
@@ -452,7 +452,7 @@ class ColumnTest extends TestCase
|
||||
/** @var $rendererMock */
|
||||
$rendererMock = $this->getMockBuilder(AbstractRenderer::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['renderExport', 'render'])
|
||||
->onlyMethods(['renderExport', 'render'])
|
||||
->getMock();
|
||||
|
||||
$rendererMock->expects($this->any())->method('renderExport')->willReturnCallback(
|
||||
@@ -474,7 +474,7 @@ class ColumnTest extends TestCase
|
||||
/** @var $rendererMock */
|
||||
$rendererMock = $this->getMockBuilder(AbstractRenderer::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['render'])
|
||||
->onlyMethods(['render'])
|
||||
->getMock();
|
||||
|
||||
$rendererMock->expects($this->any())->method('render')->willReturnCallback(
|
||||
|
||||
@@ -12,8 +12,10 @@ namespace Magento\Backend\Test\Unit\Block\Widget\Grid;
|
||||
|
||||
use Magento\Backend\Block\Widget\Grid\ColumnSet;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\App\Request\Http;
|
||||
use Magento\Framework\Data\Collection;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\View\Layout;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -28,6 +30,17 @@ class ExtendedTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->_objectManager = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$this->_objectManager->prepareObjectManager($objects);
|
||||
}
|
||||
|
||||
public function testPrepareLoadedCollection()
|
||||
|
||||
@@ -14,8 +14,10 @@ use Magento\Backend\Block\Widget\Grid;
|
||||
use Magento\Backend\Block\Widget\Grid\Massaction;
|
||||
use Magento\Backend\Block\Widget\Grid\Massaction\Extended;
|
||||
use Magento\Backend\Model\Url;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\App\Request\Http;
|
||||
use Magento\Framework\Data\Collection;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\View\Layout;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
@@ -98,6 +100,18 @@ class ExtendedTest extends TestCase
|
||||
];
|
||||
|
||||
$objectManagerHelper = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$objectManagerHelper->prepareObjectManager($objects);
|
||||
|
||||
$this->_block = $objectManagerHelper->getObject(
|
||||
Extended::class,
|
||||
$arguments
|
||||
|
||||
@@ -17,6 +17,8 @@ use Magento\Framework\Data\Collection\AbstractDb as Collection;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\Framework\DB\Adapter\AdapterInterface;
|
||||
use Magento\Framework\DB\Select;
|
||||
use Magento\Framework\Json\Helper\Data;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\View\Layout;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
@@ -84,12 +86,15 @@ class MassactionTest extends TestCase
|
||||
*/
|
||||
private $connectionMock;
|
||||
|
||||
/** @var Data */
|
||||
protected $jsonHelperMock;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->_gridMock = $this->getMockBuilder(Grid::class)
|
||||
->disableOriginalConstructor()
|
||||
->disableOriginalClone()
|
||||
->setMethods(['getId', 'getCollection'])
|
||||
->onlyMethods(['getId', 'getCollection'])
|
||||
->getMock();
|
||||
$this->_gridMock->expects($this->any())
|
||||
->method('getId')
|
||||
@@ -98,7 +103,8 @@ class MassactionTest extends TestCase
|
||||
$this->_layoutMock = $this->getMockBuilder(Layout::class)
|
||||
->disableOriginalConstructor()
|
||||
->disableOriginalClone()
|
||||
->setMethods(['getParentName', 'getBlock', 'helper'])
|
||||
->addMethods(['helper'])
|
||||
->onlyMethods(['getParentName', 'getBlock'])
|
||||
->getMock();
|
||||
$this->_layoutMock->expects($this->any())
|
||||
->method('getParentName')
|
||||
@@ -124,7 +130,7 @@ class MassactionTest extends TestCase
|
||||
|
||||
$this->_authorizationMock = $this->getMockBuilder(Authorization::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['isAllowed'])
|
||||
->onlyMethods(['isAllowed'])
|
||||
->getMock();
|
||||
|
||||
$this->gridCollectionMock = $this->createMock(Collection::class);
|
||||
@@ -147,6 +153,17 @@ class MassactionTest extends TestCase
|
||||
'authorization' => $this->_authorizationMock,
|
||||
];
|
||||
|
||||
$this->jsonHelperMock = $this->getMockBuilder(Data::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
/** @var ObjectManagerInterface|MockObject $objectManagerMock */
|
||||
$objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
|
||||
$objectManagerMock->expects($this->any())
|
||||
->method('get')
|
||||
->willReturn($this->jsonHelperMock);
|
||||
\Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);
|
||||
|
||||
$objectManagerHelper = new ObjectManager($this);
|
||||
$this->_block = $objectManagerHelper->getObject(
|
||||
Massaction::class,
|
||||
@@ -218,7 +235,7 @@ class MassactionTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function itemsProcessingDataProvider()
|
||||
public static function itemsProcessingDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -288,7 +305,7 @@ class MassactionTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function selectedDataProvider()
|
||||
public static function selectedDataProvider()
|
||||
{
|
||||
return [
|
||||
['', '', []],
|
||||
@@ -324,12 +341,10 @@ class MassactionTest extends TestCase
|
||||
|
||||
$this->gridCollectionSelectMock->expects($this->exactly(4))
|
||||
->method('reset')
|
||||
->withConsecutive(
|
||||
[Select::ORDER],
|
||||
[Select::LIMIT_COUNT],
|
||||
[Select::LIMIT_OFFSET],
|
||||
[Select::COLUMNS]
|
||||
);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[Select::ORDER], [Select::LIMIT_COUNT],
|
||||
[Select::LIMIT_OFFSET], [Select::COLUMNS] => $this->gridCollectionMock
|
||||
});
|
||||
|
||||
$this->gridCollectionSelectMock->expects($this->once())
|
||||
->method('columns')
|
||||
@@ -385,7 +400,7 @@ class MassactionTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function addItemDataProvider()
|
||||
public static function addItemDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -30,6 +30,8 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test for \Magento\Backend\Controller\Adminhtml\Auth\Login.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class LoginTest extends TestCase
|
||||
{
|
||||
@@ -99,7 +101,7 @@ class LoginTest extends TestCase
|
||||
|
||||
$this->helperMock = $this->createMock(Data::class);
|
||||
$this->requestMock = $this->getMockBuilder(Request::class)
|
||||
->setMethods(['getUri', 'getRequestUri'])
|
||||
->addMethods(['getUri', 'getRequestUri'])
|
||||
->getMockForAbstractClass();
|
||||
$this->redirectMock = $this->getMockBuilder(Redirect::class)
|
||||
->disableOriginalConstructor()
|
||||
|
||||
@@ -38,7 +38,7 @@ class CleanMediaTest extends TestCase
|
||||
$helper = new ObjectManager($this);
|
||||
|
||||
$session = $this->getMockBuilder(Session::class)
|
||||
->setMethods(['setIsUrlNotice'])
|
||||
->addMethods(['setIsUrlNotice'])
|
||||
->setConstructorArgs($helper->getConstructArguments(Session::class))
|
||||
->getMock();
|
||||
|
||||
@@ -46,7 +46,7 @@ class CleanMediaTest extends TestCase
|
||||
ExceptionMessageLookupFactory::class
|
||||
)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(
|
||||
->addMethods(
|
||||
['getMessageGenerator']
|
||||
)
|
||||
->getMock();
|
||||
@@ -54,7 +54,7 @@ class CleanMediaTest extends TestCase
|
||||
$messageManagerParams = $helper->getConstructArguments(Manager::class);
|
||||
$messageManagerParams['exceptionMessageFactory'] = $exceptionMessageFactory;
|
||||
$messageManager = $this->getMockBuilder(Manager::class)
|
||||
->setMethods(['addSuccessMessage'])
|
||||
->onlyMethods(['addSuccessMessage'])
|
||||
->setConstructorArgs($messageManagerParams)
|
||||
->getMock();
|
||||
|
||||
@@ -70,12 +70,12 @@ class CleanMediaTest extends TestCase
|
||||
]
|
||||
);
|
||||
$context = $this->getMockBuilder(Context::class)
|
||||
->setMethods(['getRequest', 'getResponse', 'getMessageManager', 'getSession', 'getResultFactory'])
|
||||
->onlyMethods(['getRequest', 'getResponse', 'getMessageManager', 'getSession', 'getResultFactory'])
|
||||
->setConstructorArgs($args)
|
||||
->getMock();
|
||||
$resultFactory = $this->getMockBuilder(ResultFactory::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->getMock();
|
||||
$resultRedirect = $this->getMockBuilder(Redirect::class)
|
||||
->disableOriginalConstructor()
|
||||
|
||||
@@ -233,8 +233,11 @@ class SaveTest extends TestCase
|
||||
|
||||
$this->objectManagerMock
|
||||
->method('get')
|
||||
->withConsecutive([Session::class], [Locale::class], [Manager::class])
|
||||
->willReturnOnConsecutiveCalls($this->authSessionMock, $this->validatorMock, $this->managerMock);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[Session::class] => $this->authSessionMock,
|
||||
[Locale::class] => $this->validatorMock,
|
||||
[Manager::class] => $this->managerMock
|
||||
});
|
||||
$this->objectManagerMock
|
||||
->method('create')
|
||||
->with(User::class)
|
||||
|
||||
@@ -11,6 +11,7 @@ use Magento\Backend\App\Config;
|
||||
use Magento\Backend\Model\Auth\Session;
|
||||
use Magento\Framework\Acl;
|
||||
use Magento\Framework\Acl\Builder;
|
||||
use Magento\Framework\Session\SessionStartChecker;
|
||||
use Magento\Framework\Session\Storage;
|
||||
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
|
||||
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;
|
||||
@@ -96,6 +97,13 @@ class SessionTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$objectManager = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
SessionStartChecker::class,
|
||||
$this->createMock(SessionStartChecker::class)
|
||||
]
|
||||
];
|
||||
$objectManager->prepareObjectManager($objects);
|
||||
$this->session = $objectManager->getObject(
|
||||
Session::class,
|
||||
[
|
||||
@@ -127,7 +135,8 @@ class SessionTest extends TestCase
|
||||
->getMock();
|
||||
$this->aclBuilder->expects($this->any())->method('getAcl')->willReturn($aclMock);
|
||||
$userMock = $this->getMockBuilder(User::class)
|
||||
->setMethods(['getReloadAclFlag', 'setReloadAclFlag', 'unsetData', 'save'])
|
||||
->addMethods(['getReloadAclFlag','setReloadAclFlag'])
|
||||
->onlyMethods(['unsetData', 'save'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$userMock->expects($this->any())->method('getReloadAclFlag')->willReturn(true);
|
||||
|
||||
@@ -89,12 +89,13 @@ class ChartTest extends TestCase
|
||||
{
|
||||
$this->orderHelperMock
|
||||
->method('setParam')
|
||||
->withConsecutive(
|
||||
['store', null],
|
||||
['website', null],
|
||||
['group', null],
|
||||
['period', $period]
|
||||
);
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($period) {
|
||||
if ($arg1 == 'period' && $arg2 == $period) {
|
||||
return $this;
|
||||
} elseif ($arg1 == 'store' || $arg1=='website' || $arg1 == 'group') {
|
||||
return $this;
|
||||
}
|
||||
});
|
||||
|
||||
$this->dateRetrieverMock->expects($this->once())
|
||||
->method('getByPeriod')
|
||||
@@ -133,7 +134,7 @@ class ChartTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getByPeriodDataProvider(): array
|
||||
public static function getByPeriodDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -66,7 +66,8 @@ class ManagerTest extends TestCase
|
||||
$this->_authSession->expects($this->any())->method('getUser')->willReturn($userMock);
|
||||
|
||||
$this->_translator = $this->getMockBuilder(TranslateInterface::class)
|
||||
->setMethods(['init', 'setLocale'])
|
||||
->addMethods(['init'])
|
||||
->onlyMethods(['setLocale'])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->_translator->expects($this->any())->method('setLocale')->willReturn($this->_translator);
|
||||
@@ -84,7 +85,7 @@ class ManagerTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function switchBackendInterfaceLocaleDataProvider()
|
||||
public static function switchBackendInterfaceLocaleDataProvider()
|
||||
{
|
||||
return ['case1' => ['locale' => 'de_DE'], 'case2' => ['locale' => 'en_US']];
|
||||
}
|
||||
|
||||
@@ -85,10 +85,17 @@ class BuilderTest extends TestCase
|
||||
|
||||
$this->menuMock
|
||||
->method('add')
|
||||
->withConsecutive(
|
||||
[$this->isInstanceOf(Item::class), null, 2],
|
||||
[$this->isInstanceOf(Item::class), null, 4]
|
||||
);
|
||||
->willReturnCallback(function (...$args) {
|
||||
static $index = 0;
|
||||
$expectedArgs = [
|
||||
[$this->isInstanceOf(Item::class), null, 2],
|
||||
[$this->isInstanceOf(Item::class), null, 4]
|
||||
];
|
||||
$index++;
|
||||
if ($args === $expectedArgs[$index - 1]) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
$this->model->processCommand(
|
||||
new Add(
|
||||
|
||||
@@ -63,7 +63,8 @@ class AdminConfigTest extends TestCase
|
||||
->willReturn('init.host');
|
||||
$this->objectManager = new ObjectManager($this);
|
||||
$this->validatorFactory = $this->getMockBuilder(ValidatorFactory::class)
|
||||
->setMethods(['setInstanceName', 'create'])
|
||||
->addMethods(['setInstanceName'])
|
||||
->onlyMethods(['create'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$backendUrl = $this->createMock(Url::class);
|
||||
@@ -154,7 +155,7 @@ class AdminConfigTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function requestSecureDataProvider()
|
||||
public static function requestSecureDataProvider()
|
||||
{
|
||||
return [[true], [false]];
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ use Magento\Customer\Api\GroupManagementInterface;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\App\Request\Http;
|
||||
use Magento\Framework\App\State;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\Session\Config\ConfigInterface;
|
||||
use Magento\Framework\Session\SaveHandlerInterface;
|
||||
use Magento\Framework\Session\SidResolverInterface;
|
||||
@@ -24,6 +25,7 @@ use Magento\Framework\Session\ValidatorInterface;
|
||||
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
|
||||
use Magento\Framework\Stdlib\CookieManagerInterface;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\Session\SessionStartChecker;
|
||||
use Magento\Quote\Api\CartRepositoryInterface;
|
||||
use Magento\Quote\Api\Data\CartInterface;
|
||||
use Magento\Quote\Model\QuoteFactory;
|
||||
@@ -123,6 +125,11 @@ class QuoteTest extends TestCase
|
||||
*/
|
||||
protected $quoteFactoryMock;
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
protected $objectManagerMock;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*
|
||||
@@ -203,8 +210,16 @@ class QuoteTest extends TestCase
|
||||
|
||||
$this->quoteFactoryMock = $this->createPartialMock(QuoteFactory::class, ['create']);
|
||||
|
||||
$objects = [
|
||||
[
|
||||
SessionStartChecker::class,
|
||||
$this->createMock(SessionStartChecker::class)
|
||||
]
|
||||
];
|
||||
$this->objectManager->prepareObjectManager($objects);
|
||||
|
||||
$this->quote = $this->getMockBuilder(Quote::class)
|
||||
->setMethods(['getStoreId', 'getQuoteId', 'setQuoteId', 'hasCustomerId', 'getCustomerId'])
|
||||
->addMethods(['getStoreId', 'getQuoteId', 'setQuoteId', 'hasCustomerId', 'getCustomerId'])
|
||||
->setConstructorArgs(
|
||||
[
|
||||
'request' => $this->requestMock,
|
||||
@@ -390,7 +405,7 @@ class QuoteTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getQuoteDataProvider()
|
||||
public static function getQuoteDataProvider()
|
||||
{
|
||||
return [
|
||||
'customer ids different' => [66, null, 'once'],
|
||||
|
||||
@@ -363,22 +363,11 @@ class UrlTest extends TestCase
|
||||
|
||||
$this->requestMock
|
||||
->method('getBeforeForwardInfo')
|
||||
->withConsecutive(
|
||||
['route_name'],
|
||||
['route_name'],
|
||||
['controller_name'],
|
||||
['controller_name'],
|
||||
['action_name'],
|
||||
['action_name']
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
'adminhtml',
|
||||
'adminhtml',
|
||||
'catalog',
|
||||
'catalog',
|
||||
'index',
|
||||
'index'
|
||||
);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['route_name'] => 'adminhtml',
|
||||
['controller_name'] => 'catalog',
|
||||
['action_name'] => 'index'
|
||||
});
|
||||
|
||||
$this->model->setRequest($this->requestMock);
|
||||
$keyFromRequest = $this->model->getSecretKey();
|
||||
|
||||
@@ -45,7 +45,7 @@ class PageTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->layoutMock = $this->getMockBuilder(LayoutInterface::class)
|
||||
->setMethods(['setGeneratorPool'])
|
||||
->addMethods(['setGeneratorPool'])
|
||||
->getMockForAbstractClass();
|
||||
$this->breadcrumbsBlockMock = $this->getMockBuilder(Breadcrumbs::class)
|
||||
->disableOriginalConstructor()
|
||||
|
||||
@@ -101,34 +101,35 @@ class CreateTest extends TestCase
|
||||
->getMock();
|
||||
$this->requestMock = $this->getMockBuilder(Http::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['isAjax', 'isPost', 'getParam'])
|
||||
->onlyMethods(['isAjax', 'isPost', 'getParam'])
|
||||
->getMock();
|
||||
$this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['representJson', 'setRedirect'])
|
||||
->onlyMethods(['representJson', 'setRedirect'])
|
||||
->getMock();
|
||||
$this->sessionMock = $this->getMockBuilder(Session::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->backupFactoryMock = $this->getMockBuilder(Factory::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->getMock();
|
||||
$this->backupModelMock = $this->getMockBuilder(Backup::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['setBackupExtension', 'setTime', 'setBackupsDir', 'setName', 'create'])
|
||||
->addMethods(['setBackupExtension', 'setBackupsDir', 'create'])
|
||||
->onlyMethods(['setTime', 'setName'])
|
||||
->getMock();
|
||||
$this->dataBackendHelperMock = $this->getMockBuilder(Data::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getUrl'])
|
||||
->onlyMethods(['getUrl'])
|
||||
->getMock();
|
||||
$this->dataBackupHelperMock = $this->getMockBuilder(\Magento\Backup\Helper\Data::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getExtensionByType', 'getBackupsDir'])
|
||||
->onlyMethods(['getExtensionByType', 'getBackupsDir'])
|
||||
->getMock();
|
||||
$this->maintenanceModeMock = $this->getMockBuilder(MaintenanceMode::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['set'])
|
||||
->onlyMethods(['set'])
|
||||
->getMock();
|
||||
$this->fileFactoryMock = $this->getMockBuilder(FileFactory::class)
|
||||
->disableOriginalConstructor()
|
||||
|
||||
@@ -22,6 +22,7 @@ use Magento\Framework\Controller\Result\Raw;
|
||||
use Magento\Framework\Controller\Result\RawFactory;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\ImportExport\Model\ResourceModel\Helper;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -101,6 +102,11 @@ class DownloadTest extends TestCase
|
||||
*/
|
||||
protected $resultRedirectMock;
|
||||
|
||||
/**
|
||||
* @var Helper
|
||||
*/
|
||||
protected $resourceHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
|
||||
@@ -111,11 +117,12 @@ class DownloadTest extends TestCase
|
||||
->getMock();
|
||||
$this->backupModelFactoryMock = $this->getMockBuilder(BackupFactory::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->getMock();
|
||||
$this->backupModelMock = $this->getMockBuilder(Backup::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getTime', 'exists', 'getSize', 'output', 'getPath', 'getFileName'])
|
||||
->addMethods(['getTime', 'getPath'])
|
||||
->onlyMethods(['exists', 'getSize', 'output', 'getFileName'])
|
||||
->getMock();
|
||||
$this->dataHelperMock = $this->getMockBuilder(Data::class)
|
||||
->disableOriginalConstructor()
|
||||
@@ -125,12 +132,12 @@ class DownloadTest extends TestCase
|
||||
->getMock();
|
||||
$this->resultRawFactoryMock = $this->getMockBuilder(RawFactory::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->getMock();
|
||||
$this->resultRedirectFactoryMock = $this->getMockBuilder(
|
||||
RedirectFactory::class
|
||||
)->disableOriginalConstructor()
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->getMock();
|
||||
$this->resultRawMock = $this->getMockBuilder(Raw::class)
|
||||
->disableOriginalConstructor()
|
||||
@@ -139,6 +146,10 @@ class DownloadTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->resourceHelper = $this->getMockBuilder(Helper::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->objectManager = new ObjectManager($this);
|
||||
$this->context = $this->objectManager->getObject(
|
||||
Context::class,
|
||||
@@ -149,9 +160,19 @@ class DownloadTest extends TestCase
|
||||
'resultRedirectFactory' => $this->resultRedirectFactoryMock
|
||||
]
|
||||
);
|
||||
|
||||
$objects = [
|
||||
[
|
||||
Data::class,
|
||||
$this->dataHelperMock
|
||||
]
|
||||
];
|
||||
$this->objectManager->prepareObjectManager($objects);
|
||||
|
||||
$this->downloadController = $this->objectManager->getObject(
|
||||
Download::class,
|
||||
[
|
||||
'helper' => $this->resourceHelper,
|
||||
'context' => $this->context,
|
||||
'backupModelFactory' => $this->backupModelFactoryMock,
|
||||
'fileFactory' => $this->fileFactoryMock,
|
||||
@@ -260,7 +281,7 @@ class DownloadTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function executeBackupNotFoundDataProvider()
|
||||
public static function executeBackupNotFoundDataProvider()
|
||||
{
|
||||
return [
|
||||
[1, false, 1],
|
||||
|
||||
@@ -278,8 +278,13 @@ class RollbackTest extends TestCase
|
||||
->willReturn($this->backupManagerMock);
|
||||
$this->objectManagerMock
|
||||
->method('create')
|
||||
->withConsecutive([Db::class, []], [Backup::class, []])
|
||||
->willReturnOnConsecutiveCalls($this->backupResourceModelMock, $this->backupModelMock);
|
||||
->willReturnCallback(function ($arg1, $arg2) {
|
||||
if ($arg1 == Db::class && empty($arg2)) {
|
||||
return $this->backupResourceModelMock;
|
||||
} elseif ($arg1 == Backup::class && empty($arg2)) {
|
||||
return $this->backupModelMock;
|
||||
}
|
||||
});
|
||||
$this->backupModelMock->expects($this->once())
|
||||
->method('validateUserPassword')
|
||||
->willReturn($passwordValid);
|
||||
|
||||
@@ -63,8 +63,13 @@ class BackupFactoryTest extends TestCase
|
||||
$this->objectManager = $this->getMockForAbstractClass(ObjectManagerInterface::class);
|
||||
$this->objectManager
|
||||
->method('create')
|
||||
->withConsecutive([Collection::class], [Backup::class])
|
||||
->willReturnOnConsecutiveCalls($this->fsCollection, $this->backupModel);
|
||||
->willReturnCallback(function ($arg1, $arg2) {
|
||||
if ($arg1 == Collection::class) {
|
||||
return $this->fsCollection;
|
||||
} elseif ($arg1 == Backup::class) {
|
||||
return $this->backupModel;
|
||||
}
|
||||
});
|
||||
|
||||
$this->instance = new BackupFactory($this->objectManager);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,11 @@ class CollectionTest extends TestCase
|
||||
->getMock();
|
||||
$directoryWrite->expects($this->any())->method('create')->with('backups');
|
||||
$directoryWrite->method('getAbsolutePath')
|
||||
->withConsecutive([], [], ['backups'])
|
||||
->willReturnOnConsecutiveCalls('', '');
|
||||
->willReturnCallback(function ($arg1) {
|
||||
if ($arg1 == 'backups' || $arg1 == []) {
|
||||
return '';
|
||||
}
|
||||
});
|
||||
$directoryWrite->expects($this->any())->method('isDirectory')->willReturn(true);
|
||||
$directoryWrite->expects($this->any())->method('getDriver')->willReturn($driver);
|
||||
$targetDirectory = $this->getMockBuilder(TargetDirectory::class)
|
||||
|
||||
+13
@@ -9,8 +9,10 @@ namespace Magento\Bundle\Test\Unit\Block\Adminhtml\Catalog\Product\Edit\Tab\Attr
|
||||
|
||||
use Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Attributes\Extend;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\Data\Form;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use PHPUnit\Framework\Constraint\ArrayHasKey;
|
||||
@@ -41,6 +43,17 @@ class ExtendTest extends TestCase
|
||||
)->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->objectManagerHelper = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$this->objectManagerHelper->prepareObjectManager($objects);
|
||||
$this->object = $this->objectManagerHelper->getObject(
|
||||
Extend::class,
|
||||
['registry' => $this->registry, 'formFactory' => $this->formFactory]
|
||||
|
||||
+14
-1
@@ -8,6 +8,8 @@ declare(strict_types=1);
|
||||
namespace Magento\Bundle\Test\Unit\Block\Adminhtml\Sales\Order\Items;
|
||||
|
||||
use Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Sales\Model\Order\Creditmemo;
|
||||
@@ -40,6 +42,17 @@ class RendererTest extends TestCase
|
||||
->getMock();
|
||||
$this->serializer = $this->createMock(Json::class);
|
||||
$objectManager = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$objectManager->prepareObjectManager($objects);
|
||||
$this->model = $objectManager->getObject(
|
||||
Renderer::class,
|
||||
['serializer' => $this->serializer]
|
||||
@@ -318,7 +331,7 @@ class RendererTest extends TestCase
|
||||
{
|
||||
$model = $this->getMockBuilder(Renderer::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['escapeHtml', 'isShipmentSeparately', 'getSelectionAttributes', 'isChildCalculated'])
|
||||
->onlyMethods(['escapeHtml', 'isShipmentSeparately', 'getSelectionAttributes', 'isChildCalculated'])
|
||||
->getMock();
|
||||
$model->expects($this->any())->method('escapeHtml')->willReturn('Test');
|
||||
$model->expects($this->any())->method('isShipmentSeparately')->willReturn(false);
|
||||
|
||||
+14
-1
@@ -9,6 +9,8 @@ declare(strict_types=1);
|
||||
namespace Magento\Bundle\Test\Unit\Block\Adminhtml\Sales\Order\View\Items;
|
||||
|
||||
use Magento\Bundle\Block\Adminhtml\Sales\Order\View\Items\Renderer;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Sales\Model\Order\Item;
|
||||
@@ -35,6 +37,17 @@ class RendererTest extends TestCase
|
||||
->getMock();
|
||||
$this->serializer = $this->createMock(Json::class);
|
||||
$objectManager = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$objectManager->prepareObjectManager($objects);
|
||||
$this->model = $objectManager->getObject(
|
||||
Renderer::class,
|
||||
['serializer' => $this->serializer]
|
||||
@@ -232,7 +245,7 @@ class RendererTest extends TestCase
|
||||
{
|
||||
$model = $this->getMockBuilder(Renderer::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['escapeHtml', 'isShipmentSeparately', 'getSelectionAttributes', 'isChildCalculated'])
|
||||
->onlyMethods(['escapeHtml', 'isShipmentSeparately', 'getSelectionAttributes', 'isChildCalculated'])
|
||||
->getMock();
|
||||
$model->expects($this->any())->method('escapeHtml')->willReturn('Test');
|
||||
$model->expects($this->any())->method('isShipmentSeparately')->willReturn(false);
|
||||
|
||||
+3
-2
@@ -42,7 +42,8 @@ class OptionTest extends TestCase
|
||||
{
|
||||
$this->product = $this->getMockBuilder(Product::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getPriceInfo', 'hasPreconfiguredValues', 'getPreconfiguredValues', '__wakeup'])
|
||||
->addMethods(['hasPreconfiguredValues'])
|
||||
->onlyMethods(['getPriceInfo', 'getPreconfiguredValues', '__wakeup'])
|
||||
->getMock();
|
||||
|
||||
$registry = $this->getMockBuilder(Registry::class)
|
||||
@@ -131,7 +132,7 @@ class OptionTest extends TestCase
|
||||
|
||||
$priceRenderBlock = $this->getMockBuilder(Render::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['renderAmount'])
|
||||
->onlyMethods(['renderAmount'])
|
||||
->getMock();
|
||||
|
||||
$this->product->expects($this->atLeastOnce())
|
||||
|
||||
@@ -268,16 +268,17 @@ class BundleTest extends TestCase
|
||||
->getMock();
|
||||
$this->product
|
||||
->method('getLowestPrice')
|
||||
->withConsecutive(
|
||||
[$this->product, $baseAmount],
|
||||
[$this->product, $basePriceValue]
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(999, 888);
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($baseAmount, $basePriceValue) {
|
||||
if ($arg1 == $this->product && $arg2==$baseAmount) {
|
||||
return 999;
|
||||
} elseif ($arg1 == $this->product && $arg2==$basePriceValue) {
|
||||
return 888;
|
||||
}
|
||||
});
|
||||
$this->bundleProductPriceFactory->expects($this->once())
|
||||
->method('create')
|
||||
->willReturn($bundleProductPrice);
|
||||
$options = [$this->createOption($optionId, 'Title `1', $selections)];
|
||||
|
||||
$finalPriceMock = $this->getPriceMock(
|
||||
[
|
||||
'getPriceWithoutOption' => new DataObject(
|
||||
@@ -310,7 +311,6 @@ class BundleTest extends TestCase
|
||||
RegularPrice::PRICE_CODE => $regularPriceMock
|
||||
];
|
||||
$priceInfo = $this->getPriceInfoMock($prices);
|
||||
|
||||
$this->product->expects($this->once())
|
||||
->method('hasPreconfiguredValues')
|
||||
->willReturn(true);
|
||||
@@ -411,8 +411,12 @@ class BundleTest extends TestCase
|
||||
}
|
||||
$priceInfoMock
|
||||
->method('getPrice')
|
||||
->withConsecutive(...$withArgs)
|
||||
->willReturnOnConsecutiveCalls(...$willReturnArgs);
|
||||
->willReturnCallback(function ($withArgs) use ($willReturnArgs) {
|
||||
static $callCount = 0;
|
||||
$returnValue = $willReturnArgs[$callCount] ?? null;
|
||||
$callCount++;
|
||||
return $returnValue;
|
||||
});
|
||||
} else {
|
||||
$priceInfoMock->expects($this->any())
|
||||
->method('getPrice')
|
||||
@@ -606,7 +610,7 @@ class BundleTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionsDataProvider(): array
|
||||
public static function getOptionsDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[true],
|
||||
|
||||
+6
-4
@@ -76,13 +76,13 @@ class FormTest extends TestCase
|
||||
->getMockForAbstractClass();
|
||||
$this->productBuilder = $this->getMockBuilder(Builder::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['build'])
|
||||
->onlyMethods(['build'])
|
||||
->getMock();
|
||||
$this->initializationHelper = $this->getMockBuilder(
|
||||
Helper::class
|
||||
)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['initialize'])
|
||||
->onlyMethods(['initialize'])
|
||||
->getMock();
|
||||
$this->view = $this->getMockForAbstractClass(ViewInterface::class);
|
||||
|
||||
@@ -110,12 +110,14 @@ class FormTest extends TestCase
|
||||
{
|
||||
$product = $this->getMockBuilder(Product::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['_wakeup', 'getId'])
|
||||
->addMethods(['_wakeup'])
|
||||
->onlyMethods(['getId'])
|
||||
->getMock();
|
||||
$layout = $this->getMockForAbstractClass(LayoutInterface::class);
|
||||
$block = $this->getMockBuilder(Bundle::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['setIndex', 'toHtml'])
|
||||
->addMethods(['setIndex'])
|
||||
->onlyMethods(['toHtml'])
|
||||
->getMock();
|
||||
|
||||
$this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
|
||||
|
||||
+2
-1
@@ -84,7 +84,8 @@ class GridTest extends TestCase
|
||||
\Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Bundle\Option\Search\Grid::class
|
||||
)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['setIndex', 'toHtml'])
|
||||
->addMethods(['setIndex'])
|
||||
->onlyMethods(['toHtml'])
|
||||
->getMock();
|
||||
|
||||
$this->response->expects($this->once())->method('setBody')->willReturnSelf();
|
||||
|
||||
+2
-1
@@ -83,7 +83,8 @@ class SearchTest extends TestCase
|
||||
$block = $this->getMockBuilder(
|
||||
\Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Bundle\Option\Search::class
|
||||
)->disableOriginalConstructor()
|
||||
->setMethods(['setIndex', 'setFirstShow', 'toHtml'])
|
||||
->addMethods(['setIndex', 'setFirstShow'])
|
||||
->onlyMethods(['toHtml'])
|
||||
->getMock();
|
||||
|
||||
$this->response->expects($this->once())->method('setBody')->willReturnSelf();
|
||||
|
||||
+3
-5
@@ -1,11 +1,9 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Test class for \Magento\Bundle\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Bundle
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Bundle\Test\Unit\Controller\Adminhtml\Product\Initialization\Helper\Plugin;
|
||||
|
||||
@@ -152,7 +150,7 @@ class BundleTest extends TestCase
|
||||
->willReturn(['option_1' => ['delete' => 1]]);
|
||||
$extensionAttribute = $this->getMockBuilder(ProductExtensionInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['setBundleProductOptions'])
|
||||
->addMethods(['setBundleProductOptions'])
|
||||
->getMockForAbstractClass();
|
||||
$extensionAttribute->expects($this->once())->method('setBundleProductOptions')->with([]);
|
||||
$this->productMock->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttribute);
|
||||
@@ -193,7 +191,7 @@ class BundleTest extends TestCase
|
||||
$this->requestMock->expects($this->any())->method('getPost')->willReturnMap($valueMap);
|
||||
$extensionAttribute = $this->getMockBuilder(ProductExtensionInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['setBundleProductOptions'])
|
||||
->addMethods(['setBundleProductOptions'])
|
||||
->getMockForAbstractClass();
|
||||
$extensionAttribute->expects($this->once())->method('setBundleProductOptions')->with([]);
|
||||
$this->productMock->expects($this->any())->method('getCompositeReadonly')->willReturn(false);
|
||||
|
||||
@@ -217,8 +217,15 @@ class ConfigurationTest extends TestCase
|
||||
->willReturn($product);
|
||||
$this->item
|
||||
->method('getOptionByCode')
|
||||
->withConsecutive(['bundle_option_ids'], ['bundle_selection_ids'])
|
||||
->willReturnOnConsecutiveCalls($itemOption, $selectionOption);
|
||||
->willReturnCallback(
|
||||
function ($arg1) use ($itemOption, $selectionOption) {
|
||||
if ($arg1 == 'bundle_option_ids') {
|
||||
return $itemOption;
|
||||
} elseif ($arg1 == 'bundle_selection_ids') {
|
||||
return $selectionOption;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertEquals([], $this->helper->getBundleOptions($this->item));
|
||||
}
|
||||
@@ -277,8 +284,14 @@ class ConfigurationTest extends TestCase
|
||||
if ($displayCartPriceBoth) {
|
||||
$this->taxHelper->expects($this->any())
|
||||
->method('getTaxPrice')
|
||||
->withConsecutive([$product, 15.00, !$includingTax], [$product, 15.00, $includingTax])
|
||||
->willReturnOnConsecutiveCalls(15.00, 15.00);
|
||||
->willReturnCallback(
|
||||
function ($product, $amount, $includingTax) {
|
||||
if ($product && $amount == 15.00 && ($includingTax || !$includingTax)) {
|
||||
return 15.00;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
} else {
|
||||
$this->taxHelper->expects($this->any())
|
||||
->method('getTaxPrice')
|
||||
@@ -318,8 +331,10 @@ class ConfigurationTest extends TestCase
|
||||
$this->item->expects($this->any())->method('getProduct')->willReturn($product);
|
||||
$this->item
|
||||
->method('getOptionByCode')
|
||||
->withConsecutive(['bundle_option_ids'], ['bundle_selection_ids'])
|
||||
->willReturnOnConsecutiveCalls($itemOption, $selectionOption);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['bundle_option_ids'] => $itemOption,
|
||||
['bundle_selection_ids'] => $selectionOption
|
||||
});
|
||||
$this->productConfiguration->expects($this->once())->method('getCustomOptions')->with($this->item)
|
||||
->willReturn([0 => ['label' => 'title', 'value' => 'value']]);
|
||||
|
||||
@@ -346,7 +361,7 @@ class ConfigurationTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTaxConfiguration(): array
|
||||
public static function getTaxConfiguration(): array
|
||||
{
|
||||
return [
|
||||
[null, false],
|
||||
|
||||
@@ -54,7 +54,7 @@ class CartItemProcessorTest extends TestCase
|
||||
$this->productOptionExtensionMock = $this->getMockBuilder(
|
||||
ProductOptionExtensionFactory::class
|
||||
)
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$this->bundleOptionFactoryMock = $this->createPartialMock(
|
||||
@@ -85,7 +85,7 @@ class CartItemProcessorTest extends TestCase
|
||||
$productOptionMock = $this->createMock(ProductOption::class);
|
||||
$dataObjectMock = $this->createMock(DataObject::class);
|
||||
$optionExtensionMock = $this->getMockBuilder(ProductOptionExtensionInterface::class)
|
||||
->setMethods(
|
||||
->addMethods(
|
||||
[
|
||||
'getBundleOptions',
|
||||
'getCustomOptions',
|
||||
@@ -141,7 +141,7 @@ class CartItemProcessorTest extends TestCase
|
||||
$bundleOptionMock = $this->createMock(BundleOption::class);
|
||||
$productOptionMock = $this->createMock(ProductOption::class);
|
||||
$optionExtensionMock = $this->getMockBuilder(ProductOptionExtensionInterface::class)
|
||||
->setMethods(
|
||||
->addMethods(
|
||||
[
|
||||
'getBundleOptions',
|
||||
'getCustomOptions',
|
||||
|
||||
@@ -751,8 +751,10 @@ class LinkManagementTest extends TestCase
|
||||
$linkedProductMock->expects($this->once())->method('isComposite')->willReturn(false);
|
||||
$this->productRepository
|
||||
->method('get')
|
||||
->withConsecutive([$bundleProductSku], ['linked_product_sku'])
|
||||
->willReturnOnConsecutiveCalls($productMock, $linkedProductMock);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[$bundleProductSku] => $productMock,
|
||||
['linked_product_sku'] => $linkedProductMock
|
||||
});
|
||||
|
||||
$store = $this->createMock(Store::class);
|
||||
$this->storeManagerMock->method('getStore')->willReturn($store);
|
||||
@@ -832,8 +834,10 @@ class LinkManagementTest extends TestCase
|
||||
->willReturn(false);
|
||||
$this->productRepository
|
||||
->method('get')
|
||||
->withConsecutive([$bundleProductSku], ['linked_product_sku'])
|
||||
->willReturnOnConsecutiveCalls($productMock, $linkedProductMock);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[$bundleProductSku] => $productMock,
|
||||
['linked_product_sku'] => $linkedProductMock
|
||||
});
|
||||
|
||||
$store = $this->createMock(Store::class);
|
||||
$this->storeManagerMock->method('getStore')
|
||||
@@ -903,8 +907,10 @@ class LinkManagementTest extends TestCase
|
||||
->willReturn(false);
|
||||
$this->productRepository
|
||||
->method('get')
|
||||
->withConsecutive([$bundleProductSku], [$linkedProductSku])
|
||||
->willReturnOnConsecutiveCalls($productMock, $linkedProductMock);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[$bundleProductSku] => $productMock,
|
||||
[$linkedProductSku] => $linkedProductMock
|
||||
});
|
||||
|
||||
$this->model->saveChild($bundleProductSku, $productLink);
|
||||
}
|
||||
@@ -937,8 +943,10 @@ class LinkManagementTest extends TestCase
|
||||
->willReturn(false);
|
||||
$this->productRepository
|
||||
->method('get')
|
||||
->withConsecutive([$bundleProductSku], [$linkedProductSku])
|
||||
->willReturnOnConsecutiveCalls($productMock, $linkedProductMock);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[$bundleProductSku] => $productMock,
|
||||
[$linkedProductSku] => $linkedProductMock
|
||||
});
|
||||
|
||||
$selection = $this->createPartialMock(
|
||||
Selection::class,
|
||||
@@ -981,8 +989,10 @@ class LinkManagementTest extends TestCase
|
||||
$linkedProductMock->expects($this->once())->method('isComposite')->willReturn(true);
|
||||
$this->productRepository
|
||||
->method('get')
|
||||
->withConsecutive([$bundleProductSku], [$linkedProductSku])
|
||||
->willReturnOnConsecutiveCalls($productMock, $linkedProductMock);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
[$bundleProductSku] => $productMock,
|
||||
[$linkedProductSku] => $linkedProductMock
|
||||
});
|
||||
|
||||
$this->model->saveChild($bundleProductSku, $productLink);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ use Magento\Framework\EntityManager\MetadataPool;
|
||||
use Magento\Framework\EntityManager\EntityMetadataInterface;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Magento\Bundle\Api\ProductLinkManagementAddChildrenInterface;
|
||||
|
||||
class SaveActionTest extends TestCase
|
||||
{
|
||||
@@ -51,6 +53,16 @@ class SaveActionTest extends TestCase
|
||||
*/
|
||||
private $saveAction;
|
||||
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
private $storeManager;
|
||||
|
||||
/**
|
||||
* @var ProductLinkManagementAddChildrenInterface
|
||||
*/
|
||||
private $addChildren;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->linkManagement = $this->getMockBuilder(ProductLinkManagementInterface::class)
|
||||
@@ -65,6 +77,12 @@ class SaveActionTest extends TestCase
|
||||
$this->optionResource = $this->getMockBuilder(OptionResource::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->addChildren = $this->getMockBuilder(ProductLinkManagementAddChildrenInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->storeManager = $this->getMockBuilder(StoreManagerInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->product = $this->getMockBuilder(ProductInterface::class)
|
||||
->addMethods(['getStoreId', 'getData', 'setIsRelationsChanged'])
|
||||
->getMockForAbstractClass();
|
||||
@@ -73,7 +91,9 @@ class SaveActionTest extends TestCase
|
||||
$this->optionResource,
|
||||
$this->metadataPool,
|
||||
$this->type,
|
||||
$this->linkManagement
|
||||
$this->linkManagement,
|
||||
$this->storeManager,
|
||||
$this->addChildren
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PriceBackendTest extends TestCase
|
||||
{
|
||||
const CLOSURE_VALUE = 'CLOSURE';
|
||||
private const CLOSURE_VALUE = 'CLOSURE';
|
||||
|
||||
/** @var PriceBackend */
|
||||
private $priceBackendPlugin;
|
||||
@@ -45,7 +45,8 @@ class PriceBackendTest extends TestCase
|
||||
->getMock();
|
||||
$this->productMock = $this->getMockBuilder(Product::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getTypeId', 'getPriceType', '__wakeUp'])
|
||||
->addMethods(['getPriceType'])
|
||||
->onlyMethods(['getTypeId', '__wakeUp'])
|
||||
->getMock();
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ class PriceBackendTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function aroundValidateDataProvider()
|
||||
public static function aroundValidateDataProvider()
|
||||
{
|
||||
return [
|
||||
['type' => Type::TYPE_SIMPLE, 'priceType' => Price::PRICE_TYPE_FIXED, 'result' => static::CLOSURE_VALUE],
|
||||
|
||||
@@ -144,7 +144,11 @@ class CatalogPriceTest extends TestCase
|
||||
->willReturn($currentStoreMock);
|
||||
$this->storeManagerMock
|
||||
->method('setCurrentStore')
|
||||
->withConsecutive(['store_id'], ['current_store_id']);
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg == 'store_id' || $arg == 'current_store_id') {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
$this->assertEquals(15, $this->catalogPrice->getCatalogPrice($this->productMock, $storeMock, true));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class BundleTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$extensionAttributesProduct = $this->getMockBuilder(ProductExtensionInterface::class)
|
||||
->setMethods(['getBundleProductOptions'])
|
||||
->addMethods(['getBundleProductOptions'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
|
||||
@@ -67,14 +67,14 @@ class BundleTest extends TestCase
|
||||
->willReturn($extensionAttributesProduct);
|
||||
|
||||
$productLink = $this->getMockBuilder(Link::class)
|
||||
->setMethods(['setSelectionId'])
|
||||
->addMethods(['setSelectionId'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$productLink->expects($this->exactly(2))
|
||||
->method('setSelectionId')
|
||||
->with($this->identicalTo(null));
|
||||
$firstOption = $this->getMockBuilder(BundleOptionInterface::class)
|
||||
->setMethods(['getProductLinks'])
|
||||
->addMethods(['getProductLinks'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$firstOption->expects($this->once())
|
||||
@@ -84,7 +84,7 @@ class BundleTest extends TestCase
|
||||
->method('setOptionId')
|
||||
->with($this->identicalTo(null));
|
||||
$secondOption = $this->getMockBuilder(BundleOptionInterface::class)
|
||||
->setMethods(['getProductLinks'])
|
||||
->addMethods(['getProductLinks'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$secondOption->expects($this->once())
|
||||
@@ -106,7 +106,7 @@ class BundleTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$extensionAttributesDuplicate = $this->getMockBuilder(ProductExtensionInterface::class)
|
||||
->setMethods(['setBundleProductOptions'])
|
||||
->addMethods(['setBundleProductOptions'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
|
||||
@@ -129,7 +129,7 @@ class BundleTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$extensionAttributesProduct = $this->getMockBuilder(ProductExtensionInterface::class)
|
||||
->setMethods(['getBundleProductOptions'])
|
||||
->addMethods(['getBundleProductOptions'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
|
||||
@@ -148,7 +148,7 @@ class BundleTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$extensionAttributesDuplicate = $this->getMockBuilder(ProductExtensionInterface::class)
|
||||
->setMethods(['setBundleProductOptions'])
|
||||
->addMethods(['setBundleProductOptions'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class OptionListTest extends TestCase
|
||||
->with($productMock, $optionId)
|
||||
->willReturn([$linkMock]);
|
||||
$newOptionMock = $this->getMockBuilder(OptionInterface::class)
|
||||
->setMethods(['setDefaultTitle'])
|
||||
->addMethods(['setDefaultTitle'])
|
||||
->getMockForAbstractClass();
|
||||
$this->dataObjectHelperMock->expects($this->once())
|
||||
->method('populateWithArray')
|
||||
|
||||
@@ -132,7 +132,7 @@ class PriceTest extends TestCase
|
||||
}
|
||||
);
|
||||
$tierPriceExtensionFactoryMock = $this->getMockBuilder(ProductTierPriceExtensionFactory::class)
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$objectManagerHelper = new ObjectManagerHelper($this);
|
||||
@@ -191,7 +191,7 @@ class PriceTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function calculateSpecialPrice()
|
||||
public static function calculateSpecialPrice()
|
||||
{
|
||||
return [
|
||||
[10, null, 0, true, 10],
|
||||
@@ -231,7 +231,7 @@ class PriceTest extends TestCase
|
||||
public function testGetTotalBundleItemsPriceWithEmptyOptions($value)
|
||||
{
|
||||
$dataObjectMock = $this->getMockBuilder(DataObject::class)
|
||||
->setMethods(['getValue'])
|
||||
->addMethods(['getValue'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
@@ -258,7 +258,7 @@ class PriceTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function dataProviderWithEmptyOptions()
|
||||
public static function dataProviderWithEmptyOptions()
|
||||
{
|
||||
return [
|
||||
['{}'],
|
||||
@@ -277,7 +277,7 @@ class PriceTest extends TestCase
|
||||
$storeId = 1;
|
||||
|
||||
$dataObjectMock = $this->getMockBuilder(DataObject::class)
|
||||
->setMethods(['getValue'])
|
||||
->addMethods(['getValue'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ class TypeTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->serializer = $this->getMockBuilder(Json::class)
|
||||
->setMethods(null)
|
||||
->onlyMethods([])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->metadataPool = $this->getMockBuilder(MetadataPool::class)
|
||||
@@ -1573,8 +1573,10 @@ class TypeTest extends TestCase
|
||||
->getMock();
|
||||
$productMock
|
||||
->method('getData')
|
||||
->withConsecutive(['sku'], ['sku_type'])
|
||||
->willReturnOnConsecutiveCalls($sku, 'some_data');
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['sku'] => $sku,
|
||||
['sku_type'] => 'some_data'
|
||||
});
|
||||
|
||||
$this->assertEquals($sku, $this->model->getSku($productMock));
|
||||
}
|
||||
@@ -1607,8 +1609,10 @@ class TypeTest extends TestCase
|
||||
->willReturn(true);
|
||||
$productMock
|
||||
->method('getCustomOption')
|
||||
->withConsecutive(['option_ids'], ['bundle_selection_ids'])
|
||||
->willReturnOnConsecutiveCalls(false, $customOptionMock);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['option_ids'] => false,
|
||||
['bundle_selection_ids'] => $customOptionMock
|
||||
});
|
||||
$customOptionMock->expects($this->any())
|
||||
->method('getValue')
|
||||
->willReturn($serializeIds);
|
||||
@@ -1617,18 +1621,12 @@ class TypeTest extends TestCase
|
||||
->getMock();
|
||||
$productMock
|
||||
->method('getData')
|
||||
->withConsecutive(
|
||||
['sku'],
|
||||
['sku_type'],
|
||||
['_cache_instance_used_selections'],
|
||||
['_cache_instance_used_selections_ids']
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
$sku,
|
||||
null,
|
||||
$selectionMock,
|
||||
$selectionIds
|
||||
);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['sku'] => $sku,
|
||||
['sku_type'] => null,
|
||||
['_cache_instance_used_selections'] => $selectionMock,
|
||||
['_cache_instance_used_selections_ids'] => $selectionIds
|
||||
});
|
||||
$selectionMock->expects(($this->any()))
|
||||
->method('getItemByColumnValue')
|
||||
->willReturn($selectionItemMock);
|
||||
@@ -1655,8 +1653,10 @@ class TypeTest extends TestCase
|
||||
|
||||
$productMock
|
||||
->method('getData')
|
||||
->withConsecutive(['weight_type'], ['weight'])
|
||||
->willReturnOnConsecutiveCalls(true, $weight);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['weight_type'] => true,
|
||||
['weight'] => $weight
|
||||
});
|
||||
|
||||
$this->assertEquals($weight, $this->model->getWeight($productMock));
|
||||
}
|
||||
@@ -1694,12 +1694,11 @@ class TypeTest extends TestCase
|
||||
->getMock();
|
||||
$productMock
|
||||
->method('getData')
|
||||
->withConsecutive(
|
||||
['weight_type'],
|
||||
['_cache_instance_used_selections'],
|
||||
['_cache_instance_used_selections_ids']
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(false, $selectionMock, $selectionIds);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['weight_type'] => false,
|
||||
['_cache_instance_used_selections'] => $selectionMock,
|
||||
['_cache_instance_used_selections_ids'] => $selectionIds
|
||||
});
|
||||
$selectionMock->expects($this->once())
|
||||
->method('getItems')
|
||||
->willReturn([$selectionItemMock]);
|
||||
@@ -1708,11 +1707,10 @@ class TypeTest extends TestCase
|
||||
->willReturn('id');
|
||||
$productMock
|
||||
->method('getCustomOption')
|
||||
->withConsecutive(
|
||||
['bundle_selection_ids'],
|
||||
['selection_qty_' . 'id']
|
||||
)
|
||||
->willReturnOnConsecutiveCalls($customOptionMock, null);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['bundle_selection_ids'] => $customOptionMock,
|
||||
['selection_qty_' . 'id'] => null
|
||||
});
|
||||
$selectionItemMock->expects($this->once())
|
||||
->method('getWeight')
|
||||
->willReturn($weight);
|
||||
@@ -1760,12 +1758,11 @@ class TypeTest extends TestCase
|
||||
->getMock();
|
||||
$productMock
|
||||
->method('getData')
|
||||
->withConsecutive(
|
||||
['weight_type'],
|
||||
['_cache_instance_used_selections'],
|
||||
['_cache_instance_used_selections_ids']
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(false, $selectionMock, $selectionIds);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['weight_type'] => false,
|
||||
['_cache_instance_used_selections'] => $selectionMock,
|
||||
['_cache_instance_used_selections_ids'] => $selectionIds
|
||||
});
|
||||
$selectionMock->expects($this->once())
|
||||
->method('getItems')
|
||||
->willReturn([$selectionItemMock]);
|
||||
@@ -1774,8 +1771,10 @@ class TypeTest extends TestCase
|
||||
->willReturn('id');
|
||||
$productMock
|
||||
->method('getCustomOption')
|
||||
->withConsecutive(['bundle_selection_ids'], ['selection_qty_' . 'id'])
|
||||
->willReturnOnConsecutiveCalls($customOptionMock, $qtyOptionMock);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['bundle_selection_ids'] => $customOptionMock,
|
||||
['selection_qty_' . 'id'] => $qtyOptionMock
|
||||
});
|
||||
$qtyOptionMock->expects($this->once())
|
||||
->method('getValue')
|
||||
->willReturn($qtyOption);
|
||||
@@ -1839,11 +1838,10 @@ class TypeTest extends TestCase
|
||||
->getMock();
|
||||
$productMock
|
||||
->method('getData')
|
||||
->withConsecutive(
|
||||
['_cache_instance_used_selections'],
|
||||
['_cache_instance_used_selections_ids']
|
||||
)
|
||||
->willReturnOnConsecutiveCalls($selectionMock, $selectionIds);
|
||||
->willReturnCallback(fn($param) => match ([$param]) {
|
||||
['_cache_instance_used_selections'] => $selectionMock,
|
||||
['_cache_instance_used_selections_ids'] => $selectionIds
|
||||
});
|
||||
$selectionMock->expects($this->once())
|
||||
->method('getItems')
|
||||
->willReturn([$selectionItemMock]);
|
||||
@@ -1926,7 +1924,7 @@ class TypeTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function shakeSelectionsDataProvider(): array
|
||||
public static function shakeSelectionsDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[0, 0, 0],
|
||||
@@ -2059,7 +2057,7 @@ class TypeTest extends TestCase
|
||||
->getMock();
|
||||
$resourceClassName = AbstractCollection::class;
|
||||
$dbResourceMock = $this->getMockBuilder($resourceClassName)
|
||||
->setMethods(['setProductIdFilter', 'setPositionOrder', 'joinValues', 'setIdFilter'])
|
||||
->addMethods(['setProductIdFilter', 'setPositionOrder', 'joinValues', 'setIdFilter'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$storeMock = $this->getMockBuilder(Store::class)
|
||||
@@ -2326,7 +2324,7 @@ class TypeTest extends TestCase
|
||||
$this->expectProductEntityMetadata();
|
||||
$resourceClassName = AbstractCollection::class;
|
||||
$dbResourceMock = $this->getMockBuilder($resourceClassName)
|
||||
->setMethods(['getItems'])
|
||||
->onlyMethods(['getItems'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$item = $this->getMockBuilder(DataObject::class)
|
||||
|
||||
@@ -49,17 +49,17 @@ class ProductOptionProcessorTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->dataObject = $this->getMockBuilder(DataObject::class)
|
||||
->setMethods([
|
||||
->addMethods([
|
||||
'getBundleOption',
|
||||
'getBundleOptionQty',
|
||||
'create',
|
||||
'addData'
|
||||
'create'
|
||||
])
|
||||
->onlyMethods(['addData'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->dataObjectFactory = $this->getMockBuilder(\Magento\Framework\DataObject\Factory::class)
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->dataObjectFactory->expects($this->any())
|
||||
@@ -74,7 +74,7 @@ class ProductOptionProcessorTest extends TestCase
|
||||
$this->bundleOptionInterfaceFactory = $this->getMockBuilder(
|
||||
BundleOptionInterfaceFactory::class
|
||||
)
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->bundleOptionInterfaceFactory->expects($this->any())
|
||||
@@ -101,7 +101,7 @@ class ProductOptionProcessorTest extends TestCase
|
||||
|
||||
$productOptionExtensionMock = $this->getMockBuilder(
|
||||
ProductOptionExtensionInterface::class
|
||||
)->setMethods(['getBundleOptions'])->getMockForAbstractClass();
|
||||
)->addMethods(['getBundleOptions'])->getMockForAbstractClass();
|
||||
|
||||
$productOptionMock->expects($this->any())
|
||||
->method('getExtensionAttributes')
|
||||
@@ -200,7 +200,7 @@ class ProductOptionProcessorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function dataProviderConvertToProductOption()
|
||||
public static function dataProviderConvertToProductOption()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -100,6 +100,7 @@ class PriceTest extends TestCase
|
||||
/**
|
||||
* @throws \ReflectionException
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function testCalculateDynamicBundleSelectionPrice(): void
|
||||
{
|
||||
@@ -177,19 +178,33 @@ class PriceTest extends TestCase
|
||||
//@codingStandardsIgnoreEnd
|
||||
$this->connectionMock->expects($this->exactly(3))
|
||||
->method('getCheckSql')
|
||||
->withConsecutive(
|
||||
[
|
||||
'i.special_price > 0 AND i.special_price < 100',
|
||||
'ROUND(' . $price . ' * (i.special_price / 100), 4)',
|
||||
$price
|
||||
],
|
||||
[
|
||||
'i.tier_percent IS NOT NULL',
|
||||
'ROUND((1 - i.tier_percent / 100) * ' . $price . ', 4)',
|
||||
'NULL'
|
||||
],
|
||||
["bo.type = 'select' OR bo.type = 'radio'", '0', '1']
|
||||
);
|
||||
->willReturnCallback(function ($arg1, $arg2, $arg3) use ($price) {
|
||||
static $callCount = 0;
|
||||
$callCount++;
|
||||
switch ($callCount) {
|
||||
case 1:
|
||||
if ($arg1 === 'i.special_price > 0 AND i.special_price < 100' &&
|
||||
$arg2 === 'ROUND(' . $price . ' * (i.special_price / 100), 4)' &&
|
||||
$arg3 === $price) {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ($arg1 === 'i.tier_percent IS NOT NULL' &&
|
||||
$arg2 === 'ROUND((1 - i.tier_percent / 100) * ' . $price . ', 4)' &&
|
||||
$arg3 === 'NULL') {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if ($arg1 === "bo.type = 'select' OR bo.type = 'radio'" &&
|
||||
$arg2 === '0' &&
|
||||
$arg3 === '1') {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$select = $this->createMock(\Magento\Framework\DB\Select::class);
|
||||
$select->expects($this->once())->method('from')->willReturn($select);
|
||||
|
||||
@@ -14,6 +14,7 @@ use Magento\Framework\App\ResourceConnection;
|
||||
use Magento\Framework\DB\Adapter\AdapterInterface;
|
||||
use Magento\Framework\EntityManager\MetadataPool;
|
||||
use Magento\Framework\Model\ResourceModel\Db\Context;
|
||||
use Magento\Framework\EntityManager\EntityManager;
|
||||
|
||||
class SelectionTest extends TestCase
|
||||
{
|
||||
@@ -27,6 +28,11 @@ class SelectionTest extends TestCase
|
||||
*/
|
||||
private MetadataPool $metadataPool;
|
||||
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private EntityManager $entityManager;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -36,6 +42,7 @@ class SelectionTest extends TestCase
|
||||
|
||||
$this->context = $this->createMock(Context::class);
|
||||
$this->metadataPool = $this->createMock(MetadataPool::class);
|
||||
$this->entityManager = $this->createMock(EntityManager::class);
|
||||
}
|
||||
|
||||
public function testSaveSelectionPrice()
|
||||
@@ -82,7 +89,12 @@ class SelectionTest extends TestCase
|
||||
->willReturn('catalog_product_bundle_selection_price');
|
||||
$this->context->expects($this->once())->method('getResources')->willReturn($parentResources);
|
||||
|
||||
$selection = new ResourceSelection($this->context, $this->metadataPool, 'test_connection_name');
|
||||
$selection = new ResourceSelection(
|
||||
$this->context,
|
||||
$this->metadataPool,
|
||||
'test_connection_name',
|
||||
$this->entityManager
|
||||
);
|
||||
$selection->saveSelectionPrice($item);
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -48,7 +48,7 @@ class AbstractItemsTest extends TestCase
|
||||
->getMock();
|
||||
$this->filterManagerMock = $this->getMockBuilder(FilterManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['stripTags', 'sprintf'])
|
||||
->addMethods(['stripTags', 'sprintf'])
|
||||
->getMock();
|
||||
|
||||
$objectManager = new ObjectManager($this);
|
||||
@@ -91,7 +91,7 @@ class AbstractItemsTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getChildrenEmptyItemsDataProvider()
|
||||
public static function getChildrenEmptyItemsDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -144,7 +144,7 @@ class AbstractItemsTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getChildrenDataProvider()
|
||||
public static function getChildrenDataProvider()
|
||||
{
|
||||
return [
|
||||
[true],
|
||||
@@ -169,7 +169,7 @@ class AbstractItemsTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function isShipmentSeparatelyWithoutItemDataProvider()
|
||||
public static function isShipmentSeparatelyWithoutItemDataProvider()
|
||||
{
|
||||
return [
|
||||
[['shipment_type' => 1], true],
|
||||
@@ -206,7 +206,7 @@ class AbstractItemsTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function isShipmentSeparatelyWithItemDataProvider()
|
||||
public static function isShipmentSeparatelyWithItemDataProvider()
|
||||
{
|
||||
return [
|
||||
[['shipment_type' => 1], false, false],
|
||||
@@ -233,7 +233,7 @@ class AbstractItemsTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function isChildCalculatedWithoutItemDataProvider()
|
||||
public static function isChildCalculatedWithoutItemDataProvider()
|
||||
{
|
||||
return [
|
||||
[['product_calculations' => 0], true],
|
||||
@@ -270,7 +270,7 @@ class AbstractItemsTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function isChildCalculatedWithItemDataProvider()
|
||||
public static function isChildCalculatedWithItemDataProvider()
|
||||
{
|
||||
return [
|
||||
[['product_calculations' => 0], false, false],
|
||||
@@ -295,7 +295,7 @@ class AbstractItemsTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBundleOptionsDataProvider()
|
||||
public static function getBundleOptionsDataProvider()
|
||||
{
|
||||
return [
|
||||
[['bundle_options' => 'result'], 'result'],
|
||||
@@ -361,7 +361,7 @@ class AbstractItemsTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function canShowPriceInfoDataProvider()
|
||||
public static function canShowPriceInfoDataProvider()
|
||||
{
|
||||
return [
|
||||
[true, ['product_calculations' => 0], true],
|
||||
@@ -390,7 +390,7 @@ class AbstractItemsTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getValueHtmlWithoutShipmentSeparatelyDataProvider()
|
||||
public static function getValueHtmlWithoutShipmentSeparatelyDataProvider()
|
||||
{
|
||||
return [
|
||||
[1],
|
||||
|
||||
@@ -99,7 +99,7 @@ class AppendUpsellProductsObserverTest extends TestCase
|
||||
|
||||
$this->bundleCollectionMock = $this->getMockBuilder(ProductCollection::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([
|
||||
->onlyMethods([
|
||||
'addAttributeToSelect',
|
||||
'addFieldToFilter',
|
||||
'addFinalPrice',
|
||||
@@ -115,37 +115,37 @@ class AppendUpsellProductsObserverTest extends TestCase
|
||||
|
||||
$this->bundleDataMock = $this->getMockBuilder(BundleHelper::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getAllowedSelectionTypes'])
|
||||
->onlyMethods(['getAllowedSelectionTypes'])
|
||||
->getMock();
|
||||
|
||||
$this->bundleSelectionMock = $this->getMockBuilder(Selection::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getParentIdsByChild'])
|
||||
->onlyMethods(['getParentIdsByChild'])
|
||||
->getMock();
|
||||
|
||||
$this->configMock = $this->getMockBuilder(CatalogConfig::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getProductAttributes'])
|
||||
->onlyMethods(['getProductAttributes'])
|
||||
->getMock();
|
||||
|
||||
$this->eventMock = $this->getMockBuilder(Event::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getProduct', 'getCollection', 'getLimit'])
|
||||
->addMethods(['getProduct', 'getCollection', 'getLimit'])
|
||||
->getMock();
|
||||
|
||||
$this->collectionMock = $this->getMockBuilder(Event::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['setItems', 'getItems'])
|
||||
->addMethods(['setItems', 'getItems'])
|
||||
->getMock();
|
||||
|
||||
$this->productMock = $this->getMockBuilder(Product::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getCollection', 'getId', 'getTypeId'])
|
||||
->onlyMethods(['getCollection', 'getId', 'getTypeId'])
|
||||
->getMock();
|
||||
|
||||
$this->productVisibilityMock = $this->getMockBuilder(Visibility::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getVisibleInCatalogIds'])
|
||||
->onlyMethods(['getVisibleInCatalogIds'])
|
||||
->getMock();
|
||||
|
||||
$this->observer = $this->objectManager->getObject(
|
||||
|
||||
@@ -51,12 +51,12 @@ class InitOptionRendererObserverTest extends TestCase
|
||||
$this->objectManager = new ObjectManager($this);
|
||||
$this->observerMock = $this->getMockBuilder(Observer::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getBlock'])
|
||||
->addMethods(['getBlock'])
|
||||
->getMock();
|
||||
|
||||
$this->blockMock = $this->getMockBuilder(Options::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['addOptionsRenderCfg'])
|
||||
->onlyMethods(['addOptionsRenderCfg'])
|
||||
->getMock();
|
||||
|
||||
$this->observer = $this->objectManager->getObject(InitOptionRendererObserver::class);
|
||||
|
||||
@@ -60,7 +60,7 @@ class SetAttributeTabBlockObserverTest extends TestCase
|
||||
$this->observerMock = $this->createMock(Observer::class);
|
||||
$this->eventMock = $this->getMockBuilder(Event::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getProduct'])
|
||||
->addMethods(['getProduct'])
|
||||
->getMock();
|
||||
$this->productMock = $this->getMockBuilder(Product::class)
|
||||
->disableOriginalConstructor()
|
||||
|
||||
@@ -84,7 +84,8 @@ class CalculatorTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->saleableItem = $this->getMockBuilder(Product::class)
|
||||
->setMethods(['getPriceInfo', 'getPriceType', '__wakeup', 'getStore', 'getTypeInstance'])
|
||||
->addMethods(['getPriceType'])
|
||||
->onlyMethods(['getPriceInfo', '__wakeup', 'getStore', 'getTypeInstance'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
@@ -192,17 +193,17 @@ class CalculatorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function dataProviderForGetterAmount()
|
||||
public static function dataProviderForGetterAmount()
|
||||
{
|
||||
return [
|
||||
// first case with minimal amount
|
||||
'case with getting minimal amount' => $this->getCaseWithMinAmount(),
|
||||
'case with getting minimal amount' => self::getCaseWithMinAmount(),
|
||||
// second case with maximum amount
|
||||
'case with getting maximum amount' => $this->getCaseWithMaxAmount(),
|
||||
'case with getting maximum amount' => self::getCaseWithMaxAmount(),
|
||||
// third case without saleable items
|
||||
'case without saleable items' => $this->getCaseWithoutSaleableItems(),
|
||||
'case without saleable items' => self::getCaseWithoutSaleableItems(),
|
||||
// fourth case without require options
|
||||
'case without required options' => $this->getCaseMinAmountWithoutRequiredOptions(),
|
||||
'case without required options' => self::getCaseMinAmountWithoutRequiredOptions(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -221,7 +222,8 @@ class CalculatorTest extends TestCase
|
||||
{
|
||||
/** @var MockObject|\Magento\Framework\Pricing\Amount\Base $amount */
|
||||
$amount = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class)
|
||||
->setMethods(['getAdjustmentAmounts', 'getValue', '__wakeup'])
|
||||
->addMethods(['__wakeup'])
|
||||
->onlyMethods(['getAdjustmentAmounts', 'getValue'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$amount->expects($this->any())->method('getAdjustmentAmounts')
|
||||
@@ -263,7 +265,8 @@ class CalculatorTest extends TestCase
|
||||
{
|
||||
/** @var MockObject|Product $selection */
|
||||
$selection = $this->getMockBuilder(Product::class)
|
||||
->setMethods(['isSalable', 'getQuantity', 'getAmount', 'getProduct', '__wakeup'])
|
||||
->addMethods(['getQuantity', 'getAmount', 'getProduct'])
|
||||
->onlyMethods(['isSalable', '__wakeup'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
@@ -277,7 +280,8 @@ class CalculatorTest extends TestCase
|
||||
$selection->expects($this->any())->method('getQuantity')->willReturn(1);
|
||||
|
||||
$innerProduct = $this->getMockBuilder(Product::class)
|
||||
->setMethods(['getSelectionCanChangeQty', '__wakeup'])
|
||||
->addMethods(['getSelectionCanChangeQty'])
|
||||
->onlyMethods(['__wakeup'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$innerProduct->expects($this->any())->method('getSelectionCanChangeQty')->willReturn(false);
|
||||
@@ -291,7 +295,7 @@ class CalculatorTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCaseWithMinAmount()
|
||||
protected static function getCaseWithMinAmount()
|
||||
{
|
||||
return [
|
||||
'amountForBundle' => [
|
||||
@@ -334,7 +338,7 @@ class CalculatorTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCaseWithMaxAmount()
|
||||
protected static function getCaseWithMaxAmount()
|
||||
{
|
||||
return [
|
||||
'amountForBundle' => [
|
||||
@@ -412,7 +416,7 @@ class CalculatorTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCaseWithoutSaleableItems()
|
||||
protected static function getCaseWithoutSaleableItems()
|
||||
{
|
||||
return [
|
||||
'amountForBundle' => [
|
||||
@@ -447,7 +451,7 @@ class CalculatorTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCaseMinAmountWithoutRequiredOptions()
|
||||
protected static function getCaseMinAmountWithoutRequiredOptions()
|
||||
{
|
||||
return [
|
||||
'amountForBundle' => [
|
||||
@@ -507,7 +511,7 @@ class CalculatorTest extends TestCase
|
||||
/** @var Calculator|MockObject $calculatorMock */
|
||||
$calculatorMock = $this->getMockBuilder(Calculator::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['calculateBundleAmount'])
|
||||
->onlyMethods(['calculateBundleAmount'])
|
||||
->getMock();
|
||||
|
||||
$calculatorMock->expects($this->once())
|
||||
@@ -528,7 +532,7 @@ class CalculatorTest extends TestCase
|
||||
/** @var Calculator|MockObject $calculatorMock */
|
||||
$calculatorMock = $this->getMockBuilder(Calculator::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getOptionsAmount'])
|
||||
->onlyMethods(['getOptionsAmount'])
|
||||
->getMock();
|
||||
|
||||
$calculatorMock->expects($this->once())
|
||||
@@ -551,7 +555,7 @@ class CalculatorTest extends TestCase
|
||||
/** @var Calculator|MockObject $calculatorMock */
|
||||
$calculatorMock = $this->getMockBuilder(Calculator::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getOptionsAmount'])
|
||||
->onlyMethods(['getOptionsAmount'])
|
||||
->getMock();
|
||||
|
||||
$calculatorMock->expects($this->once())
|
||||
@@ -577,7 +581,7 @@ class CalculatorTest extends TestCase
|
||||
/** @var Calculator|MockObject $calculatorMock */
|
||||
$calculatorMock = $this->getMockBuilder(Calculator::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['calculateBundleAmount', 'getSelectionAmounts'])
|
||||
->onlyMethods(['calculateBundleAmount', 'getSelectionAmounts'])
|
||||
->getMock();
|
||||
|
||||
$selections[] = $this->getMockBuilder(BundleSelectionPrice::class)
|
||||
@@ -607,7 +611,7 @@ class CalculatorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionsAmountDataProvider()
|
||||
public static function getOptionsAmountDataProvider()
|
||||
{
|
||||
return [
|
||||
'true, true' => [
|
||||
|
||||
@@ -56,7 +56,8 @@ class BundleRegularPriceTest extends TestCase
|
||||
{
|
||||
$this->saleableInterfaceMock = $this->getMockBuilder(Product::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getPriceInfo', 'getPriceType', 'getPrice'])
|
||||
->addMethods(['getPriceType'])
|
||||
->onlyMethods(['getPriceInfo', 'getPrice'])
|
||||
->getMock();
|
||||
$this->bundleCalculatorMock = $this->createMock(
|
||||
BundleCalculatorInterface::class
|
||||
|
||||
@@ -97,7 +97,8 @@ class FinalPriceTest extends TestCase
|
||||
{
|
||||
$this->saleableInterfaceMock = $this->getMockBuilder(Product::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getPriceType', 'getPriceInfo'])
|
||||
->addMethods(['getPriceType'])
|
||||
->onlyMethods(['getPriceInfo'])
|
||||
->getMock();
|
||||
$this->bundleCalculatorMock = $this->createMock(
|
||||
BundleCalculatorInterface::class
|
||||
@@ -169,7 +170,7 @@ class FinalPriceTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getValueDataProvider()
|
||||
public static function getValueDataProvider()
|
||||
{
|
||||
return [
|
||||
[false, false, 0],
|
||||
@@ -229,7 +230,7 @@ class FinalPriceTest extends TestCase
|
||||
$this->prepareMock();
|
||||
$customOptions = [
|
||||
$this->getMockBuilder(ProductCustomOptionInterface::class)
|
||||
->setMethods(['setProduct'])
|
||||
->addMethods(['setProduct'])
|
||||
->getMockForAbstractClass()
|
||||
];
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ class TierPriceTest extends TestCase
|
||||
$this->priceInfo = $this->createMock(Base::class);
|
||||
|
||||
$this->product = $this->getMockBuilder(Product::class)
|
||||
->setMethods(['getPriceInfo', 'hasCustomerGroupId', 'getCustomerGroupId', 'getResource', '__wakeup'])
|
||||
->addMethods(['hasCustomerGroupId', 'getCustomerGroupId'])
|
||||
->onlyMethods(['getPriceInfo', 'getResource', '__wakeup'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
@@ -127,7 +128,7 @@ class TierPriceTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerForGetterTierPriceList()
|
||||
public static function providerForGetterTierPriceList()
|
||||
{
|
||||
return [
|
||||
'base case' => [
|
||||
@@ -220,7 +221,7 @@ class TierPriceTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerForTestGetSavePercent()
|
||||
public static function providerForTestGetSavePercent()
|
||||
{
|
||||
return [
|
||||
'no fraction' => [9.0000, 8.1, 10],
|
||||
|
||||
@@ -77,8 +77,12 @@ class FinalPriceBoxTest extends TestCase
|
||||
}
|
||||
$priceInfo
|
||||
->method('getPrice')
|
||||
->withConsecutive(...$priceWithArgs)
|
||||
->willReturnOnConsecutiveCalls(...$priceWillReturnArgs);
|
||||
->willReturnCallback(function ($priceWithArgs) use ($priceWillReturnArgs) {
|
||||
static $callCount = 0;
|
||||
$returnValue = $priceWillReturnArgs[$callCount] ?? null;
|
||||
$callCount++;
|
||||
return $returnValue;
|
||||
});
|
||||
|
||||
$bundlePrice->expects($this->once())
|
||||
->method('getMinimalPrice')
|
||||
@@ -99,7 +103,7 @@ class FinalPriceBoxTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function showRangePriceDataProvider(): array
|
||||
public static function showRangePriceDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'bundle options different, custom options noop' => [
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ abstract class AbstractModifierTest extends TestCase
|
||||
$this->locatorMock = $this->getMockBuilder(LocatorInterface::class)
|
||||
->getMockForAbstractClass();
|
||||
$this->productMock = $this->getMockBuilder(ProductInterface::class)
|
||||
->setMethods(['getPriceType'])
|
||||
->addMethods(['getPriceType'])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->locatorMock->expects($this->any())
|
||||
|
||||
+6
-2
@@ -148,7 +148,11 @@ class BundlePanelTest extends TestCase
|
||||
];
|
||||
$this->arrayManagerMock
|
||||
->method('merge')
|
||||
->withConsecutive([], [], [], [], [], [], [], [], [], [], [], [], $metaArgument);
|
||||
->willReturnCallback(function ($arg1) use ($metaArgument) {
|
||||
if (is_null($arg1) || $arg1 == $metaArgument) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
$this->bundlePanelModel->modifyMeta($sourceMeta);
|
||||
}
|
||||
|
||||
@@ -157,7 +161,7 @@ class BundlePanelTest extends TestCase
|
||||
*
|
||||
* @return string[][]
|
||||
*/
|
||||
public function getDataModifyMeta(): array
|
||||
public static function getDataModifyMeta(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ class BundlePriceTest extends TestCase
|
||||
->getMockForAbstractClass();
|
||||
$this->priceInfoFactory = $this->getMockBuilder(PriceInfoInterfaceFactory::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['create'])
|
||||
->onlyMethods(['create'])
|
||||
->getMock();
|
||||
$this->formattedPriceInfoBuilder = $this->getMockBuilder(FormattedPriceInfoBuilder::class)
|
||||
->disableOriginalConstructor()
|
||||
@@ -83,9 +83,9 @@ class BundlePriceTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$priceInfo = $this->getMockBuilder(PriceInfoInterface::class)
|
||||
->setMethods(
|
||||
->addMethods(['getPrice'])
|
||||
->onlyMethods(
|
||||
[
|
||||
'getPrice',
|
||||
'setMaxPrice',
|
||||
'setMaxRegularPrice',
|
||||
'setMinimalPrice',
|
||||
|
||||
@@ -95,10 +95,14 @@ class PurgeCacheTest extends TestCase
|
||||
}
|
||||
$this->socketAdapterMock
|
||||
->method('connect')
|
||||
->withConsecutive(...$connectWithArgs);
|
||||
->willReturnCallback(function (...$connectWithArgs) {
|
||||
return null;
|
||||
});
|
||||
$this->socketAdapterMock
|
||||
->method('write')
|
||||
->withConsecutive(...$writeWithArgs);
|
||||
->willReturnCallback(function (...$writeWithArgs) {
|
||||
return null;
|
||||
});
|
||||
$this->socketAdapterMock
|
||||
->method('read');
|
||||
|
||||
@@ -113,6 +117,7 @@ class PurgeCacheTest extends TestCase
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function testSendMultiPurgeRequest(): void
|
||||
{
|
||||
@@ -140,16 +145,36 @@ class PurgeCacheTest extends TestCase
|
||||
|
||||
$this->socketAdapterMock->expects($this->exactly(2))
|
||||
->method('write')
|
||||
->withConsecutive(
|
||||
[
|
||||
'PURGE', $uri, '1.1',
|
||||
['X-Magento-Tags-Pattern' => implode('|', $tagsSplitA), 'Host' => $uri->getHost()]
|
||||
],
|
||||
[
|
||||
'PURGE', $uri, '1.1',
|
||||
['X-Magento-Tags-Pattern' => implode('|', $tagsSplitB), 'Host' => $uri->getHost()]
|
||||
]
|
||||
);
|
||||
->willReturnCallback(function ($arg1, $arg2, $arg3, $arg4) use ($uri, $tagsSplitA, $tagsSplitB) {
|
||||
static $callCount = 0;
|
||||
$callCount++;
|
||||
switch ($callCount) {
|
||||
case 1:
|
||||
if ($arg1 === 'PURGE' &&
|
||||
$arg2 === $uri &&
|
||||
$arg3 === '1.1' &&
|
||||
is_array($arg4) &&
|
||||
isset($arg4['X-Magento-Tags-Pattern']) &&
|
||||
$arg4['X-Magento-Tags-Pattern'] === implode('|', $tagsSplitA) &&
|
||||
isset($arg4['Host']) &&
|
||||
$arg4['Host'] === $uri->getHost()) {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ($arg1 === 'PURGE' &&
|
||||
$arg2 === $uri &&
|
||||
$arg3 === '1.1' &&
|
||||
is_array($arg4) &&
|
||||
isset($arg4['X-Magento-Tags-Pattern']) &&
|
||||
$arg4['X-Magento-Tags-Pattern'] === implode('|', $tagsSplitB) &&
|
||||
isset($arg4['Host']) &&
|
||||
$arg4['Host'] === $uri->getHost()) {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$this->socketAdapterMock->expects($this->exactly(2))
|
||||
->method('close');
|
||||
@@ -160,7 +185,7 @@ class PurgeCacheTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function sendPurgeRequestDataProvider(): array
|
||||
public static function sendPurgeRequestDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -55,13 +55,14 @@ class IndexTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
|
||||
->setMethods(['getPost', 'getContent'])
|
||||
->addMethods(['getPost', 'getContent'])
|
||||
->getMockForAbstractClass();
|
||||
$this->layoutMock = $this->getMockBuilder(LayoutInterface::class)
|
||||
->setMethods(['createBlock'])
|
||||
->onlyMethods(['createBlock'])
|
||||
->getMockForAbstractClass();
|
||||
$this->blockMock = $this->getMockBuilder(BlockInterface::class)
|
||||
->setMethods(['setFormId', 'setIsAjax', 'toHtml'])
|
||||
->addMethods(['setFormId', 'setIsAjax'])
|
||||
->onlyMethods(['toHtml'])
|
||||
->getMockForAbstractClass();
|
||||
$this->jsonResultFactoryMock = $this->createMock(ResultJsonFactory::class);
|
||||
$this->jsonResultMock = $this->createMock(ResultJson::class);
|
||||
@@ -142,7 +143,8 @@ class IndexTest extends TestCase
|
||||
private function getCaptchaModelMock(string $imageSource): CaptchaInterface
|
||||
{
|
||||
$modelMock = $this->getMockBuilder(CaptchaInterface::class)
|
||||
->setMethods(['generate', 'getBlockName', 'getImgSrc'])
|
||||
->onlyMethods(['generate', 'getBlockName'])
|
||||
->addMethods(['getImgSrc'])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$modelMock->method('getImgSrc')
|
||||
|
||||
@@ -23,6 +23,8 @@ use Magento\Store\Model\Store;
|
||||
use Magento\Store\Model\Website;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Magento\Framework\Math\Random;
|
||||
use Magento\Authorization\Model\UserContextInterface;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
@@ -91,7 +93,9 @@ class DataTest extends TestCase
|
||||
$this->createMock(SessionManager::class),
|
||||
$this->createMock(Data::class),
|
||||
$this->createPartialMock(LogFactory::class, ['create']),
|
||||
'user_create'
|
||||
'user_create',
|
||||
$this->createMock(Random::class),
|
||||
$this->createMock(UserContextInterface::class)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ use Magento\Framework\Math\Random;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\Session\Storage;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\Session\SessionStartChecker;
|
||||
use Magento\Store\Model\Store;
|
||||
use Magento\Store\Model\StoreManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
@@ -31,7 +32,7 @@ class DefaultTest extends TestCase
|
||||
/**
|
||||
* Expiration frame
|
||||
*/
|
||||
const EXPIRE_FRAME = 86400;
|
||||
private const EXPIRE_FRAME = 86400;
|
||||
|
||||
/**
|
||||
* Captcha default config data
|
||||
@@ -120,19 +121,6 @@ class DefaultTest extends TestCase
|
||||
$this->_getStoreStub()
|
||||
);
|
||||
|
||||
// \Magento\Customer\Model\Session
|
||||
$this->_objectManager = $this->getMockForAbstractClass(ObjectManagerInterface::class);
|
||||
$this->_objectManager->expects(
|
||||
$this->any()
|
||||
)->method(
|
||||
'get'
|
||||
)->willReturnMap(
|
||||
[
|
||||
Data::class => $this->_getHelperStub(),
|
||||
Session::class => $this->session,
|
||||
]
|
||||
);
|
||||
|
||||
$this->_resLogFactory = $this->createPartialMock(
|
||||
LogFactory::class,
|
||||
['create']
|
||||
@@ -284,12 +272,20 @@ class DefaultTest extends TestCase
|
||||
protected function _getSessionStub()
|
||||
{
|
||||
$helper = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
SessionStartChecker::class,
|
||||
$this->createMock(SessionStartChecker::class)
|
||||
]
|
||||
];
|
||||
$helper->prepareObjectManager($objects);
|
||||
$sessionArgs = $helper->getConstructArguments(
|
||||
Session::class,
|
||||
['storage' => new Storage()]
|
||||
);
|
||||
$session = $this->getMockBuilder(Session::class)
|
||||
->setMethods(['isLoggedIn', 'getUserCreateWord'])
|
||||
->addMethods(['getUserCreateWord'])
|
||||
->onlyMethods(['isLoggedIn'])
|
||||
->setConstructorArgs($sessionArgs)
|
||||
->getMock();
|
||||
$session->expects($this->any())->method('isLoggedIn')->willReturn(false);
|
||||
@@ -315,7 +311,7 @@ class DefaultTest extends TestCase
|
||||
$helper = $this->getMockBuilder(
|
||||
Data::class
|
||||
)->disableOriginalConstructor()
|
||||
->setMethods(
|
||||
->onlyMethods(
|
||||
['getConfig', 'getFonts', '_getWebsiteCode', 'getImgUrl']
|
||||
)->getMock();
|
||||
|
||||
@@ -415,7 +411,7 @@ class DefaultTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function isShownToLoggedInUserDataProvider()
|
||||
public static function isShownToLoggedInUserDataProvider()
|
||||
{
|
||||
return [
|
||||
[true, 'contact_us'],
|
||||
@@ -449,7 +445,7 @@ class DefaultTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function generateWordProvider()
|
||||
public static function generateWordProvider()
|
||||
{
|
||||
return [
|
||||
['ABC123'],
|
||||
|
||||
@@ -36,7 +36,7 @@ class CheckUserEditObserverTest extends TestCase
|
||||
/** @var ActionFlag|MockObject */
|
||||
protected $actionFlagMock;
|
||||
|
||||
/* @var \Magento\Framework\Message\ManagerInterface|MockObject */
|
||||
/** @var \Magento\Framework\Message\ManagerInterface|MockObject */
|
||||
protected $messageManagerMock;
|
||||
|
||||
/** @var RedirectInterface|MockObject */
|
||||
@@ -165,7 +165,11 @@ class CheckUserEditObserverTest extends TestCase
|
||||
$message = __('The account is locked. Please wait and try again or contact %1.', $email);
|
||||
$this->messageManagerMock->expects($this->exactly(2))
|
||||
->method('addErrorMessage')
|
||||
->withConsecutive([$message], [__('Incorrect CAPTCHA')]);
|
||||
->willReturnCallback(function ($arg1) use ($message) {
|
||||
if ($arg1 == $message || $arg1 == (__('Incorrect CAPTCHA'))) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
$this->actionFlagMock->expects($this->once())
|
||||
->method('set')
|
||||
|
||||
+7
-5
@@ -29,8 +29,8 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class CheckUserForgotPasswordBackendObserverTest extends TestCase
|
||||
{
|
||||
const STUB_EMAIL = 'stub@test.mail';
|
||||
const STUB_REQUEST_PARAMS = ['STUB_PARAM'];
|
||||
private const STUB_EMAIL = 'stub@test.mail';
|
||||
private const STUB_REQUEST_PARAMS = ['STUB_PARAM'];
|
||||
|
||||
/**
|
||||
* @var MockObject|DataHelper
|
||||
@@ -97,7 +97,7 @@ class CheckUserForgotPasswordBackendObserverTest extends TestCase
|
||||
$this->helperMock = $this->createMock(DataHelper::class);
|
||||
$this->captchaStringResolverMock = $this->createMock(CaptchaStringResolver::class);
|
||||
$this->sessionMock = $this->getMockBuilder(SessionManagerInterface::class)
|
||||
->setMethods(['setEmail'])
|
||||
->addMethods(['setEmail'])
|
||||
->getMockForAbstractClass();
|
||||
$this->actionFlagMock = $this->createMock(ActionFlag::class);
|
||||
$this->messageManagerMock = $this->getMockForAbstractClass(ManagerInterface::class);
|
||||
@@ -117,7 +117,8 @@ class CheckUserForgotPasswordBackendObserverTest extends TestCase
|
||||
);
|
||||
|
||||
$this->captchaMock = $this->getMockBuilder(CaptchaInterface::class)
|
||||
->setMethods(['isRequired', 'isCorrect'])
|
||||
->addMethods(['isRequired'])
|
||||
->onlyMethods(['isCorrect'])
|
||||
->getMockForAbstractClass();
|
||||
$this->helperMock->expects($this->once())
|
||||
->method('getCaptcha')
|
||||
@@ -128,7 +129,8 @@ class CheckUserForgotPasswordBackendObserverTest extends TestCase
|
||||
|
||||
$this->controllerMock = $this->getMockBuilder(Action::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getUrl', 'getResponse'])
|
||||
->addMethods(['getUrl'])
|
||||
->onlyMethods(['getResponse'])
|
||||
->getMockForAbstractClass();
|
||||
$this->controllerMock->expects($this->any())
|
||||
->method('getResponse')
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Category;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Catalog\Block\Adminhtml\Category\AbstractCategory;
|
||||
use Magento\Catalog\Model\Category;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Store\Model\Store;
|
||||
@@ -59,6 +61,18 @@ class AbstractCategoryTest extends TestCase
|
||||
{
|
||||
$this->objectManager = new ObjectManager($this);
|
||||
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$this->objectManager->prepareObjectManager($objects);
|
||||
|
||||
$this->contextMock = $this->createMock(Context::class);
|
||||
|
||||
$this->requestMock = $this->getMockBuilder(
|
||||
|
||||
+14
@@ -10,6 +10,7 @@ namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute\Edit\Tab;
|
||||
use Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced;
|
||||
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
|
||||
use Magento\Config\Model\Config\Source\Yesno;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
|
||||
use Magento\Eav\Helper\Data as EavHelper;
|
||||
use Magento\Eav\Model\Entity\Type as EntityType;
|
||||
@@ -19,6 +20,7 @@ use Magento\Framework\Data\Form\Element\Text;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Framework\Filesystem\Directory\ReadInterface;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\Stdlib\DateTime;
|
||||
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
|
||||
@@ -79,6 +81,18 @@ class AdvancedTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$objectManager = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$objectManager->prepareObjectManager($objects);
|
||||
|
||||
$this->registry = $this->createMock(Registry::class);
|
||||
$this->formFactory = $this->createMock(FormFactory::class);
|
||||
$this->yesNo = $this->createMock(Yesno::class);
|
||||
|
||||
@@ -10,13 +10,35 @@ namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid;
|
||||
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class GridTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$objectManager = new ObjectManager($this);
|
||||
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$objectManager->prepareObjectManager($objects);
|
||||
}
|
||||
|
||||
public function testGetRowUrl()
|
||||
{
|
||||
$attribute = $this->createMock(Attribute::class);
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class OptionsTest extends TestCase
|
||||
['resource' => $this->_optionResource, 'optionValueFactory' => $optionFactoryMock]
|
||||
);
|
||||
$dateBlock = $this->getMockBuilder(Options::class)
|
||||
->setMethods(['setSkipJsReloadPrice'])
|
||||
->addMethods(['setSkipJsReloadPrice'])
|
||||
->setConstructorArgs(['context' => $context, 'option' => $option])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class GenericTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->productMock = $this->getMockBuilder(ProductInterface::class)
|
||||
->setMethods(['isReadonly', 'isDuplicable'])
|
||||
->addMethods(['isReadonly', 'isDuplicable'])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->registryMock->expects($this->any())
|
||||
|
||||
@@ -16,6 +16,8 @@ use Magento\CatalogInventory\Api\StockConfigurationInterface;
|
||||
use Magento\CatalogInventory\Api\StockRegistryInterface;
|
||||
use Magento\CatalogInventory\Model\Source\Backorders;
|
||||
use Magento\CatalogInventory\Model\Source\Stock;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
use Magento\Framework\Module\Manager;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
@@ -83,6 +85,18 @@ class InventoryTest extends TestCase
|
||||
{
|
||||
$objectManager = new ObjectManager($this);
|
||||
|
||||
$objects = [
|
||||
[
|
||||
JsonHelper::class,
|
||||
$this->createMock(JsonHelper::class)
|
||||
],
|
||||
[
|
||||
DirectoryHelper::class,
|
||||
$this->createMock(DirectoryHelper::class)
|
||||
]
|
||||
];
|
||||
$objectManager->prepareObjectManager($objects);
|
||||
|
||||
$this->contextMock = $this->createPartialMock(
|
||||
Context::class,
|
||||
['getRequest', 'getStoreManager']
|
||||
|
||||
+13
@@ -9,7 +9,9 @@ namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Helper\Form;
|
||||
|
||||
use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category;
|
||||
use Magento\Framework\AuthorizationInterface;
|
||||
use Magento\Framework\Math\Random;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\View\Helper\SecureHtmlRenderer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CategoryTest extends TestCase
|
||||
@@ -30,6 +32,17 @@ class CategoryTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$this->objectManager = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
SecureHtmlRenderer::class,
|
||||
$this->createMock(SecureHtmlRenderer::class)
|
||||
],
|
||||
[
|
||||
Random::class,
|
||||
$this->createMock(Random::class)
|
||||
]
|
||||
];
|
||||
$this->objectManager->prepareObjectManager($objects);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+15
-1
@@ -13,7 +13,9 @@ use Magento\Framework\Data\Form\Element\CollectionFactory;
|
||||
use Magento\Framework\Data\Form\Element\Factory;
|
||||
use Magento\Framework\Data\Form\Element\Radios;
|
||||
use Magento\Framework\Locale\Format;
|
||||
use Magento\Framework\Math\Random;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use Magento\Framework\View\Helper\SecureHtmlRenderer;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -46,6 +48,18 @@ class WeightTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$objectManager = new ObjectManager($this);
|
||||
$objects = [
|
||||
[
|
||||
SecureHtmlRenderer::class,
|
||||
$this->createMock(SecureHtmlRenderer::class)
|
||||
],
|
||||
[
|
||||
Random::class,
|
||||
$this->createMock(Random::class)
|
||||
]
|
||||
];
|
||||
$objectManager->prepareObjectManager($objects);
|
||||
$this->weightSwitcher = $this->getMockBuilder(Radios::class)
|
||||
->addMethods(['setName', 'setLabel'])
|
||||
->onlyMethods(['setId', 'setForm'])
|
||||
@@ -72,7 +86,7 @@ class WeightTest extends TestCase
|
||||
['create']
|
||||
);
|
||||
|
||||
$this->_model = (new ObjectManager($this))->getObject(
|
||||
$this->_model = $objectManager->getObject(
|
||||
Weight::class,
|
||||
[
|
||||
'factoryElement' => $this->factory,
|
||||
|
||||
Loaded 100 of 650 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user