Commit 631c4e6a authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

Merge pull request #126 from aligent/feature/disable_modules

Allow modules to be disabled from local.xml.phpunit
parents 8111e7ca 2c79df6a
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
*/ */
/** /**
* Configution model extended to make unit tests to be available * Configuration model extended to make unit tests to be available
* at separate configuration scope * at separate configuration scope
* *
*/ */
...@@ -56,6 +56,13 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config ...@@ -56,6 +56,13 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
*/ */
protected $_cacheSections = array(); protected $_cacheSections = array();
/**
* Object containing parsed local.xml.phpunit
*
* @var null
*/
protected $_localXmlForTest = null;
/** /**
* Load config data from DB * Load config data from DB
* *
...@@ -215,6 +222,33 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config ...@@ -215,6 +222,33 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
return $this; return $this;
} }
/**
* Define if module is allowed
*
* Magento core allows use of a whitelist of modules supplied via the
* addAllowedModules method. EcomDev_PHPUnit extends this to allow a
* blacklist of modules to be supplied via local.xml.phpunit.
*
* @see Mage_Core_Model_Config::_isAllowedModule()
* @param string $moduleName
* @return bool
*/
protected function _isAllowedModule($moduleName)
{
if (!parent::_isAllowedModule($moduleName)) {
return false;
}
$localXml = $this->_loadLocalXmlForTest();
if ($localXml) {
$node = $localXml->getNode("phpunit/disable_modules/$moduleName");
return $node === false;
}
return true;
}
/** /**
* (non-PHPdoc) * (non-PHPdoc)
* @see Mage_Core_Model_Config::loadModules() * @see Mage_Core_Model_Config::loadModules()
...@@ -235,10 +269,8 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config ...@@ -235,10 +269,8 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
*/ */
protected function _loadTestConfig() protected function _loadTestConfig()
{ {
$merge = clone $this->_prototype;
try { try {
if ($merge->loadFile($this->_getLocalXmlForTest())) { if ($merge = $this->_loadLocalXmlForTest()) {
$this->_checkDbCredentialForDuplicate($this, $merge); $this->_checkDbCredentialForDuplicate($this, $merge);
$this->_checkBaseUrl($this, $merge); $this->_checkBaseUrl($this, $merge);
$this->extend($merge); $this->extend($merge);
...@@ -253,6 +285,20 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config ...@@ -253,6 +285,20 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
return $this; return $this;
} }
/**
* Parse the phpunit specific local configuration. This may be loaded by
* and used by _isAllowedModule before it's merged into the merged config.
*
* @return Mage_Core_Model_Config_Base|null
*/
protected function _loadLocalXmlForTest() {
if ($this->_localXmlForTest === null) {
$this->_localXmlForTest = clone $this->_prototype;
$this->_localXmlForTest->loadFile($this->_getLocalXmlForTest());
}
return $this->_localXmlForTest;
}
/** /**
* Loads cache configuration for PHPUnit tests scope * Loads cache configuration for PHPUnit tests scope
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment