public function testGetVatForArticleCategoryArtWithoutCat() { $oArticle1 = $this->getMock('oxarticle', array('getId')); //make sure getCategories are never called $oArticle1->expects($this->once())->method('getId')->will($this->returnValue('666')); $oVatSelector = $this->getProxyClass("oxVatSelector"); $this->oCategory->oxcategories__oxvat = new oxField(69, oxField::T_RAW); $this->oCategory->save(); $this->assertFalse($oVatSelector->UNITgetVatForArticleCategory($oArticle1)); }
/** * Category_Main::_deleteCatPicture() test case - deleting icon * * @return null */ public function testDeletePicture_deletingIcon() { $oDb = oxDb::getDb(oxDB::FETCH_MODE_ASSOC); $this->_oCategory->oxcategories__oxicon = new oxField('testIcon.jpg'); $this->_oCategory->save(); $this->assertEquals('testIcon.jpg', $oDb->getOne("select oxicon from oxcategories where oxid='_testCatId' "), 'Category save operation failed'); /** @var Category_Main $oView */ $oView = $this->getProxyClass('Category_Main'); $oView->UNITdeleteCatPicture($this->_oCategory, 'oxicon'); $this->assertEquals('', $oDb->getOne("select oxicon from oxcategories where oxid='_testCatId' ")); }
/** * Delete category picture, specified in $sField parameter * * @param oxCategory $item active category object * @param string $field picture field name * * @return null */ protected function _deleteCatPicture(oxCategory $item, $field) { if ($item->isDerived()) { return; } $myConfig = $this->getConfig(); $sItemKey = 'oxcategories__' . $field; switch ($field) { case 'oxthumb': $sImgType = 'TC'; break; case 'oxicon': $sImgType = 'CICO'; break; case 'oxpromoicon': $sImgType = 'PICO'; break; default: $sImgType = false; } if ($sImgType !== false) { /** @var oxUtilsPic $myUtilsPic */ $myUtilsPic = oxRegistry::get("oxUtilsPic"); /** @var oxUtilsFile $oUtilsFile */ $oUtilsFile = oxRegistry::get("oxUtilsFile"); $sDir = $myConfig->getPictureDir(false); $myUtilsPic->safePictureDelete($item->{$sItemKey}->value, $sDir . $oUtilsFile->getImageDirByType($sImgType), 'oxcategories', $field); $item->{$sItemKey} = new oxField(); $item->save(); } }