Last active
February 6, 2018 19:03
-
-
Save KamilBalwierz/33ce4a010760c94b63344c2bcc4ef551 to your computer and use it in GitHub Desktop.
Tests typical entry points in Magento against why Snowdog_Freshmail module menu may not be showed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// enable error reporting to see all useful warnings | |
error_reporting(E_ALL); | |
ini_set('display_errors', 1); | |
if (function_exists('libxml_disable_entity_loader')) { | |
libxml_disable_entity_loader(false); | |
} | |
header('Content-type: text/plain'); | |
$xmlFiles = array( | |
'app/etc/modules/Snowdog_Freshmail.xml', | |
'app/code/community/Snowdog/Freshmail/etc/adminhtml.xml', | |
'app/code/community/Snowdog/Freshmail/etc/config.xml', | |
'app/code/community/Snowdog/Freshmail/etc/system.xml', | |
'app/code/community/Snowdog/Freshmail/etc/widget.xml', | |
); | |
echo 'Testing files from ' . __DIR__ . PHP_EOL; | |
foreach ($xmlFiles as $xmlFile) { | |
echo 'Testing existance of ' . $xmlFile . PHP_EOL; | |
if (file_exists($xmlFile)) { | |
echo "\t" . 'Found ' . realpath($xmlFile) . PHP_EOL; | |
echo "\t\t" . 'Contains # lines ' . count(file($xmlFile)) . PHP_EOL; | |
$xml = simplexml_load_file($xmlFile); | |
if ($xml) { | |
echo "\t\t" . 'Contains proper XML object' . PHP_EOL; | |
} | |
} else { | |
echo "\t" . '!! Not found' . PHP_EOL; | |
} | |
} | |
echo PHP_EOL . PHP_EOL; | |
require __DIR__ . '/app/Mage.php'; | |
Mage::app('admin', 'store'); | |
$coreHelper = Mage::helper('core'); | |
$enabled = $coreHelper->isModuleEnabled('Snowdog_Freshmail'); | |
echo 'Module enabled ' . ($enabled ? 'Yes' : 'No') . PHP_EOL; | |
$menuXml = Mage::getModel('admin/config')->getAdminhtmlConfig()->getNode('menu'); | |
$node = $menuXml->xpath('//snowfreshmail'); | |
if (count($node)) { | |
echo 'Menu nodes exists in config' . PHP_EOL; | |
} else { | |
echo '!! Did not found menu nodes' . PHP_EOL; | |
} | |
echo 'Attempt to instantiate helper class' . PHP_EOL; | |
$helper = new Snowdog_Freshmail_Helper_Data(); | |
if ($helper) { | |
echo 'Direct class instantiation successful' . PHP_EOL; | |
} else { | |
echo '!! Cannot instantiate helper directly' . PHP_EOL; | |
} | |
class Mage_Snowfreshmail_Helper_Data extends Mage_Core_Helper_Abstract | |
{ | |
} | |
; | |
$helper = Mage::helper('snowfreshmail'); | |
if ($helper instanceof Snowdog_Freshmail_Helper_Data) { | |
echo 'Factory class instantiation successful' . PHP_EOL; | |
} else { | |
echo '!! Cannot instantiate helper via factory' . PHP_EOL; | |
} | |
$outputEnabled = Mage::helper('snowfreshmail')->isModuleOutputEnabled(); | |
echo 'Module output enabled ' . ($outputEnabled ? 'Yes' : 'No') . PHP_EOL; | |
echo PHP_EOL . PHP_EOL; | |
Mage::reset(); | |
echo 'Retry without cache' . PHP_EOL; | |
Mage::app('admin', 'store', array('global_ban_use_cache' => true)); | |
Mage::getConfig()->getCache()->setOption('caching', false); | |
$coreHelper = Mage::helper('core'); | |
$enabled = $coreHelper->isModuleEnabled('Snowdog_Freshmail'); | |
$outputEnabled = Mage::helper('snowfreshmail')->isModuleOutputEnabled(); | |
echo 'Module enabled ' . ($enabled ? 'Yes' : 'No') . PHP_EOL; | |
echo 'Module output enabled ' . ($outputEnabled ? 'Yes' : 'No') . PHP_EOL; | |
$menuXml = Mage::getModel('admin/config')->getAdminhtmlConfig()->getNode('menu'); | |
$node = $menuXml->xpath('//snowfreshmail'); | |
if (count($node)) { | |
echo 'Menu nodes exists in config' . PHP_EOL; | |
} else { | |
echo '!! Did not found menu nodes' . PHP_EOL; | |
} | |
$compilerConfig = __DIR__ . '/includes/config.php'; | |
if (file_exists($compilerConfig)) { | |
include $compilerConfig; | |
} | |
if (defined('COMPILER_INCLUDE_PATH') || define('COMPILER_COLLECT_PATH')) { | |
echo '!! Warning compiler enabled'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment