/** * Tear down the fixture. * * @return null */ protected function tearDown() { $this->cleanUpTable('oxactions'); $this->cleanUpTable('oxattribute'); $this->cleanUpTable('oxarticles'); $this->cleanUpTable('oxcategories'); $this->cleanUpTable('oxdiscount'); $this->cleanUpTable('oxnews'); $this->cleanUpTable('oxorder'); //clean it oxDB::getDb()->execute('delete from oxactions where oxtitle like "test%"'); oxDB::getDb()->execute('delete from oxnews where oxshortdesc like "oxbasetest%"'); oxRemClassModule('modoxCacheAdminForBase'); oxRemClassModule('modoxCacheForBase'); parent::teardown(); }
/** * Insert this Object into the database, this function only works * on the main table, it will not save any dependend tables, which * might be loaded through oxlist. * * @return bool */ protected function _insert() { $blRet = parent::_insert(); if ($blRet) { //also insert to multilang tables if it is separate foreach ($this->_getLanguageSetTables() as $sTable) { $sSq = "insert into {$sTable} set " . $this->_getUpdateFieldsForTable($sTable, false); $blRet = $blRet && (bool) oxDB::getDb()->execute($sSq); } } return $blRet; }
/** * Update this Object into the database, this function only works on * the main table, it will not save any dependend tables, which might * be loaded through oxlist. * * @throws oxObjectException Throws on failure inserting * * @return bool */ protected function _update() { //do not allow derived item update if (!$this->allowDerivedUpdate()) { return false; } if (!$this->getId()) { $oEx = oxNew('oxObjectException'); $oEx->setMessage('EXCEPTION_OBJECT_OXIDNOTSET'); $oEx->setObject($this); throw $oEx; } $sIDKey = oxUtils::getInstance()->getArrFldName($this->_sCoreTable . ".oxid"); $this->{$sIDKey} = new oxField($this->getId(), oxField::T_RAW); $oDb = oxDB::getDb(); $sUpdate = "update {$this->_sCoreTable} set " . $this->_getUpdateFields() . " where {$this->_sCoreTable}.oxid = " . $oDb->quote($this->getId()); //trigger event $this->beforeUpdate(); $blRet = (bool) $oDb->execute($sUpdate); $this->_rebuildCache(); return $blRet; }
public function testSearchWithCorrectVendorAndCat() { $sIDVend = "68342e2955d7401e6.18967838"; $sIDCat = "8a142c3e4d3253c95.46563530"; if ($this->getConfig()->getEdition() === 'EE') { $sIDVend = "d2e44d9b31fcce448.08890330"; $sIDCat = "30e44ab8593023055.23928895"; } $oSearch = oxNew('oxSearch'); $oSearchList = $oSearch->getSearchArticles("", $sIDCat, $sIDVend); $iAllArtCnt = $oSearch->getSearchArticleCount("", $sIDCat, $sIDVend); $sArticleTable = getViewName('oxarticles'); $sQ = "select {$sArticleTable}.* from {$sArticleTable}, oxobject2category as\n oxobject2category where oxobject2category.oxcatnid='{$sIDCat}' and\n oxobject2category.oxobjectid={$sArticleTable}.oxid and ( ( {$sArticleTable}.oxactive = 1 or (\n {$sArticleTable}.oxactivefrom < '" . date('Y-m-d H:i:s') . "' and {$sArticleTable}.oxactiveto > '" . date('Y-m-d H:i:s') . "' ) )\n and ( {$sArticleTable}.oxstockflag != 2 or ( {$sArticleTable}.oxstock + {$sArticleTable}.oxvarstock ) > 0 ) ) and\n {$sArticleTable}.oxparentid = '' and {$sArticleTable}.oxissearch = 1 and {$sArticleTable}.oxvendorid = '{$sIDVend}'\n and ( ( {$sArticleTable}.oxtitle like '%%' or {$sArticleTable}.oxshortdesc like '%%' or {$sArticleTable}.oxsearchkeys like '%%' or\n {$sArticleTable}.oxartnum like '%%' ) )"; $aAll = oxDB::getDb()->getAll($sQ); // testing if article count in list is <= 'iNrofCatArticles' = 10; $count = 5; if ($this->getConfig()->getEdition() === 'EE') { $count = 8; } $this->assertEquals($count, $oSearchList->count()); $this->assertEquals(count($aAll), $iAllArtCnt); // now looking if all found articles are correct $aFoundIds = $oSearchList->arrayKeys(); $aAll = array_slice($aAll, 0, 10); // if this tests fails here - you must add spec sorting for an upper SQL foreach ($aAll as $aData) { if (($sKey = array_search($aData[0], $aFoundIds)) !== false) { unset($aFoundIds[$sKey]); } } $this->assertEquals(0, count($aFoundIds)); }