Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Fixed - Admin - dropdown toggle arrow not working on closing #20240 #6

Merged
merged 66 commits into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
06443f9
#18192, Fixed rating issue website wise
Oct 27, 2018
cb6ff7e
updated code as per given instruction
Oct 27, 2018
56a0f11
code modification
Oct 29, 2018
9c59356
core modified as per instructions
Oct 30, 2018
fd4dd39
updated code
Oct 30, 2018
a26b9bd
code updated as per instructions
Nov 13, 2018
30a6d5a
Fixed code style issues
Nov 18, 2018
c307953
MAGETWO-97000: Not all sizes are available in the layered navigation …
nikita-shcherbatykh Dec 31, 2018
f47ed29
MAGETWO-97393: Impossible to enable shared catalog through cli command
yelahin-serhiy Jan 4, 2019
b9ba4cb
MAGETWO-97281: [Magento Cloud] Custom Price not shown in Quotes
serhii-balko Jan 4, 2019
0455fcf
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-97393
yelahin-serhiy Jan 4, 2019
4d451f8
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-97393
yelahin-serhiy Jan 8, 2019
3a3fed4
Merge branch '2.2-develop' into MAGETWO-97000
nikita-shcherbatykh Jan 8, 2019
b58256d
MAGETWO-97393: Impossible to enable shared catalog through cli command
yelahin-serhiy Jan 8, 2019
b853f99
MAGETWO-94112: Configurable "As low As" Product Price Not Updating Co…
rostyslav-hymon Jan 10, 2019
3b4581c
ISSUE-16198: Category image remain after deleted.
p-bystritsky Jan 10, 2019
4afb3db
ENGCOM-3826: magento/magento2#16198: Category image remain after dele…
magento-engcom-team Jan 10, 2019
53c188d
Move website_name column into columnSet
bradleyfrye Dec 20, 2018
979e552
ISSUE-16198: Static test fix.
p-bystritsky Jan 11, 2019
e5ddeb7
ENGCOM-3826: magento/magento2#16198: Category image remain after dele…
magento-engcom-team Jan 11, 2019
73f43d7
ENGCOM-3833: 2.2 develop pr port 18888 #20183
magento-engcom-team Jan 11, 2019
4a46cd1
MAGETWO-97312: Order Summary doesn't show Qty of Bundle Product ordered
yelahin-serhiy Jan 14, 2019
fe674a6
MAGETWO-96886: A new customer created via an admin order has their Cu…
serhii-balko Jan 14, 2019
cf04937
MAGETWO-96886: A new customer created via an admin order has their Cu…
serhii-balko Jan 14, 2019
7e3ea1b
added json hex tag serializer and use it.
Jun 15, 2018
f72fb42
Fix static tests.
nmalevanec Jan 3, 2019
dbb905c
Fix static test.
nmalevanec Jan 3, 2019
0247fc3
Don't return categoryId from registry if the product doesn't belong i…
ErikPel Nov 20, 2018
99c69fe
ENGCOM-3859: [Backport] Don't return categoryId from registry if the …
magento-engcom-team Jan 14, 2019
f4190f5
Merge remote-tracking branch 'origin/MAGETWO-94112' into 2.2-develop-…
serhii-balko Jan 15, 2019
e5be829
Merge branch 'MAGETWO-97281' into 2.2-develop-pr18
serhii-balko Jan 15, 2019
54121e7
Merge branch 'MAGETWO-96886' into 2.2-develop-pr18
serhii-balko Jan 15, 2019
5087a3f
Merge remote-tracking branch 'origin/MAGETWO-97000' into 2.2-develop-…
serhii-balko Jan 15, 2019
50c93fe
Merge remote-tracking branch 'origin/MAGETWO-97312' into 2.2-develop-…
serhii-balko Jan 15, 2019
701d4f0
Merge remote-tracking branch 'origin/MAGETWO-97393' into 2.2-develop-…
serhii-balko Jan 15, 2019
de64b09
ISSUE-20296: "@magentoDataIsolation" is used instead of "@magentoDbIs…
p-bystritsky Jan 15, 2019
5eda9d3
ENGCOM-3873: [Backport] Move website_name column into columnSet #20185
magento-engcom-team Jan 15, 2019
0d5a245
ENGCOM-3875: ISSUE-20296: '@magentoDataIsolation' is used instead of …
magento-engcom-team Jan 15, 2019
f9a03d8
issus fixed #20158 Store switcher not aligned proper in tab view
cedarvinda Jan 10, 2019
82ad1ca
ENGCOM-3825: Static test fix.
p-bystritsky Jan 11, 2019
6c5cba7
checkbox alignment issue resolved
speedy008 Jan 12, 2019
40f64f9
Update uploader.php fix issue 20098
Jan 8, 2019
f412fe4
ENGCOM-3877: [Backport] Product image failure when importing through…
magento-engcom-team Jan 16, 2019
b73b312
Merge branch 2.2-develop into ENGCOM-3833-magento-magento2-20183
magento-engcom-team Jan 16, 2019
c3f4d5d
Merge remote-tracking branch 'mainline/2.2-develop' into 2.2-develop-…
nmalevanec Jan 16, 2019
31bf4b2
Fix unit test.
nmalevanec Jan 16, 2019
c0730dc
displaying html content for file type option on order view admin area
mahesh-rajawat Jan 16, 2019
c281661
ENGCOM-3880: Fixed#20352: displaying html content for file type optio…
magento-engcom-team Jan 16, 2019
c9f19ca
ENGCOM-3882: [Backport] issus fixed #20158 Store switcher not aligned…
magento-engcom-team Jan 16, 2019
ffe9904
ENGCOM-3884: [Backport] Fix issue 20232 : Backend order credit card d…
magento-engcom-team Jan 16, 2019
d3359c4
ENGCOM-3858: [Backport] Use the new json serializer which throws an e…
magento-engcom-team Jan 17, 2019
a1d67f6
Merge branch 2.2-develop into ENGCOM-3873-magento-magento2-20185
magento-engcom-team Jan 17, 2019
8c4aa0e
merge magento/2.2-develop into magento-tsg-csl3/2.2-develop-pr18
magento-cicd2 Jan 17, 2019
530e0d1
Merge pull request #3605 from magento-tsg-csl3/2.2-develop-pr18
Jan 18, 2019
76234eb
ENGCOM-3884: [Backport] Fix issue 20232 : Backend order credit card d…
Jan 18, 2019
ab2dff4
ENGCOM-3882: [Backport] issus fixed #20158 Store switcher not aligned…
Jan 18, 2019
88499d0
ENGCOM-3880: Fixed#20352: displaying html content for file type optio…
Jan 18, 2019
8d05948
ENGCOM-3877: [Backport] Product image failure when importing through…
Jan 18, 2019
0d6b16f
ENGCOM-3875: ISSUE-20296: "@magentoDataIsolation" is used instead of …
Jan 18, 2019
a32e880
ENGCOM-3873: [Backport] Move website_name column into columnSet #20185
Jan 18, 2019
7900322
ENGCOM-3859: [Backport] Don't return categoryId from registry if the …
Jan 18, 2019
936078f
ENGCOM-3858: [Backport] Use the new json serializer which throws an e…
Jan 18, 2019
b645530
ENGCOM-3833: 2.2 develop pr port 18888 #20183
Jan 18, 2019
2e38840
ENGCOM-3826: magento/magento2#16198: Category image remain after dele…
Jan 18, 2019
8170336
:arrows_clockwise: [EngCom] Public Pull Requests - 2.2-develop
magento-engcom-team Jan 18, 2019
b8fa8f3
Fixed admin multiselect and select ui arrow toggle issue
Jan 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $ccType = $block->getInfoData('cc_type');
id="<?= /* @noEscape */ $code ?>_vault"
name="payment[is_active_payment_token_enabler]"
class="admin__control-checkbox"/>
<label class="label" for="<?= /* @noEscape */ $code ?>_vault">
<label class="label admin__field-label" for="<?= /* @noEscape */ $code ?>_vault">
<span><?= $block->escapeHtml(__('Save for later use.')) ?></span>
</label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,129 +7,150 @@
// @codingStandardsIgnoreFile

/** @var $block \Magento\Bundle\Block\Sales\Order\Items\Renderer */
$parentItem = $block->getItem();
$items = array_merge([$parentItem], $parentItem->getChildrenItems());
$index = 0;
$prevOptionId = '';
?>
<?php $parentItem = $block->getItem() ?>
<?php $items = array_merge([$parentItem], $parentItem->getChildrenItems()); ?>
<?php $_index = 0 ?>

<?php $_prevOptionId = '' ?>
<?php foreach ($items as $item): ?>

<?php foreach ($items as $_item): ?>

<?php if ($block->getItemOptions() || $parentItem->getDescription() || $this->helper('Magento\GiftMessage\Helper\Message')->isMessagesAllowed('order_item', $parentItem) && $parentItem->getGiftMessageId()): ?>
<?php $_showlastRow = true ?>
<?php if ($block->getItemOptions()
|| $parentItem->getDescription()
|| $this->helper('Magento\GiftMessage\Helper\Message')->isMessagesAllowed('order_item', $parentItem)
&& $parentItem->getGiftMessageId()): ?>
<?php $showLastRow = true; ?>
<?php else: ?>
<?php $_showlastRow = false ?>
<?php $showLastRow = false; ?>
<?php endif; ?>

<?php if ($_item->getParentItem()): ?>
<?php $attributes = $block->getSelectionAttributes($_item) ?>
<?php if ($_prevOptionId != $attributes['option_id']): ?>
<?php if ($item->getParentItem()): ?>
<?php $attributes = $block->getSelectionAttributes($item) ?>
<?php if ($prevOptionId != $attributes['option_id']): ?>
<tr class="options-label">
<td class="col label" colspan="5"><?= /* @escapeNotVerified */ $attributes['option_label'] ?></td>
<td class="col label" colspan="5"><?= $block->escapeHtml($attributes['option_label']); ?></td>
</tr>
<?php $_prevOptionId = $attributes['option_id'] ?>
<?php $prevOptionId = $attributes['option_id'] ?>
<?php endif; ?>
<?php endif; ?>
<tr id="order-item-row-<?= /* @escapeNotVerified */ $_item->getId() ?>" class="<?php if ($_item->getParentItem()): ?>item-options-container<?php else: ?>item-parent<?php endif; ?>"<?php if ($_item->getParentItem()): ?> data-th="<?= /* @escapeNotVerified */ $attributes['option_label'] ?>"<?php endif; ?>>
<?php if (!$_item->getParentItem()): ?>
<td class="col name" data-th="<?= $block->escapeHtml(__('Product Name')) ?>">
<strong class="product name product-item-name"><?= $block->escapeHtml($_item->getName()) ?></strong>
<tr id="order-item-row-<?= /* @noEscape */ $item->getId() ?>"
class="<?php if ($item->getParentItem()): ?>
item-options-container
<?php else: ?>
item-parent
<?php endif; ?>"
<?php if ($item->getParentItem()): ?>
data-th="<?= $block->escapeHtml($attributes['option_label']); ?>"
<?php endif; ?>>
<?php if (!$item->getParentItem()): ?>
<td class="col name" data-th="<?= $block->escapeHtml(__('Product Name')); ?>">
<strong class="product name product-item-name"><?= $block->escapeHtml($item->getName()); ?></strong>
</td>
<?php else: ?>
<td class="col value" data-th="<?= $block->escapeHtml(__('Product Name')) ?>"><?= $block->getValueHtml($_item) ?></td>
<td class="col value" data-th="<?= $block->escapeHtml(__('Product Name')); ?>">
<?= $block->getValueHtml($item); ?>
</td>
<?php endif; ?>
<td class="col sku" data-th="<?= $block->escapeHtml(__('SKU')) ?>"><?= /* @escapeNotVerified */ $block->prepareSku($_item->getSku()) ?></td>
<td class="col price" data-th="<?= $block->escapeHtml(__('Price')) ?>">
<?php if (!$_item->getParentItem()): ?>
<?= $block->getItemPriceHtml() ?>
<td class="col sku" data-th="<?= $block->escapeHtml(__('SKU')); ?>">
<?= /* @noEscape */ $block->prepareSku($item->getSku()); ?>
</td>
<td class="col price" data-th="<?= $block->escapeHtml(__('Price')); ?>">
<?php if (!$item->getParentItem()): ?>
<?= /* @noEscape */ $block->getItemPriceHtml(); ?>
<?php else: ?>
&nbsp;
<?php endif; ?>
</td>
<td class="col qty" data-th="<?= $block->escapeHtml(__('Quantity')) ?>">
<td class="col qty" data-th="<?= $block->escapeHtml(__('Quantity')); ?>">
<?php if (
($_item->getParentItem() && $block->isChildCalculated()) ||
(!$_item->getParentItem() && !$block->isChildCalculated()) || ($_item->getQtyShipped() > 0 && $_item->getParentItem() && $block->isShipmentSeparately())):?>
($item->getParentItem() && $block->isChildCalculated()) ||
(!$item->getParentItem() && !$block->isChildCalculated()) ||
($item->getQtyShipped() > 0 && $item->getParentItem() && $block->isShipmentSeparately())): ?>
<ul class="items-qty">
<?php endif; ?>
<?php if (($_item->getParentItem() && $block->isChildCalculated()) ||
(!$_item->getParentItem() && !$block->isChildCalculated())): ?>
<?php if ($_item->getQtyOrdered() > 0): ?>
<?php if (($item->getParentItem() && $block->isChildCalculated()) ||
(!$item->getParentItem() && !$block->isChildCalculated())): ?>
<?php if ($item->getQtyOrdered() > 0): ?>
<li class="item">
<span class="title"><?= /* @escapeNotVerified */ __('Ordered') ?></span>
<span class="content"><?= /* @escapeNotVerified */ $_item->getQtyOrdered()*1 ?></span>
<span class="title"><?= $block->escapeHtml(__('Ordered')); ?></span>
<span class="content"><?= /* @noEscape */ $item->getQtyOrdered() * 1; ?></span>
</li>
<?php endif; ?>
<?php if ($_item->getQtyShipped() > 0 && !$block->isShipmentSeparately()): ?>
<?php if ($item->getQtyShipped() > 0 && !$block->isShipmentSeparately()): ?>
<li class="item">
<span class="title"><?= /* @escapeNotVerified */ __('Shipped') ?></span>
<span class="content"><?= /* @escapeNotVerified */ $_item->getQtyShipped()*1 ?></span>
<span class="title"><?= $block->escapeHtml(__('Shipped')); ?></span>
<span class="content"><?= /* @noEscape */ $item->getQtyShipped() * 1; ?></span>
</li>
<?php endif; ?>
<?php if ($_item->getQtyCanceled() > 0): ?>
<?php if ($item->getQtyCanceled() > 0): ?>
<li class="item">
<span class="title"><?= /* @escapeNotVerified */ __('Canceled') ?></span>
<span class="content"><?= /* @escapeNotVerified */ $_item->getQtyCanceled()*1 ?></span>
<span class="title"><?= $block->escapeHtml(__('Canceled')); ?></span>
<span class="content"><?= /* @noEscape */ $item->getQtyCanceled() * 1; ?></span>
</li>
<?php endif; ?>
<?php if ($_item->getQtyRefunded() > 0): ?>
<?php if ($item->getQtyRefunded() > 0): ?>
<li class="item">
<span class="title"><?= /* @escapeNotVerified */ __('Refunded') ?></span>
<span class="content"><?= /* @escapeNotVerified */ $_item->getQtyRefunded()*1 ?></span>
<span class="title"><?= $block->escapeHtml(__('Refunded')); ?></span>
<span class="content"><?= /* @noEscape */ $item->getQtyRefunded() * 1; ?></span>
</li>
<?php endif; ?>
<?php elseif ($_item->getQtyShipped() > 0 && $_item->getParentItem() && $block->isShipmentSeparately()): ?>
<?php elseif ($item->getQtyShipped() > 0 && $item->getParentItem() && $block->isShipmentSeparately()): ?>
<li class="item">
<span class="title"><?= /* @escapeNotVerified */ __('Shipped') ?></span>
<span class="content"><?= /* @escapeNotVerified */ $_item->getQtyShipped()*1 ?></span>
<span class="title"><?= $block->escapeHtml(__('Shipped')); ?></span>
<span class="content"><?= /* @noEscape */ $item->getQtyShipped() * 1; ?></span>
</li>
<?php else: ?>
&nbsp;
<span class="content"><?= /* @noEscape */ $parentItem->getQtyOrdered() * 1; ?></span>
<?php endif; ?>
<?php if (
($_item->getParentItem() && $block->isChildCalculated()) ||
(!$_item->getParentItem() && !$block->isChildCalculated()) || ($_item->getQtyShipped() > 0 && $_item->getParentItem() && $block->isShipmentSeparately())):?>
($item->getParentItem() && $block->isChildCalculated()) ||
(!$item->getParentItem() && !$block->isChildCalculated()) ||
($item->getQtyShipped() > 0 && $item->getParentItem() && $block->isShipmentSeparately())):?>
</ul>
<?php endif; ?>
</td>
<td class="col subtotal" data-th="<?= $block->escapeHtml(__('Subtotal')) ?>">
<?php if (!$_item->getParentItem()): ?>
<?= $block->getItemRowTotalHtml() ?>
<?php if (!$item->getParentItem()): ?>
<?= /* @noEscape */ $block->getItemRowTotalHtml(); ?>
<?php else: ?>
&nbsp;
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>

