Exemplo n.º 1
0
 /**
  * Creates a SeleniumTestSuite and add all the selenium test cases to it
  *
  * @return PHPUnit_Extensions_SeleniumTestSuite
  */
 public static function suite()
 {
     $suite = new PHPUnit_Extensions_SeleniumTestSuite('phpMyAdmin');
     $suite->addTestSuite('PmaSeleniumLoginTest');
     $suite->addTestSuite('PmaSeleniumXssTest');
     $suite->addTestSuite('PmaSeleniumPrivilegesTest');
     $suite->addTestSuite('PmaSeleniumCreateDropDatabaseTest');
     $suite->addTestSuite('PmaSeleniumCreateRemoveUserTest');
     return $suite;
 }
 public static function suite($className)
 {
     return PHPUnit_Extensions_SeleniumTestSuite::fromTestCaseClass($className);
 }
 /**
  * @param  string $className
  * @return PHPUnit_Framework_TestSuite
  */
 public static function suite($className)
 {
     $suite = new PHPUnit_Extensions_SeleniumTestSuite();
     $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 = new PHPUnit_Framework_TestSuite();
                 $browserSuite->setName($className . ': ' . $browser['name']);
                 foreach ($files as $file) {
                     self::addConfiguredTestTo($browserSuite, new $className($file, array(), '', $browser), $classGroups);
                 }
                 $suite->addTest($browserSuite);
             }
         } else {
             foreach ($files as $file) {
                 self::addConfiguredTestTo($suite, new $className($file), $classGroups);
             }
         }
     }
     // Create tests from test methods for multiple browsers.
     if (!empty($staticProperties['browsers'])) {
         foreach ($staticProperties['browsers'] as $browser) {
             $browserSuite = new PHPUnit_Framework_TestSuite();
             $browserSuite->setName($className . ': ' . $browser['name']);
             foreach ($class->getMethods() as $method) {
                 if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
                     $name = $method->getName();
                     $test = PHPUnit_Framework_TestSuite::createTest($class, $name);
                     if ($test instanceof PHPUnit_Framework_TestCase) {
                         $test->setupSpecificBrowser($browser);
                         $groups = PHPUnit_Util_Test::getGroups($className, $name);
                         self::addConfiguredTestTo($browserSuite, $test, $groups);
                     } else {
                         $browserSuite->addTest($test);
                     }
                 }
             }
             $suite->addTest($browserSuite);
         }
     } else {
         foreach ($class->getMethods() as $method) {
             if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
                 $name = $method->getName();
                 $test = PHPUnit_Framework_TestSuite::createTest($class, $name);
                 if ($test instanceof PHPUnit_Framework_TestCase) {
                     $groups = PHPUnit_Util_Test::getGroups($className, $name);
                     self::addConfiguredTestTo($suite, $test, $groups);
                 } else {
                     $suite->addTest($test);
                 }
             }
         }
     }
     return $suite;
 }