Example #1
0
 /**
  * This method loads all available test suites for PHPUnit
  *
  * @return PHPUnit_Framework_TestSuite
  */
 public static function suite()
 {
     $groups = Mage::getConfig()->getNode(self::XML_PATH_UNIT_TEST_GROUPS);
     $modules = Mage::getConfig()->getNode(self::XML_PATH_UNIT_TEST_MODULES);
     $testSuiteClass = EcomDev_Utils_Reflection::getReflection((string) Mage::getConfig()->getNode(self::XML_PATH_UNIT_TEST_SUITE));
     if (!$testSuiteClass->isSubclassOf('EcomDev_PHPUnit_Test_Suite_Group')) {
         new RuntimeException('Test Suite class should be extended from EcomDev_PHPUnit_Test_Suite_Group');
     }
     $suite = new self('Magento Test Suite');
     // Walk through different groups in modules for finding test cases
     foreach ($groups->children() as $group) {
         foreach ($modules->children() as $module) {
             $realModule = Mage::getConfig()->getNode('modules/' . $module->getName());
             if (!$realModule || !$realModule->is('active')) {
                 $suite->addTest(self::warning('There is no module with name: ' . $module->getName()));
                 continue;
             }
             $moduleCodeDir = Mage::getBaseDir('code') . DS . (string) $realModule->codePool;
             $searchPath = Mage::getModuleDir('', $module->getName()) . DS . 'Test' . DS . (string) $group;
             if (!is_dir($searchPath)) {
                 continue;
             }
             $currentGroups = array($group->getName(), $module->getName());
             $testCases = self::_loadTestCases($searchPath, $moduleCodeDir);
             foreach ($testCases as $className) {
                 $suite->addTest($testSuiteClass->newInstance($className, $currentGroups));
             }
         }
     }
     if (!$suite->count()) {
         $suite->addTest(self::warning('There were no test cases for the current run'));
     }
     return $suite;
 }
