Skip to content

Commit

Permalink
magento#9466: Fixed unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
lenaorobei committed Feb 5, 2020
1 parent a027e87 commit 64cb774
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ class CopierTest extends \PHPUnit\Framework\TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $optionRepositoryMock;
private $optionRepositoryMock;

/**
* @var Copier
*/
protected $_model;
private $_model;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $copyConstructorMock;
private $copyConstructorMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $productFactoryMock;
private $productFactoryMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
Expand All @@ -44,12 +44,12 @@ class CopierTest extends \PHPUnit\Framework\TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $productMock;
private $productMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $metadata;
private $metadata;

protected function setUp()
{
Expand Down Expand Up @@ -77,13 +77,10 @@ protected function setUp()
$this->_model = new Copier(
$this->copyConstructorMock,
$this->productFactoryMock,
$this->scopeOverriddenValueMock
$this->scopeOverriddenValueMock,
$this->optionRepositoryMock,
$metadataPool
);

$this->setProperties($this->_model, [
'optionRepository' => $this->optionRepositoryMock,
'metadataPool' => $metadataPool
]);
}

/**
Expand Down Expand Up @@ -340,20 +337,4 @@ public function testUrlAlreadyExistsExceptionWhileCopyStoresUrl()
$this->expectException(\Magento\UrlRewrite\Model\Exception\UrlAlreadyExistsException::class);
$this->_model->copy($this->productMock);
}

/**
* @param $object
* @param array $properties
*/
private function setProperties($object, $properties = [])
{
$reflectionClass = new \ReflectionClass(get_class($object));
foreach ($properties as $key => $value) {
if ($reflectionClass->hasProperty($key)) {
$reflectionProperty = $reflectionClass->getProperty($key);
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($object, $value);
}
}
}
}

0 comments on commit 64cb774

Please sign in to comment.