From 1cdfdbd5aaf37615d0af821b11ad8e8fdcf6ae35 Mon Sep 17 00:00:00 2001 From: Cristian Partica <cpartica@magento.com> Date: Thu, 12 Jan 2017 12:38:24 -0600 Subject: [PATCH] MAGETWO-58924: SQL error wait timeout error when saving categories - fix sample data --- .../Model/Map/DataCategoryHashMap.php | 10 +--------- .../Unit/Model/Map/DataCategoryHashMapTest.php | 17 +---------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryHashMap.php b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryHashMap.php index d432767e926..ece8b203395 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryHashMap.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryHashMap.php @@ -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]; } diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryHashMapTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryHashMapTest.php index 1df5391f9d9..1aa6276742b 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryHashMapTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryHashMapTest.php @@ -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)); -- GitLab