<?php if ($_showlastRow && (($_options = $block->getItemOptions()) || $block->escapeHtml($_item->getDescription()))): ?>
<?php if ($showLastRow && (($options = $block->getItemOptions()) || $block->escapeHtml($item->getDescription()))): ?>
<tr>
<td class="col options" colspan="5">
<?php if ($_options = $block->getItemOptions()): ?>
<?php if ($options = $block->getItemOptions()): ?>
<dl class="item-options">
<?php foreach ($_options as $_option) : ?>
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
<?php foreach ($options as $option) : ?>
<dt><?= $block->escapeHtml($option['label']) ?></dt>
<?php if (!$block->getPrintStatus()): ?>
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
<dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="tooltip wrapper"<?php endif; ?>>
<?= /* @escapeNotVerified */ $_formatedOptionValue['value'] ?>
<?php if (isset($_formatedOptionValue['full_view'])): ?>
<?php $formattedOptionValue = $block->getFormatedOptionValue($option) ?>
<dd<?php if (isset($formattedOptionValue['full_view'])): ?>
class="tooltip wrapper"
<?php endif; ?>>
<?= /* @noEscape */ $formattedOptionValue['value'] ?>
<?php if (isset($formattedOptionValue['full_view'])): ?>
<div class="tooltip content">
<dl class="item options">
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
<dd><?= /* @escapeNotVerified */ $_formatedOptionValue['full_view'] ?></dd>
<dt><?= $block->escapeHtml($option['label']); ?></dt>
<dd><?= /* @noEscape */ $formattedOptionValue['full_view']; ?></dd>
</dl>
</div>
<?php endif; ?>
</dd>
<?php else: ?>
<dd><?= $block->escapeHtml((isset($_option['print_value']) ? $_option['print_value'] : $_option['value'])) ?></dd>
<dd><?= $block->escapeHtml((isset($option['print_value']) ?
$option['print_value'] :
$option['value'])); ?>
</dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
<?php endif; ?>
<?= $block->escapeHtml($_item->getDescription()) ?>
<?= $block->escapeHtml($item->getDescription()); ?>
</td>
</tr>
<?php endif; ?>
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ public function getIdBySku($sku)
public function getCategoryId()
{
$category = $this->_registry->registry('current_category');
if ($category) {
if ($category && in_array($category->getId(), $this->getCategoryIds())) {
return $category->getId();
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model\ResourceModel\Category;

use Magento\Catalog\Api\CategoryListInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;

/**
* Check if Image is currently used in any category as Category Image.
*/
class RedundantCategoryImageChecker
{
/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;

/**
* @var CategoryListInterface
*/
private $categoryList;

public function __construct(
CategoryListInterface $categoryList,
SearchCriteriaBuilder $searchCriteriaBuilder
) {
$this->categoryList = $categoryList;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
}

/**
* Checks if Image is currently used in any category as Category Image.
*
* Returns true if not.
*
* @param string $imageName
* @return bool
*/
public function execute(string $imageName): bool
{
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteria = $this->searchCriteriaBuilder->addFilter('image', $imageName)->create();
$categories = $this->categoryList->getList($searchCriteria)->getItems();

return empty($categories);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Plugin\Model\ResourceModel\Category;

use Magento\Catalog\Model\ImageUploader;
use Magento\Catalog\Model\ResourceModel\Category as CategoryResource;
use Magento\Catalog\Model\ResourceModel\Category\RedundantCategoryImageChecker;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\Framework\Model\AbstractModel;

/**
* Remove old Category Image file from pub/media/catalog/category directory if such Image is not used anymore.
*/
class RemoveRedundantImagePlugin
{
/**
* @var Filesystem
*/
private $filesystem;

/**
* @var ImageUploader
*/
private $imageUploader;

/**
* @var RedundantCategoryImageChecker
*/
private $redundantCategoryImageChecker;

public function __construct(
Filesystem $filesystem,
ImageUploader $imageUploader,
RedundantCategoryImageChecker $redundantCategoryImageChecker
) {
$this->filesystem = $filesystem;
$this->imageUploader = $imageUploader;
$this->redundantCategoryImageChecker = $redundantCategoryImageChecker;
}

/**
* Removes Image file if it is not used anymore.
*
* @param CategoryResource $subject
* @param CategoryResource $result
* @param AbstractModel $category
* @return CategoryResource
*
* @throws \Magento\Framework\Exception\FileSystemException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterSave(
CategoryResource $subject,
CategoryResource $result,
AbstractModel $category
): CategoryResource {
$originalImage = $category->getOrigData('image');
if (null !== $originalImage
&& $originalImage !== $category->getImage()
&& $this->redundantCategoryImageChecker->execute($originalImage)
) {
$basePath = $this->imageUploader->getBasePath();
$baseImagePath = $this->imageUploader->getFilePath($basePath, $originalImage);
/** @var \Magento\Framework\Filesystem\Directory\WriteInterface $mediaDirectory */
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$mediaDirectory->delete($baseImagePath);
}

return $result;
}
}
12 changes: 11 additions & 1 deletion app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ public function testSetCategoryCollection()

public function testGetCategory()
{
$this->model->setData('category_ids', [10]);
$this->category->expects($this->any())->method('getId')->will($this->returnValue(10));
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->category));
$this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($this->category));
Expand All @@ -551,14 +552,23 @@ public function testGetCategory()

public function testGetCategoryId()
{
$this->category->expects($this->once())->method('getId')->will($this->returnValue(10));
$this->model->setData('category_ids', [10]);
$this->category->expects($this->any())->method('getId')->will($this->returnValue(10));

$this->registry->expects($this->at(0))->method('registry');
$this->registry->expects($this->at(1))->method('registry')->will($this->returnValue($this->category));
$this->assertFalse($this->model->getCategoryId());
$this->assertEquals(10, $this->model->getCategoryId());
}

public function testGetCategoryIdWhenProductNotInCurrentCategory()
{
$this->model->setData('category_ids', [12]);
$this->category->expects($this->once())->method('getId')->will($this->returnValue(10));
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->category));
$this->assertFalse($this->model->getCategoryId());
}

public function testGetIdBySku()
{
$this->resource->expects($this->once())->method('getIdBySku')->will($this->returnValue(5));
Expand Down
Loading