public function testSetMainTableNoSelect() { $this->connectionMock->expects($this->any())->method('select')->will($this->returnValue(null)); $this->uut = $this->getUut(); $this->resourceMock->expects($this->any())->method('getTable')->will($this->returnValue(self::TABLE_NAME)); $this->uut->setMainTable(''); $this->selectMock->expects($this->never())->method('getPart'); $this->assertTrue($this->uut->setMainTable('') instanceof Uut); $this->assertEquals(self::TABLE_NAME, $this->uut->getMainTable()); }
/** * {@inheritDoc} */ protected function setUp() { $this->entityFactoryMock = $this->getMockBuilder('Magento\\Framework\\Data\\Collection\\EntityFactoryInterface')->getMock(); $this->loggerMock = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $this->fetchStrategyMock = $this->getMockBuilder('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface')->getMock(); $this->managerMock = $this->getMockBuilder('Magento\\Framework\\Event\\ManagerInterface')->getMock(); $this->selectMock = $this->getMockBuilder('Zend_Db_Select')->setMethods(['where', 'from'])->disableOriginalConstructor()->getMock(); $this->selectMock->expects($this->any())->method('from')->willReturnSelf(); $this->selectMock->expects($this->any())->method('where')->willReturnSelf(); $this->dbMock = $this->getMockBuilder('Zend_Db_Adapter_Abstract')->disableOriginalConstructor()->getMock(); $this->dbMock->expects($this->any())->method('select')->willReturn($this->selectMock); $this->resourceMock = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb')->disableOriginalConstructor()->setMethods(['getReadConnection', 'getCurrentStoreIds', '_construct', 'getMainTable', 'getTable'])->getMock(); $this->resourceMock->expects($this->any())->method('getReadConnection')->willReturn($this->dbMock); $this->collection = new Collection($this->entityFactoryMock, $this->loggerMock, $this->fetchStrategyMock, $this->managerMock, null, $this->resourceMock); }
/** * @param array $storeIds * @param array $parameters * @dataProvider storesDataProvider * @return void */ public function testSetStoreIds($storeIds, $parameters) { $this->dbMock->expects($this->any())->method('getIfNullSql')->willReturn('text'); $this->selectMock->expects($this->once())->method('columns')->with($parameters)->willReturnSelf(); $this->collection->setStoreIds($storeIds); }