/** * @covers Opt_Cdf_Manager::getFormat * @covers Opt_Cdf_Manager::addFormat * @covers Opt_Cdf_Manager::setLocality * @covers Opt_Cdf_Manager::setLocals * @expectedException Opt_NoMatchingFormat_Exception */ public function testMaskingLocalCdfDefinitions() { $locator = $this->getMock('Opt_Cdf_Locator_Interface', array('getElementLocation')); $locator->expects($this->once())->method('getElementLocation')->will($this->returnValue(array())); $this->_obj->setLocality('file.cdf'); $this->_obj->setLocals(array('foo.cdf')); $this->_obj->addFormat('foo', 'bar', 'Array', array()); $this->_obj->getFormat('foo', 'bar', $locator); }
/** * Allows to export the data format configuration to the compiler. * * @param Array $list An associative array of pairs "variable => format description" */ public function addFormats(array $globalCdf, array $localCdf, array $globalDefs, array $localDefs) { $manager = $this->getCdfManager(); if (sizeof($globalCdf) > 0 || sizeof($localCdf) > 0) { // Initialize the loader if ($this->_cdfLoader === null) { $this->_cdfLoader = new Opt_Cdf_Loader($manager); } $manager->setLocality(Opt_Cdf_Manager::AS_GLOBAL); foreach ($globalCdf as $cdf) { $this->_cdfLoader->load($this->_tpl->cdfDir . $cdf); } foreach ($localCdf as $cdf) { $manager->setLocality($cdf); $this->_cdfLoader->load($this->_tpl->cdfDir . $cdf); } $this->_cdfManager->setLocals($localCdf); } // Now manual definitions... $manager->setLocality(Opt_Cdf_Manager::AS_GLOBAL); foreach ($globalDefs as $item => &$idList) { foreach ($idList as $id => $format) { $this->_cdfManager->addFormat($item, $id, $format, array()); } } $manager->setLocality(Opt_Cdf_Manager::AS_LOCAL); foreach ($localDefs as $item => &$idList) { foreach ($idList as $id => $format) { $this->_cdfManager->addFormat($item, $id, $format, array()); } } }