public function testFindOneByData() { $data = ['col1' => 'val1', 'col2' => 'val2']; $this->select->expects($this->at(1))->method('where')->with('col1 IN (?)', 'val1'); $this->select->expects($this->at(2))->method('where')->with('col2 IN (?)', 'val2'); $this->connectionMock->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0)); $this->connectionMock->expects($this->once())->method('fetchRow')->with($this->select)->will($this->returnValue(['row1'])); $this->dataObjectHelper->expects($this->at(0))->method('populateWithArray')->with(['urlRewrite1'], ['row1'], '\\Magento\\UrlRewrite\\Service\\V1\\Data\\UrlRewrite')->will($this->returnSelf()); $this->urlRewriteFactory->expects($this->at(0))->method('create')->will($this->returnValue(['urlRewrite1'])); $this->assertEquals(['urlRewrite1'], $this->storage->findOneByData($data)); }
public function testFindOneByData() { $data = ['col1' => 'val1', 'col2' => 'val2']; $this->select->expects($this->at(1))->method('where')->with('col1 IN (?)', 'val1'); $this->select->expects($this->at(2))->method('where')->with('col2 IN (?)', 'val2'); $this->adapter->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0)); $this->adapter->expects($this->once())->method('fetchRow')->with($this->select)->will($this->returnValue(['row1'])); $this->urlRewriteBuilder->expects($this->at(0))->method('populateWithArray')->with(['row1'])->will($this->returnSelf()); $this->urlRewriteBuilder->expects($this->at(1))->method('create')->will($this->returnValue(['urlRewrite1'])); $this->assertEquals(['urlRewrite1'], $this->storage->findOneByData($data)); }
/** * {@inheritdoc} */ public function findOneByData(array $data) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'findOneByData'); if (!$pluginInfo) { return parent::findOneByData($data); } else { return $this->___callPlugins('findOneByData', func_get_args(), $pluginInfo); } }