Example #2
0
 public static function suite()
 {
     require_once 'IndexControllerTest.php';
     require_once 'ErrorControllerTest.php';
     $suite = new self('Default');
     $suite->addTest(new PHPUnit_Framework_TestSuite('IndexControllerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('ErrorControllerTest'));
     return $suite;
 }
Example #3
0
 public static function suite()
 {
     require_once 'IndexControllerTest.php';
     require_once 'ImagesControllerTest.php';
     require_once 'models/PageTest.php';
     require_once 'models/Page/TableTest.php';
     $suite = new self('Pages');
     $suite->addTest(new PHPUnit_Framework_TestSuite('Pages_IndexControllerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Pages_ImagesControllerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Model_PageTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Model_Page_ManagerTest'));
     return $suite;
 }
Example #4
0
 public static function suite()
 {
     require_once 'ManagementControllerTest.php';
     $suite = new self('Mail');
     $suite->addTest(new PHPUnit_Framework_TestSuite('Mail_ManagementControllerTest'));
     return $suite;
 }
Example #5
0
 public static function suite()
 {
     require_once 'models/OptionTest.php';
     $suite = new self('Options');
     $suite->addTest(new PHPUnit_Framework_TestSuite('Model_OptionTest'));
     return $suite;
 }
Example #6
0
 public static function suite()
 {
     require_once 'IndexControllerTest.php';
     require_once 'LoginControllerTest.php';
     require_once 'AuthControllerTest.php';
     require_once 'ManagementControllerTest.php';
     require_once 'RegisterControllerTest.php';
     require_once 'models/UserTest.php';
     require_once 'models/Users/ManagerTest.php';
     require_once 'models/Users/TableTest.php';
     $suite = new self('Users');
     $suite->addTest(new PHPUnit_Framework_TestSuite('Users_IndexControllerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Users_LoginControllerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Users_AuthControllerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Users_ManagementControllerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Users_RegisterControllerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Model_UserTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Model_Users_ManagerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Model_Users_TableTest'));
     return $suite;
 }
Example #7
0
 public static function suite()
 {
     require_once 'Zend/VersionTest.php';
     require_once 'Core/Controller/Plugin/AclTest.php';
     require_once 'Core/Dump/ManagerTest.php';
     require_once 'Core/Form/MultipageTest.php';
     require_once 'Core/Migration/ManagerTest.php';
     require_once 'Core/Tests/PHPUnit/ControllerTestCaseTest.php';
     require_once 'Core/Tests/PHPUnit/Constraint/DomQueryTest.php';
     $suite = new self('Library');
     $suite->addTest(new PHPUnit_Framework_TestSuite('Zend_VersionTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Core_Controller_Plugin_AclTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Core_Dump_ManagerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Core_Form_MultipageTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Core_Migration_ManagerTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Core_Tests_PHPUnit_ControllerTestCaseTest'));
     $suite->addTest(new PHPUnit_Framework_TestSuite('Core_Tests_PHPUnit_Constraint_DomQueryTest'));
     return $suite;
 }
 /**
  * Composes a TestSuite from a TestCaseClass or uses $staticProperties['phantomPath']
  * for creation of a TestSuite from a folder.
  *
  * @param  string $className extending PHPUnit_Extensions_PhantomTestCase
  * @return PHPUnit_Extensions_PhantomTestSuite
  */
 public static function addTestsFromTestCaseClass($className)
 {
     $suite = new self();
     $suite->setName($className);
     // use Ref to allow access to class properties
     $class = new ReflectionClass($className);
     $classGroups = PHPUnit_Util_Test::getGroups($className);
     $staticProperties = $class->getStaticProperties();
     // Tests come from Folder.
     // create tests from a folder with phantom .js or .coffee files
     if (isset($staticProperties['phantomPath']) === true) {
         $files = array();
         if (is_dir($staticProperties['phantomPath']) === true) {
             $files = array_merge(self::getTestFilesFromFolder($staticProperties['phantomPath'], '.js'), self::getTestFilesFromFolder($staticProperties['phantomPath'], '.coffee'));
         } else {
             $files[] = realpath($staticProperties['phantomPath']);
         }
         // create tests from PhantomJS javascript or coffee script files
         foreach ($files as $file) {
             $basename = basename($file);
             $filename = str_replace(array('.js', '.coffee'), array('', ''), $basename);
             // exclude some javascript tests from execution, because:
             $excludedFiles = array('modernizr', 'jquery', 'movies', 'seasonfood', 'outputEncoding', 'sleepsort', 'stdin-stdout-stderr', 'universe', 'colorwheel', 'technews');
             if (in_array($filename, $excludedFiles) === true) {
                 continue;
             }
             // filename to testname
             $testname = 'test_' . str_replace('.', '_', $basename);
             // every Phantom test file gets its own test case (one executePhantomJS call each)
             $test = new PHPUnit_Extensions_Phantom_FileExecute($testname, array($file));
             $suite->addTest($test, $classGroups);
         }
     } else {
         // Test come from a TestCaseClass.
         // create tests for all methods of the test case class
         foreach ($class->getMethods() as $method) {
             $suite->addTestMethod($class, $method);
         }
     }
     return $suite;
 }
 /**
  * @param string $className     extending PHPUnit_Extensions_SeleniumTestCase
  * @return PHPUnit_Extensions_SeleniumTestSuite
  */
 public static function fromTestCaseClass($className)
 {
     $suite = new self();
     $suite->setName($className);
     $class = new ReflectionClass($className);
     $classGroups = PHPUnit_Util_Test::getGroups($className);
     $staticProperties = $class->getStaticProperties();
     // Create tests from Selenese/HTML files.
     if (isset($staticProperties['seleneseDirectory']) && is_dir($staticProperties['seleneseDirectory'])) {
         $files = array_merge(self::getSeleneseFiles($staticProperties['seleneseDirectory'], '.htm'), self::getSeleneseFiles($staticProperties['seleneseDirectory'], '.html'));
         // Create tests from Selenese/HTML files for multiple browsers.
         if (!empty($staticProperties['browsers'])) {
             foreach ($staticProperties['browsers'] as $browser) {
                 $browserSuite = PHPUnit_Extensions_SeleniumBrowserSuite::fromClassAndBrowser($className, $browser);
                 foreach ($files as $file) {
                     self::addGeneratedTestTo($browserSuite, new $className($file, array(), '', $browser), $classGroups);
                 }
                 $suite->addTest($browserSuite);
             }
         } else {
             // Create tests from Selenese/HTML files for single browser.
             foreach ($files as $file) {
                 self::addGeneratedTestTo($suite, new $className($file), $classGroups);
             }
         }
     }
     // Create tests from test methods for multiple browsers.
     if (!empty($staticProperties['browsers'])) {
         foreach ($staticProperties['browsers'] as $browser) {
             $browserSuite = PHPUnit_Extensions_SeleniumBrowserSuite::fromClassAndBrowser($className, $browser);
             foreach ($class->getMethods() as $method) {
                 $browserSuite->addTestMethod($class, $method);
             }
             $browserSuite->setupSpecificBrowser($browser);
             $suite->addTest($browserSuite);
         }
     } else {
         // Create tests from test methods for single browser.
         foreach ($class->getMethods() as $method) {
             $suite->addTestMethod($class, $method);
         }
     }
     return $suite;
 }
Example #10
0
 /**
  * Static function to run one test. Used inside test files.
  * in IDE.
  * @param string $testClass
  */
 public static function test($testClass)
 {
     if (self::isRunnedByOthers() === FALSE) {
         $test = new self();
         $test->addTest($testClass, 'single file');
         $test->run();
     }
 }