Skip to content

Commit

Permalink
magento-engcom/import-export-improvements#43: update the AddressTest …
Browse files Browse the repository at this point in the history
…and StorageTest

 - fix up the lines of over 120 characters
 - import classes that will be used to shorten lines
  • Loading branch information
dmanners committed Jan 18, 2018
1 parent c07b97b commit 330634b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

use Magento\CustomerImportExport\Model\Import\Address;
use Magento\ImportExport\Model\Import\AbstractEntity;
use Magento\Framework\DB\Select;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Customer\Model\ResourceModel\Customer\Collection;
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
use Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory;
use Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage;

/**
* Class AddressTest
Expand Down Expand Up @@ -233,14 +239,14 @@ protected function _createAttrCollectionMock()
*/
protected function _createCustomerStorageMock()
{
/** @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject $selectMock */
$selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
/** @var Select|\PHPUnit_Framework_MockObject_MockObject $selectMock */
$selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->setMethods(['from'])
->getMock();
$selectMock->expects($this->any())->method('from')->will($this->returnSelf());

/** @var $connectionMock \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */
/** @var $connectionMock AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */
$connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class)
->disableOriginalConstructor()
->setMethods(['select', 'fetchAll'])
Expand All @@ -249,32 +255,32 @@ protected function _createCustomerStorageMock()
->method('select')
->will($this->returnValue($selectMock));

/** @var \Magento\Customer\Model\ResourceModel\Customer\Collection|\PHPUnit_Framework_MockObject_MockObject $customerCollection */
$customerCollection = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class)
/** @var Collection|\PHPUnit_Framework_MockObject_MockObject $customerCollection */
$customerCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->setMethods(['getConnection'])
->getMock();
$customerCollection->expects($this->any())
->method('getConnection')
->will($this->returnValue($connectionMock));

/** @var \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject $collectionFactory */
$collectionFactory = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class)
/** @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject $collectionFactory */
$collectionFactory = $this->getMockBuilder(CollectionFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$collectionFactory->expects($this->any())
->method('create')
->willReturn($customerCollection);

/** @var \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory|\PHPUnit_Framework_MockObject_MockObject $byPagesIteratorFactory */
$byPagesIteratorFactory = $this->getMockBuilder(\Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class)
/** @var CollectionByPagesIteratorFactory|\PHPUnit_Framework_MockObject_MockObject $byPagesIteratorFactory */
$byPagesIteratorFactory = $this->getMockBuilder(CollectionByPagesIteratorFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();

/** @var \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage|\PHPUnit_Framework_MockObject_MockObject $customerStorage */
$customerStorage = $this->getMockBuilder(\Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage::class)
/** @var Storage|\PHPUnit_Framework_MockObject_MockObject $customerStorage */
$customerStorage = $this->getMockBuilder(Storage::class)
->setMethods(['load'])
->setConstructorArgs([$collectionFactory, $byPagesIteratorFactory])
->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
namespace Magento\CustomerImportExport\Test\Unit\Model\ResourceModel\Import\Customer;

use Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Customer\Model\ResourceModel\Customer\Collection;
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
use Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory;

class StorageTest extends \PHPUnit\Framework\TestCase
{
Expand Down Expand Up @@ -33,7 +37,7 @@ protected function setUp()
->getMock();
$selectMock->expects($this->any())->method('from')->will($this->returnSelf());

/** @var $connectionMock \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */
/** @var $connectionMock AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */
$connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class)
->disableOriginalConstructor()
->setMethods(['select', 'fetchAll'])
Expand All @@ -45,8 +49,8 @@ protected function setUp()
->method('fetchAll')
->will($this->returnValue([]));

/** @var \Magento\Customer\Model\ResourceModel\Customer\Collection|\PHPUnit_Framework_MockObject_MockObject $customerCollection */
$customerCollection = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class)
/** @var Collection|\PHPUnit_Framework_MockObject_MockObject $customerCollection */
$customerCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->setMethods(['getConnection','getMainTable'])
->getMock();
Expand All @@ -58,22 +62,22 @@ protected function setUp()
->method('getMainTable')
->willReturn('customer_entity');

/** @var \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject $collectionFactory */
$collectionFactory = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class)
/** @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject $collectionFactory */
$collectionFactory = $this->getMockBuilder(CollectionFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$collectionFactory->expects($this->any())
->method('create')
->willReturn($customerCollection);

/** @var \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory|\PHPUnit_Framework_MockObject_MockObject $byPagesIteratorFactory */
$byPagesIteratorFactory = $this->getMockBuilder(\Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class)
/** @var CollectionByPagesIteratorFactory|\PHPUnit_Framework_MockObject_MockObject $byPagesIteratorFactory */
$byPagesIteratorFactory = $this->getMockBuilder(CollectionByPagesIteratorFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();

$this->_model = new \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage(
$this->_model = new Storage(
$collectionFactory,
$byPagesIteratorFactory
);
Expand Down

0 comments on commit 330634b

Please sign in to comment.