Skip to content

Commit 3d038fe

Browse files
author
Aditya Yadav
authored
Fixed Error for Duplication of Variable Name
1 parent acbb755 commit 3d038fe

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class ProductTest extends \PHPUnit\Framework\TestCase
200200
/**
201201
* @var ProductExtensionInterface|\PHPUnit_Framework_MockObject_MockObject
202202
*/
203-
private $extensionAttributes;
203+
private $productExtAttributes;
204204

205205
/**
206206
* @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
@@ -372,13 +372,13 @@ protected function setUp()
372372
$this->mediaConfig = $this->createMock(\Magento\Catalog\Model\Product\Media\Config::class);
373373
$this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class);
374374

375-
$this->extensionAttributes = $this->getMockBuilder(ProductExtensionInterface::class)
375+
$this->productExtAttributes = $this->getMockBuilder(ProductExtensionInterface::class)
376376
->setMethods(['getStockItem'])
377377
->getMockForAbstractClass();
378378
$this->extensionAttributesFactory
379379
->expects($this->any())
380380
->method('create')
381-
->willReturn($this->extensionAttributes);
381+
->willReturn($this->productExtAttributes);
382382

383383
$this->filterCustomAttribute = $this->createTestProxy(
384384
\Magento\Catalog\Model\FilterProductCustomAttribute::class
@@ -549,6 +549,7 @@ public function testSetCategoryCollection()
549549

550550
public function testGetCategory()
551551
{
552+
$this->model->setData('category_ids', [10]);
552553
$this->category->expects($this->any())->method('getId')->will($this->returnValue(10));
553554
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->category));
554555
$this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($this->category));
@@ -557,14 +558,23 @@ public function testGetCategory()
557558

558559
public function testGetCategoryId()
559560
{
560-
$this->category->expects($this->once())->method('getId')->will($this->returnValue(10));
561+
$this->model->setData('category_ids', [10]);
562+
$this->category->expects($this->any())->method('getId')->will($this->returnValue(10));
561563

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

570+
public function testGetCategoryIdWhenProductNotInCurrentCategory()
571+
{
572+
$this->model->setData('category_ids', [12]);
573+
$this->category->expects($this->once())->method('getId')->will($this->returnValue(10));
574+
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->category));
575+
$this->assertFalse($this->model->getCategoryId());
576+
}
577+
568578
public function testGetIdBySku()
569579
{
570580
$this->resource->expects($this->once())->method('getIdBySku')->will($this->returnValue(5));

0 commit comments

Comments
 (0)