Skip to content
Snippets Groups Projects
Commit 1cdfdbd5 authored by Cristian Partica's avatar Cristian Partica
Browse files

MAGETWO-58924: SQL error wait timeout error when saving categories

- fix sample data
parent bef74960
No related merge requests found
......@@ -5,7 +5,6 @@
*/
namespace Magento\CatalogUrlRewrite\Model\Map;
use Magento\Catalog\Model\ResourceModel\Category\Collection;
use Magento\Catalog\Model\ResourceModel\Category;
use Magento\Catalog\Model\CategoryRepository;
use Magento\Catalog\Api\Data\CategoryInterface;
......@@ -21,24 +20,18 @@ class DataCategoryHashMap implements HashMapInterface
/** @var CategoryRepository */
private $categoryRepository;
/** @var Collection */
private $collection;
/** @var Category */
private $categoryResource;
/**
* @param CategoryRepository $categoryRepository
* @param Collection $collection
* @param Category $categoryResource
*/
public function __construct(
CategoryRepository $categoryRepository,
Collection $collection,
Category $categoryResource
) {
$this->categoryRepository = $categoryRepository;
$this->collection = $collection;
$this->categoryResource = $categoryResource;
}
......@@ -52,8 +45,7 @@ class DataCategoryHashMap implements HashMapInterface
{
if (!isset($this->hashMap[$categoryId])) {
$category = $this->categoryRepository->get($categoryId);
$this->hashMap[$categoryId] = $this->collection->addIdFilter($this->getAllCategoryChildrenIds($category))
->getAllIds();
$this->hashMap[$categoryId] = $this->getAllCategoryChildrenIds($category);
}
return $this->hashMap[$categoryId];
}
......
......@@ -5,7 +5,6 @@
*/
namespace Magento\CatalogUrlRewrite\Test\Unit\Model\Map;
use Magento\Catalog\Model\ResourceModel\Category\Collection;
use Magento\Catalog\Model\ResourceModel\Category as CategoryResource;
use Magento\Framework\DB\Select;
use Magento\Catalog\Model\CategoryRepository;
......@@ -22,9 +21,6 @@ class DataCategoryHashMapTest extends \PHPUnit_Framework_TestCase
/** @var CategoryRepository|\PHPUnit_Framework_MockObject_MockObject */
private $categoryRepository;
/** @var Collection|\PHPUnit_Framework_MockObject_MockObject */
private $collection;
/** @var CategoryResource|\PHPUnit_Framework_MockObject_MockObject */
private $categoryResource;
......@@ -34,7 +30,6 @@ class DataCategoryHashMapTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->categoryRepository = $this->getMock(CategoryRepository::class, [], [], '', false);
$this->collection = $this->getMock(Collection::class, ['addIdFilter', 'getAllIds'], [], '', false);
$this->categoryResource = $this->getMock(
CategoryResource::class,
['getConnection', 'getEntityTable'],
......@@ -47,7 +42,6 @@ class DataCategoryHashMapTest extends \PHPUnit_Framework_TestCase
DataCategoryHashMap::class,
[
'categoryRepository' => $this->categoryRepository,
'collection' => $this->collection,
'categoryResource' => $this->categoryResource
]
);
......@@ -68,15 +62,6 @@ class DataCategoryHashMapTest extends \PHPUnit_Framework_TestCase
$this->categoryRepository->expects($this->any())
->method('get')
->willReturn($categoryMock);
$categoryMock->expects($this->any())
->method('getResourceCollection')
->willReturn($this->collection);
$this->collection->expects($this->any())
->method('addIdFilter')
->willReturnSelf();
$this->collection->expects($this->exactly(3))
->method('getAllIds')
->willReturnOnConsecutiveCalls($categoryIds, $categoryIdsOther, $categoryIds);
$categoryMock->expects($this->any())
->method('getResource')
->willReturn($this->categoryResource);
......@@ -97,7 +82,7 @@ class DataCategoryHashMapTest extends \PHPUnit_Framework_TestCase
->willReturnSelf();
$connectionAdapterMock->expects($this->any())
->method('fetchCol')
->willReturnOnConsecutiveCalls($categoryIds, $categoryIdsOther);
->willReturnOnConsecutiveCalls($categoryIds, $categoryIdsOther, $categoryIds);
$this->assertEquals($categoryIds, $this->model->getAllData(1));
$this->assertEquals($categoryIds[2], $this->model->getData(1, 2));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment