Beispiel #1
0
 public function testLoad()
 {
     $data = array(10 => 'test');
     $this->fetchStrategyMock->expects($this->once())->method('fetchAll')->with($this->selectMock, array())->will($this->returnValue(array($data)));
     $objectMock = $this->getMock('Magento\\Framework\\Object', array('addData'), array());
     $objectMock->expects($this->once())->method('addData')->with($data);
     $this->entityFactoryMock->expects($this->once())->method('create')->with('Magento\\Review\\Model\\Review\\Summary')->will($this->returnValue($objectMock));
     $this->collection->load();
 }
Beispiel #2
0
 public function setUp()
 {
     $this->eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
     $this->connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->selectMock = $this->getMock('Zend_Db_Select', [], [], '', false);
     $this->historyItemMock = $this->getMock('Magento\\Sales\\Model\\Order\\Status\\History', ['__wakeup', 'addData'], [], '', false);
     $this->resourceMock = $this->getMockForAbstractClass('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb', [], '', false, true, true, ['getReadConnection', 'getMainTable', 'getTable', '__wakeup']);
     $this->fetchStrategyMock = $this->getMockForAbstractClass('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface');
     $this->entityFactoryMock = $this->getMock('Magento\\Core\\Model\\EntityFactory', [], [], '', false);
     $this->resourceMock->expects($this->any())->method('getReadConnection')->will($this->returnValue($this->connectionMock));
     $this->resourceMock->expects($this->any())->method('getTable')->will($this->returnArgument(0));
     $this->connectionMock->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0));
     $this->connectionMock->expects($this->atLeastOnce())->method('select')->will($this->returnValue($this->selectMock));
     $data = [['data']];
     $this->historyItemMock->expects($this->once())->method('addData')->with($this->equalTo($data[0]))->will($this->returnValue($this->historyItemMock));
     $this->fetchStrategyMock->expects($this->once())->method('fetchAll')->will($this->returnValue($data));
     $this->entityFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->historyItemMock));
     $logger = $this->getMock('Magento\\Framework\\Logger', [], [], '', false);
     $this->collection = new \Magento\Sales\Model\Resource\Order\Status\History\Collection($this->entityFactoryMock, $logger, $this->fetchStrategyMock, $this->eventManagerMock, $this->connectionMock, $this->resourceMock);
 }
Beispiel #3
0
 public function setUp()
 {
     $this->coreEntityFactoryMock = $this->getMock('Magento\\Core\\Model\\EntityFactory', array(), array(), '', false);
     $this->loggerMock = $this->getMock('Magento\\Framework\\Logger', array(), array(), '', false);
     $this->fetchStrategyMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface', array(), array(), '', false);
     $this->eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', array(), array(), '', false);
     $this->configMock = $this->getMock('Magento\\Eav\\Model\\Config', array(), array(), '', false);
     $this->coreResourceMock = $this->getMock('Magento\\Framework\\App\\Resource', array('getConnection'), array(), '', false);
     $this->resourceHelperMock = $this->getMock('Magento\\Eav\\Model\\Resource\\Helper', array(), array(), '', false);
     $this->validatorFactoryMock = $this->getMock('Magento\\Framework\\Validator\\UniversalFactory', array(), array(), '', false);
     $this->entityFactoryMock = $this->getMock('Magento\\Eav\\Model\\EntityFactory', array(), array(), '', false);
     /** @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject */
     $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', array(), array(), '', false);
     /** @var $selectMock \Zend_Db_Select|\PHPUnit_Framework_MockObject_MockObject */
     $selectMock = $this->getMock('Zend_Db_Select', array(), array(), '', false);
     $this->coreEntityFactoryMock->expects($this->any())->method('create')->will($this->returnCallback(array($this, 'getMagentoObject')));
     $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock));
     $this->coreResourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock));
     $entityMock = $this->getMock('Magento\\Eav\\Model\\Entity\\AbstractEntity', array(), array(), '', false);
     $entityMock->expects($this->once())->method('getReadConnection')->will($this->returnValue($connectionMock));
     $entityMock->expects($this->once())->method('getDefaultAttributes')->will($this->returnValue(array()));
     $this->validatorFactoryMock->expects($this->once())->method('create')->with('test_entity_model')->will($this->returnValue($entityMock));
     $this->model = new \Magento\Eav\Model\Entity\Collection\AbstractCollectionStub($this->coreEntityFactoryMock, $this->loggerMock, $this->fetchStrategyMock, $this->eventManagerMock, $this->configMock, $this->coreResourceMock, $this->entityFactoryMock, $this->resourceHelperMock, $this->validatorFactoryMock, null);
 }
Beispiel #4
0
 public function testToOptionHash()
 {
     $data = array(10 => 'test');
     $adapterMock = $this->getMock('Zend_Db_Adapter_Pdo_Mysql', array('select', 'query'), array(), '', false);
     $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', array(), array('adapter' => $adapterMock));
     $adapterMock->expects($this->once())->method('select')->will($this->returnValue($selectMock));
     $this->fetchStrategyMock->expects($this->once())->method('fetchAll')->with($selectMock, array())->will($this->returnValue(array($data)));
     $objectMock = $this->getMock('Magento\\Framework\\Object', array('addData', 'setIdFieldName', 'getData'), array());
     $objectMock->expects($this->once())->method('addData')->with($data);
     $objectMock->expects($this->any())->method('getData')->will($this->returnValueMap(array(array(null, null, 10), array('name', null, 'test'))));
     $this->entityFactoryMock->expects($this->once())->method('create')->with('Magento\\Framework\\Object')->will($this->returnValue($objectMock));
     $this->collection->setConnection($adapterMock);
     $this->collection->loadData(false, false);
     $this->collection->loadData(false, false);
     $this->assertEquals($data, $this->collection->toOptionHash());
 }