Ejemplo n.º 1
0
 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');
 }
Ejemplo n.º 2
0
 /**
  * @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);
 }