Skip to content

Commit

Permalink
Merge branch 'media-modules' of github.com:magento-engcom/magento2ce …
Browse files Browse the repository at this point in the history
…into media-modules
  • Loading branch information
sivaschenko committed Aug 4, 2020
2 parents a9a508d + 36b97ee commit 86d618c
Show file tree
Hide file tree
Showing 51 changed files with 1,044 additions and 483 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public function loadOldStatus(array $linkIdBySku): void
$select = $connection->select()
->from($this->getAttribute()->getBackend()->getTable())
->columns([$linkId, 'store_id', 'value'])
->where(sprintf('%s IN (?)', $linkId), array_values($linkIdBySku));
->where(sprintf('%s IN (?)', $linkId), array_values($linkIdBySku))
->where('attribute_id = ?', $this->getAttribute()->getId());
$skuByLinkId = array_flip($linkIdBySku);

foreach ($connection->fetchAll($select) as $item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
?>
<?php if ($block->getRatingSummary()->getCount()): ?>
<div class="rating-box">
<div class="rating"/>
<div class="rating"></div>
</div>
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
"width:" . /* @noEscape */ ceil($block->getRatingSummary()->getSum() /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

/* @var $block \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */

$blockDataId = $block->getDataId();
$jsEscapedBlockDataId = $block->escapeJs($blockDataId);
?>
<div class="create-order-sidebar-block" id="sidebar_data_<?= $block->escapeHtmlAttr($block->getDataId()) ?>">
<div class="create-order-sidebar-block" id="sidebar_data_<?= $block->escapeHtmlAttr($blockDataId) ?>">
<div class="head sidebar-title-block">
<a href="#" class="action-refresh" title="<?= $block->escapeHtml(__('Refresh')) ?>">
<span><?= $block->escapeHtml(__('Refresh')) ?></span>
Expand All @@ -19,9 +22,12 @@
</div>
<?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag(
'onclick',
"order.loadArea('sidebar_" . $block->escapeJs($block->getDataId()) .
"', 'sidebar_data_" . $block->escapeJs($block->getDataId()) . "');event.preventDefault();",
'div.head.sidebar-title-block'
"order.loadArea(
'sidebar_" . $jsEscapedBlockDataId ."',
'sidebar_data_" . $jsEscapedBlockDataId . "'
);
event.preventDefault();",
'div#sidebar_data_'. $jsEscapedBlockDataId . ' a.action-refresh'
) ?>
<div class="content">
<div class="auto-scroll">
Expand Down Expand Up @@ -83,7 +89,7 @@
type="checkbox"
class="admin__control-checkbox"
name="sidebar[remove][<?= (int) $block->getItemId($_item) ?>]"
value="<?= $block->escapeHtmlAttr($block->getDataId()) ?>"
value="<?= $block->escapeHtmlAttr($blockDataId) ?>"
title="<?= $block->escapeHtml(__('Remove')) ?>" />
<label class="admin__field-label"
for="sidebar-remove-<?=
Expand All @@ -97,7 +103,7 @@
<td class="col-add">
<div class="admin__field-option">
<?php if ($block->isConfigurationRequired($_item->getTypeId()) &&
$block->getDataId() == 'wishlist'): ?>
$blockDataId == 'wishlist'): ?>
<a href="#"
class="icon icon-configure"
title="<?= $block->escapeHtml(__('Configure and Add to Order')) ?>">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@
<span><?= $block->escapeHtml(__('Invoice Comments')) ?></span>
</label>
<div class="admin__field-control">
<textarea id="invoice_comment_text" name="invoice[comment_text]" class="admin__control-textarea"
rows="3" cols="5"><?= $block->escapeHtml($block->getInvoice()->getCommentText()) ?>
</textarea>
<textarea id="invoice_comment_text"
name="invoice[comment_text]"
class="admin__control-textarea"
rows="3"
cols="5"><?= $block->escapeHtml($block->getInvoice()->getCommentText())?></textarea>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<argument name="productVar" value="$createProduct$"/>
</actionGroup>
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logout"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogoutBeforeCheck"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="navigateToCustomerEditPage">
<argument name="customer" value="$createCustomer$"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\GraphQl\Catalog;

use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\TestFramework\ObjectManager;
use Magento\TestFramework\TestCase\GraphQlAbstract;

