Merge pull request #24059 from eileenmcnaughton/pledged
[civicrm-core.git] / tests / phpunit / EnvTests.php
CommitLineData
52bd16c5
TO
1<?php
2
3/**
4 * The EnvTests suite allows you to specify an arbitrary mix of tests
5 * using an environment variable. For example:
6 *
7 * env PHPUNIT_TESTS="MyFirstTest MySecondTest" phpunit EnvTests
8 *
9 * The PHPUNIT_TESTS variable contains a space-delimited list of test
10 * names. Each name may be a class (eg "MyFirstTest") or a method
11 * (eg "MyFirstTest::testFoo").
12 */
a6439b6a 13class EnvTests extends \PHPUnit\Framework\TestSuite {
39b959db 14
f0be539a
EM
15 /**
16 * @return \EnvTests
17 */
52bd16c5
TO
18 public static function suite() {
19 require_once 'CRM/Core/ClassLoader.php';
20 CRM_Core_ClassLoader::singleton()->register();
21
22 $suite = new EnvTests();
23 $tests = getenv('PHPUNIT_TESTS');
24 foreach (explode(' ', $tests) as $test) {
25 if (strpos($test, '::') !== FALSE) {
26 list ($class, $method) = explode('::', $test);
27 $clazz = new \ReflectionClass($class);
28 $suite->addTestMethod($clazz, $clazz->getMethod($method));
0db6c3e1
TO
29 }
30 else {
52bd16c5
TO
31 $suite->addTestSuite($test);
32 }
33 }
34 return $suite;
35 }
96025800 36
ef10e0b5 37}