Mercurial > hg > isophonics-drupal-site
comparison core/tests/bootstrap.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
6 * | 6 * |
7 * @see phpunit.xml.dist | 7 * @see phpunit.xml.dist |
8 */ | 8 */ |
9 | 9 |
10 use Drupal\Component\Assertion\Handle; | 10 use Drupal\Component\Assertion\Handle; |
11 use Drupal\Core\Composer\Composer; | |
12 use PHPUnit\Runner\Version; | |
11 | 13 |
12 /** | 14 /** |
13 * Finds all valid extension directories recursively within a given directory. | 15 * Finds all valid extension directories recursively within a given directory. |
14 * | 16 * |
15 * @param string $scan_directory | 17 * @param string $scan_directory |
147 }; | 149 }; |
148 | 150 |
149 // Do class loader population. | 151 // Do class loader population. |
150 drupal_phpunit_populate_class_loader(); | 152 drupal_phpunit_populate_class_loader(); |
151 | 153 |
154 // Ensure we have the correct PHPUnit version for the version of PHP. | |
155 if (class_exists('\PHPUnit_Runner_Version')) { | |
156 $phpunit_version = \PHPUnit_Runner_Version::id(); | |
157 } | |
158 else { | |
159 $phpunit_version = Version::id(); | |
160 } | |
161 if (!Composer::upgradePHPUnitCheck($phpunit_version)) { | |
162 $message = "PHPUnit testing framework version 6 or greater is required when running on PHP 7.2 or greater. Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this."; | |
163 echo "\033[31m" . $message . "\n\033[0m"; | |
164 exit(1); | |
165 } | |
166 | |
152 // Set sane locale settings, to ensure consistent string, dates, times and | 167 // Set sane locale settings, to ensure consistent string, dates, times and |
153 // numbers handling. | 168 // numbers handling. |
154 // @see \Drupal\Core\DrupalKernel::bootEnvironment() | 169 // @see \Drupal\Core\DrupalKernel::bootEnvironment() |
155 setlocale(LC_ALL, 'C'); | 170 setlocale(LC_ALL, 'C'); |
156 | 171 |
164 // Runtime assertions. PHPUnit follows the php.ini assert.active setting for | 179 // Runtime assertions. PHPUnit follows the php.ini assert.active setting for |
165 // runtime assertions. By default this setting is on. Here we make a call to | 180 // runtime assertions. By default this setting is on. Here we make a call to |
166 // make PHP 5 and 7 handle assertion failures the same way, but this call does | 181 // make PHP 5 and 7 handle assertion failures the same way, but this call does |
167 // not turn runtime assertions on if they weren't on already. | 182 // not turn runtime assertions on if they weren't on already. |
168 Handle::register(); | 183 Handle::register(); |
184 | |
185 // PHPUnit 4 to PHPUnit 6 bridge. Tests written for PHPUnit 4 need to work on | |
186 // PHPUnit 6 with a minimum of fuss. | |
187 if (version_compare($phpunit_version, '6.1', '>=')) { | |
188 class_alias('\PHPUnit\Framework\AssertionFailedError', '\PHPUnit_Framework_AssertionFailedError'); | |
189 class_alias('\PHPUnit\Framework\Constraint\Count', '\PHPUnit_Framework_Constraint_Count'); | |
190 class_alias('\PHPUnit\Framework\Error\Error', '\PHPUnit_Framework_Error'); | |
191 class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Warning'); | |
192 class_alias('\PHPUnit\Framework\ExpectationFailedException', '\PHPUnit_Framework_ExpectationFailedException'); | |
193 class_alias('\PHPUnit\Framework\Exception', '\PHPUnit_Framework_Exception'); | |
194 class_alias('\PHPUnit\Framework\MockObject\Matcher\InvokedRecorder', '\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder'); | |
195 class_alias('\PHPUnit\Framework\SkippedTestError', '\PHPUnit_Framework_SkippedTestError'); | |
196 class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); | |
197 class_alias('\PHPUnit\Util\Test', '\PHPUnit_Util_Test'); | |
198 class_alias('\PHPUnit\Util\XML', '\PHPUnit_Util_XML'); | |
199 } |