/**
* Test that product is not present in GQL after it was deleted
*/
class ProductDeleteTest extends GraphQlAbstract
{
/**
* @var \Magento\TestFramework\ObjectManager
*/
private $objectManager;

protected function setUp(): void
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_all_fields.php
*/
public function testQuerySimpleProductAfterDelete()
{
$productSku = 'simple';

$query = <<<QUERY
{
products(filter: {sku: {eq: "{$productSku}"}})
{
items {
attribute_set_id
}
}
}
QUERY;
// get customer ID token
/** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */
$customerTokenService = $this->objectManager->create(
\Magento\Integration\Api\CustomerTokenServiceInterface::class
);
$customerToken = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password');

$headerMap = ['Authorization' => 'Bearer ' . $customerToken];
$response = $this->graphQlQuery($query, [], '', $headerMap);
$this->assertArrayHasKey('products', $response);
$this->assertArrayHasKey('items', $response['products']);
$this->assertCount(1, $response['products']['items']);

// Delete the product and verify it is actually not accessible via the storefront anymore
/** @var ProductRepositoryInterface $productRepository */
$productRepository = ObjectManager::getInstance()->get(ProductRepositoryInterface::class);

$registry = ObjectManager::getInstance()->get(\Magento\Framework\Registry::class);
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', true);
$productRepository->deleteById($productSku);
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);

$response = $this->graphQlQuery($query, [], '', $headerMap);
$this->assertArrayHasKey('products', $response);
$this->assertArrayHasKey('items', $response['products']);
$this->assertCount(0, $response['products']['items']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected function setUp(): void
*
* @magentoApiDataFixture Magento/SalesRule/_files/rules_rollback.php
* @magentoApiDataFixture Magento/Sales/_files/quote.php
* @magentoAppIsolation enabled
*/
public function testGetList()
{
Expand Down Expand Up @@ -87,6 +88,7 @@ public function testGetList()

/**
* @magentoApiDataFixture Magento/Sales/_files/invoice.php
* @magentoAppIsolation enabled
*/
public function testAutoGeneratedGetList()
{
Expand Down Expand Up @@ -131,6 +133,7 @@ public function testAutoGeneratedGetList()
* Test get list of orders with extension attributes.
*
* @magentoApiDataFixture Magento/Sales/_files/order.php
* @magentoAppIsolation enabled
*/
public function testGetOrdertList()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ protected function setUp(): void
parent::setUp();

$this->_objectManager->get(\Magento\Backend\Model\UrlInterface::class)->turnOffSecretKey();

/**
* Authorization can be created on test bootstrap...
* If it will be created on test bootstrap we will have invalid RoleLocator object.
* As tests by default are run not from adminhtml area...
*/
\Magento\TestFramework\ObjectManager::getInstance()->removeSharedInstance(
\Magento\Framework\Authorization::class
);
$this->_auth = $this->_objectManager->get(\Magento\Backend\Model\Auth::class);
$this->_session = $this->_auth->getAuthStorage();
$credentials = $this->_getAdminCredentials();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ protected function getOptionValueByLabel(string $attributeCode, string $label):
/**
* Returns product for testing.
*
* @param bool $forceReload
* @return ProductInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
protected function getProduct(): ProductInterface
protected function getProduct($forceReload = false): ProductInterface
{
return $this->productRepository->get('simple', false, Store::DEFAULT_STORE_ID);
return $this->productRepository->get('simple', false, Store::DEFAULT_STORE_ID, $forceReload);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public function testModifyMeta(): void
public function testModifyData(): void
{
$expectedData = include __DIR__ . '/../_files/eav_expected_data_output.php';
$this->callModifyDataAndAssert($this->getProduct(), $expectedData);
// force load: ProductRepositoryInterface::getList does not add stock item, prices, categories to product
$this->callModifyDataAndAssert($this->getProduct(true), $expectedData);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
if ($category->getId()) {
$category->delete();
}
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
*/
declare(strict_types=1);

use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Helper\CacheCleaner;
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;

Resolver::getInstance()->requireDataFixture('Magento/ConfigurableProduct/_files/configurable_products.php');

use Magento\TestFramework\Helper\Bootstrap;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\TestFramework\Helper\CacheCleaner;

$eavConfig = Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);

/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
Expand All @@ -28,11 +29,5 @@
/** @var AttributeRepositoryInterface $attributeRepository */
$attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class);
$attributeRepository->save($attribute);

CacheCleaner::cleanAll();
/** @var \Magento\Indexer\Model\Indexer\Collection $indexerCollection */
$indexerCollection = Bootstrap::getObjectManager()->get(\Magento\Indexer\Model\Indexer\Collection::class);
$indexerCollection->load();
/** @var \Magento\Indexer\Model\Indexer $indexer */
foreach ($indexerCollection->getItems() as $indexer) {
$indexer->reindexAll();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
->setName('Simple Product1')
->setSku('simple1')
->setTaxClassId('none')
->setDescription('description')
->setDescription('description uniqueword')
->setShortDescription('short description')
->setOptionsContainer('container1')
->setMsrpDisplayActualPriceType(\Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_IN_CART)
Expand Down
Loading

0 comments on commit 86d618c

Please sign in to comment.