Skip to content

Commit

Permalink
Merge pull request #5688 from magento-honey-badgers/MC-18332-remake
Browse files Browse the repository at this point in the history
MC-18332
  • Loading branch information
cpartica committed May 27, 2020
2 parents 5b2f325 + e20234f commit 0333859
Show file tree
Hide file tree
Showing 161 changed files with 669 additions and 16,904 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
*/
namespace Magento\AdvancedSearch\Model\Client;

use \Magento\Framework\ObjectManagerInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Search\EngineResolverInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;

/**
* @api
Expand Down Expand Up @@ -46,7 +47,7 @@ class ClientResolver
private $clientOptionsPool;

/**
* @var EngineResolver
* @var EngineResolverInterface
*/
private $engineResolver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use Magento\Framework\Model\AbstractModel;
use Magento\Catalog\Model\ResourceModel\Attribute;
use Magento\AdvancedSearch\Model\Client\ClientOptionsInterface;
use Magento\Framework\Search\EngineResolverInterface;
use Magento\Search\Model\EngineResolver;

class CustomerGroup extends AbstractPlugin
{
Expand All @@ -22,24 +20,16 @@ class CustomerGroup extends AbstractPlugin
*/
protected $clientOptions;

/**
* @var EngineResolverInterface
*/
protected $engineResolver;

/**
* @param IndexerRegistry $indexerRegistry
* @param ClientOptionsInterface $clientOptions
* @param EngineResolverInterface $engineResolver
*/
public function __construct(
IndexerRegistry $indexerRegistry,
ClientOptionsInterface $clientOptions,
EngineResolverInterface $engineResolver
ClientOptionsInterface $clientOptions
) {
parent::__construct($indexerRegistry);
$this->clientOptions = $clientOptions;
$this->engineResolver = $engineResolver;
}

/**
Expand All @@ -56,9 +46,7 @@ public function aroundSave(
\Closure $proceed,
AbstractModel $group
) {
$needInvalidation =
($this->engineResolver->getCurrentSearchEngine() != EngineResolver::CATALOG_SEARCH_MYSQL_ENGINE)
&& ($group->isObjectNew() || $group->dataHasChangedFor('tax_class_id'));
$needInvalidation = $group->isObjectNew() || $group->dataHasChangedFor('tax_class_id');
$result = $proceed($group);
if ($needInvalidation) {
$this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use Magento\Customer\Model\ResourceModel\Group as CustomerGroupResourceModel;
use Magento\Framework\Indexer\IndexerInterface;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Search\EngineResolverInterface;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\MockObject\MockObject;

/**
* @covers \Magento\AdvancedSearch\Model\Indexer\Fulltext\Plugin\CustomerGroup
Expand All @@ -35,7 +35,7 @@ class CustomerGroupTest extends TestCase
private $indexerMock;

/**
* @var Group|MockObject
* @var CustomerGroupResourceModel|MockObject
*/
private $subjectMock;

Expand All @@ -49,11 +49,6 @@ class CustomerGroupTest extends TestCase
*/
private $indexerRegistryMock;

/**
* @var EngineResolverInterface|MockObject
*/
private $engineResolverMock;

protected function setUp(): void
{
$this->subjectMock = $this->createMock(CustomerGroupResourceModel::class);
Expand All @@ -73,35 +68,24 @@ protected function setUp(): void
IndexerRegistry::class,
['get']
);
$this->engineResolverMock = $this->createPartialMock(
EngineResolverInterface::class,
['getCurrentSearchEngine']
);
$this->model = new CustomerGroupPlugin(
$this->indexerRegistryMock,
$this->customerOptionsMock,
$this->engineResolverMock
$this->customerOptionsMock
);
}

/**
* @param string $searchEngine
* @param bool $isObjectNew
* @param bool $isTaxClassIdChanged
* @param int $invalidateCounter
* @return void
* @dataProvider aroundSaveDataProvider
*/
public function testAroundSave(
string $searchEngine,
bool $isObjectNew,
bool $isTaxClassIdChanged,
int $invalidateCounter
): void {
$this->engineResolverMock->expects($this->once())
->method('getCurrentSearchEngine')
->willReturn($searchEngine);

$groupMock = $this->createPartialMock(
CustomerGroupModel::class,
['dataHasChangedFor', 'isObjectNew', '__wakeup']
Expand Down Expand Up @@ -137,14 +121,10 @@ public function testAroundSave(
public function aroundSaveDataProvider(): array
{
return [
['mysql', false, false, 0],
['mysql', false, true, 0],
['mysql', true, false, 0],
['mysql', true, true, 0],
['custom', false, false, 0],
['custom', false, true, 1],
['custom', true, false, 1],
['custom', true, true, 1],
[false, false, 0],
[false, true, 1],
[true, false, 1],
[true, true, 1],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Magento\Framework\Exception\InputException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\Resolver\Argument\SearchCriteria\ArgumentApplier\Filter;
use Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match;
use Magento\Search\Model\Query;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\ScopeInterface;
Expand All @@ -24,6 +23,11 @@
*/
class CategoryFilter
{
/**
* @var string
*/
private const SPECIAL_CHARACTERS = '-+~/\\<>\'":*$#@()!,.?`=%&^';

/**
* @var ScopeConfigInterface
*/
Expand Down Expand Up @@ -120,7 +124,7 @@ private function formatMatchFilters(array $filters, StoreInterface $store): arra
foreach ($filters as $filter => $condition) {
$conditionType = current(array_keys($condition));
if ($conditionType === 'match') {
$searchValue = trim(str_replace(Match::SPECIAL_CHARACTERS, '', $condition[$conditionType]));
$searchValue = trim(str_replace(self::SPECIAL_CHARACTERS, '', $condition[$conditionType]));
$matchLength = strlen($searchValue);
if ($matchLength < $minQueryLength) {
throw new InputException(__('Invalid match filter. Minimum length is %1.', $minQueryLength));
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions app/code/Magento/CatalogGraphQl/etc/graphql/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@
</argument>
</arguments>
</virtualType>
<preference for="Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match"
type="Magento\CatalogGraphQl\Model\Search\Adapter\Mysql\Query\Builder\Match" />
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
<arguments>
<argument name="extendedConfigData" xsi:type="array">
Expand Down

This file was deleted.

Loading

0 comments on commit 0333859

Please sign in to comment.