/** * Returns array of enabled modules * * @return array */ protected function _getEnabledModules() { if ($this->_enabledModules === null) { /** @var $helper Magento_Test_Helper_Config */ $helper = Magento_Test_Helper_Factory::getHelper('config'); $enabledModules = $helper->getEnabledModules(); $this->_enabledModules = array_combine($enabledModules, $enabledModules); } return $this->_enabledModules; }
public function testSetHelper() { $helper = new stdClass(); Magento_Test_Helper_Factory::setHelper('config', $helper); $helperGot = Magento_Test_Helper_Factory::getHelper('config'); $this->assertSame($helper, $helperGot, 'The helper must be used, when requested again'); $helperNew = new stdClass(); Magento_Test_Helper_Factory::setHelper('config', $helperNew); $helperGot = Magento_Test_Helper_Factory::getHelper('config'); $this->assertSame($helperNew, $helperGot, 'The helper must be changed upon new setHelper() method'); }
/** * @magentoDataFixture Mage/DesignEditor/_files/design_editor_active.php * @dataProvider pageActionDataProvider * * @param string $handle * @param string $requiredModule * @param bool $isVdeToolbarBug */ public function testPageAction($handle, $requiredModule) { if (!in_array($requiredModule, Magento_Test_Helper_Factory::getHelper('config')->getEnabledModules())) { $this->markTestSkipped("Test requires the module '{$requiredModule}' to be enabled."); } $this->getRequest()->setParam('handle', $handle); $this->dispatch('design/editor/page'); $this->assertEquals(200, $this->getResponse()->getHttpResponseCode()); $controller = Mage::app()->getFrontController()->getAction(); $this->assertInstanceOf('Mage_DesignEditor_EditorController', $controller); $this->assertContains('data-selected="li[rel=\'' . $handle . '\']"', $this->getResponse()->getBody(), 'Page type control should maintain the selection of the current page handle.'); }
/** * @param bool $moduleGroupsOnly * @param array $enabledModules * @param array $groups * @param array $excludeGroups * @param array $expectedTestCases * @dataProvider runDataProvider */ public function testRun($moduleGroupsOnly, $enabledModules, $groups, $excludeGroups, $expectedTestCases) { // Prepare suite $suite = $this->getMock('Magento_Test_TestSuite_ModuleGroups', array('runTest'), array($moduleGroupsOnly)); // Stubs enabled modules call $stubHelper = $this->getMock('Magento_Test_Helper_Config', array('getEnabledModules')); $stubHelper->expects($this->any())->method('getEnabledModules')->will($this->returnValue($enabledModules)); $prevHelper = Magento_Test_Helper_Factory::setHelper('config', $stubHelper); // Callback that receives list of run tests $runTestCases = array(); $func = function (PHPUnit_Framework_Test $test) use(&$runTestCases) { $runTestCases[] = get_class($test); }; $suite->expects($this->any())->method('runTest')->will($this->returnCallback($func)); $this->_fillTests($suite); $suite->run(null, false, $groups, $excludeGroups, false); // Restore old values Magento_Test_Helper_Factory::setHelper('config', $prevHelper); // Sort arrays to be sure, as order of tests is not important for us sort($expectedTestCases); sort($runTestCases); $this->assertEquals($expectedTestCases, $runTestCases); }
/** * Returns groups of tests for enabled modules * * @return array */ protected function _getRelevantGroups() { $allGroups = $this->getGroups(); $enabledModules = Magento_Test_Helper_Factory::getHelper('config')->getEnabledModules(); $fullPrefix = self::PREFIX_MODULE . self::PART_SEPARATOR; // Basic list of included modules $result = array(); foreach ($enabledModules as $moduleName) { $result[] = $fullPrefix . $moduleName; } // Add non-module groups, if allowed $prefixLength = strlen($fullPrefix); if (!$this->_moduleGroupsOnly) { foreach ($allGroups as $groupName) { if (strncmp($groupName, $fullPrefix, $prefixLength) != 0) { $result[] = $groupName; } } } return $result; }