public function testGetIsVisible() { // case 1 - normal mode $this->getConfig()->setConfigParam('blDontShowEmptyCategories', false); oxTestModules::addVariable('oxcategory', '_iNrOfArticles', 'public', 0); oxTestModules::addFunction('oxcategory', 'getHasVisibleSubCats', '{ return false; }'); $this->reload(); $this->_oCategory->oxcategories__oxhidden = new oxField(false, oxField::T_RAW); $this->assertEquals(true, $this->_oCategory->getIsVisible()); $this->reload(); $this->_oCategory->oxcategories__oxhidden = new oxField(true, oxField::T_RAW); $this->assertEquals(false, $this->_oCategory->getIsVisible()); // case 2 - hide empties $this->getConfig()->setConfigParam('blDontShowEmptyCategories', true); $this->reload(); $this->_oCategory->_iNrOfArticles = 0; $this->_oCategory->oxcategories__oxhidden = new oxField(false, oxField::T_RAW); $this->assertEquals(false, $this->_oCategory->getIsVisible()); $this->reload(); $this->_oCategory->_iNrOfArticles = 0; $this->_oCategory->oxcategories__oxhidden = new oxField(true, oxField::T_RAW); $this->assertEquals(false, $this->_oCategory->getIsVisible()); // case 3 - hide empties, but cat has 1 art $this->reload(); $this->_oCategory->_iNrOfArticles = 1; $this->_oCategory->oxcategories__oxhidden = new oxField(false, oxField::T_RAW); $this->assertEquals(true, $this->_oCategory->getIsVisible()); $this->reload(); $this->_oCategory->_iNrOfArticles = 1; $this->_oCategory->oxcategories__oxhidden = new oxField(true, oxField::T_RAW); $this->assertEquals(false, $this->_oCategory->getIsVisible()); // case 4 - hide empties, but cat has 1 art & subCats oxTestModules::addFunction('oxcategory', 'getHasVisibleSubCats', '{ return true; }'); $this->reload(); $this->_oCategory->_iNrOfArticles = 1; $this->_oCategory->oxcategories__oxhidden = new oxField(false, oxField::T_RAW); $this->assertEquals(true, $this->_oCategory->getIsVisible()); $this->reload(); $this->_oCategory->_iNrOfArticles = 1; $this->_oCategory->oxcategories__oxhidden = new oxField(true, oxField::T_RAW); $this->assertEquals(false, $this->_oCategory->getIsVisible()); // case 5 - hide empties, but cat has subCats $this->reload(); $this->_oCategory->_iNrOfArticles = 0; $this->_oCategory->oxcategories__oxhidden = new oxField(false, oxField::T_RAW); $this->assertEquals(true, $this->_oCategory->getIsVisible()); $this->reload(); $this->_oCategory->_iNrOfArticles = 0; $this->_oCategory->oxcategories__oxhidden = new oxField(true, oxField::T_RAW); }