forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'customer-grid-ui-component' of github.com:simpleadm/mag…
…ento2 into customer-grid-ui-component # Conflicts: # app/code/Magento/Customer/etc/di.xml
- Loading branch information
Showing
7 changed files
with
582 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/CollectionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Customer\Test\Unit\Model\ResourceModel\Group\Grid; | ||
|
||
use Magento\Customer\Model\ResourceModel\Group\Grid\Collection; | ||
use Magento\Framework\Api\Search\AggregationInterface; | ||
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; | ||
use Magento\Framework\Data\Collection\EntityFactoryInterface; | ||
use Magento\Framework\DB\Adapter\AdapterInterface; | ||
use Magento\Framework\Event\ManagerInterface; | ||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Psr\Log\LoggerInterface; | ||
use Magento\Framework\DB\Select; | ||
|
||
/** | ||
* CollectionTest contains unit tests for \Magento\Customer\Model\ResourceModel\Group\Grid\Collection class | ||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||
*/ | ||
class CollectionTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var EntityFactoryInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $entityFactoryMock; | ||
|
||
/** | ||
* @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $loggerMock; | ||
|
||
/** | ||
* @var FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $fetchStrategyMock; | ||
|
||
/** | ||
* @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $eventManagerMock; | ||
|
||
/** | ||
* @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $connectionMock; | ||
|
||
/** | ||
* @var AbstractDb|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $resourceMock; | ||
|
||
/** | ||
* @var AggregationInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $aggregationsMock; | ||
|
||
/** | ||
* @var Select | ||
*/ | ||
protected $selectMock; | ||
|
||
/** | ||
* @var Collection | ||
*/ | ||
protected $model; | ||
|
||
protected function setUp() | ||
{ | ||
$this->entityFactoryMock = $this->getMockBuilder(EntityFactoryInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->loggerMock = $this->getMockBuilder(LoggerInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->fetchStrategyMock = $this->getMockBuilder(FetchStrategyInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->eventManagerMock = $this->getMockBuilder(ManagerInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->resourceMock = $this->getMockBuilder(AbstractDb::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->aggregationsMock = $this->getMockBuilder(AggregationInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->connectionMock = $this->getMockBuilder(AdapterInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->selectMock = $this->getMockBuilder(Select::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->resourceMock->expects($this->any()) | ||
->method('getConnection') | ||
->willReturn($this->connectionMock); | ||
$this->connectionMock->expects($this->once()) | ||
->method('select') | ||
->willReturn($this->selectMock); | ||
|
||
$this->model = (new ObjectManager($this))->getObject(Collection::class, [ | ||
'entityFactory' => $this->entityFactoryMock, | ||
'logger' => $this->loggerMock, | ||
'fetchStrategy' => $this->fetchStrategyMock, | ||
'eventManager' => $this->eventManagerMock, | ||
'mainTable' => null, | ||
'eventPrefix' => 'test_event_prefix', | ||
'eventObject' => 'test_event_object', | ||
'resourceModel' => null, | ||
'resource' => $this->resourceMock, | ||
]); | ||
} | ||
|
||
/** | ||
* @covers \Magento\Customer\Model\ResourceModel\Group\Grid\Collection::setSearchCriteria | ||
* @covers \Magento\Customer\Model\ResourceModel\Group\Grid\Collection::getAggregations | ||
*/ | ||
public function testSetGetAggregations() | ||
{ | ||
$this->model->setAggregations($this->aggregationsMock); | ||
$this->assertInstanceOf(AggregationInterface::class, $this->model->getAggregations()); | ||
} | ||
|
||
/** | ||
* @covers \Magento\Customer\Model\ResourceModel\Group\Grid\Collection::setSearchCriteria | ||
*/ | ||
public function testSetSearchCriteria() | ||
{ | ||
$this->assertEquals($this->model, $this->model->setSearchCriteria()); | ||
} | ||
} |
Oops, something went wrong.