Skip to content

Commit c599d44

Browse files
authored
Merge pull request #77 from attrib/master_require_once
Prevent files from being required twice
2 parents cdcf935 + a79442f commit c599d44

File tree

3 files changed

+111
-3
lines changed

3 files changed

+111
-3
lines changed

.circleci/config.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,48 @@ jobs:
9393
command: |
9494
cd /tmp/drupal
9595
./vendor/bin/phpstan analyze web/core/modules/dynamic_page_cache --debug
96+
test_upgrade_status:
97+
<<: *defaults
98+
steps:
99+
- start-project
100+
- run:
101+
name: Disable Xdebug PHP extension
102+
command: sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
103+
- create-drupal-project:
104+
project: 'drupal/drupal:^8@alpha'
105+
- local-require
106+
# @todo use this when `require` constraints relaxed.
107+
# - run:
108+
# name: Add upgrade_status
109+
# command: |
110+
# cd /tmp/drupal
111+
# composer require drupal/upgrade_status:1.x-dev
112+
# @todo use composer, not this hack.
113+
- run:
114+
name: Add upgrade_status
115+
command: |
116+
cd /tmp/drupal
117+
composer require phpstan/phpstan-deprecation-rules drupal/git_deploy
118+
curl -L https://ftp.drupal.org/files/projects/upgrade_status-8.x-1.x-dev.tar.gz | tar -zx -C /tmp/drupal/modules
119+
- run:
120+
name: Start builtin
121+
command: php -S 127.0.0.1:8080 -t /tmp/drupal
122+
background: true
123+
- run:
124+
name: Wait for web server
125+
command: dockerize -wait http://127.0.0.1:8080 -timeout 120s
126+
- run:
127+
name: Upgrade Status PHPUnit
128+
command: |
129+
cp ~/repo/tests/fixtures/config/circleci-phpunit.xml /tmp/drupal/core/phpunit.xml
130+
cd /tmp/drupal
131+
composer run-script drupal-phpunit-upgrade
132+
./vendor/bin/phpunit -c core modules/upgrade_status --debug --stop-on-failure
96133
workflows:
97134
version: 2
98135
tests:
99136
jobs:
100137
- build
101138
- test_drupal
102139
- test_drupal_project
140+
- test_upgrade_status

src/Drupal/Bootstrap.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,12 @@ protected function loadLegacyIncludes(): void
145145
{
146146
/** @var \SplFileInfo $file */
147147
foreach (Finder::findFiles('*.inc')->in($this->drupalRoot . '/core/includes') as $file) {
148-
require $file->getPathname();
148+
require_once $file->getPathname();
149149
}
150150
}
151151

152152
protected function addCoreNamespaces(): void
153153
{
154-
require $this->drupalRoot . '/core/lib/Drupal.php';
155154
foreach (['Core', 'Component'] as $parent_directory) {
156155
$path = $this->drupalRoot . '/core/lib/Drupal/' . $parent_directory;
157156
$parent_namespace = 'Drupal\\' . $parent_directory;
@@ -232,7 +231,7 @@ protected function loadExtension(Extension $extension): void
232231
protected function loadAndCatchErrors(string $path): void
233232
{
234233
try {
235-
require $path;
234+
require_once $path;
236235
} catch (ContainerNotInitializedException $e) {
237236
$path = str_replace(dirname($this->drupalRoot) . '/', '', $path);
238237
// This can happen when drupal_get_path or drupal_get_filename are used outside of the scope of a function.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
4+
<!-- PHPUnit expects functional tests to be run with either a privileged user
5+
or your current system user. See core/tests/README.md and
6+
https://www.drupal.org/node/2116263 for details.
7+
-->
8+
<phpunit bootstrap="tests/bootstrap.php" colors="true"
9+
beStrictAboutTestsThatDoNotTestAnything="true"
10+
beStrictAboutOutputDuringTests="true"
11+
beStrictAboutChangesToGlobalState="true">
12+
<!-- TODO set printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" once
13+
https://youtrack.jetbrains.com/issue/WI-24808 is resolved. Drupal provides a
14+
result printer that links to the html output results for functional tests.
15+
Unfortunately, this breaks the output of PHPStorm's PHPUnit runner. However, if
16+
using the command line you can add
17+
- -printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" to use it (note there
18+
should be no spaces between the hyphens).
19+
-->
20+
<php>
21+
<!-- Set error reporting to E_ALL. -->
22+
<ini name="error_reporting" value="32767"/>
23+
<!-- Do not limit the amount of memory tests take to run. -->
24+
<ini name="memory_limit" value="-1"/>
25+
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
26+
<env name="SIMPLETEST_BASE_URL" value="http://127.0.0.1:8080"/>
27+
<!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix -->
28+
<env name="SIMPLETEST_DB" value="sqlite://localhost/sites/default/files/.ht.sqlite"/>
29+
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
30+
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
31+
<!-- To disable deprecation testing completely uncomment the next line. -->
32+
<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> -->
33+
<!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' -->
34+
<!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
35+
<!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' -->
36+
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["firefox", null, "http://localhost:4444/wd/hub"]' -->
37+
</php>
38+
<testsuites>
39+
<testsuite name="unit">
40+
<file>./tests/TestSuites/UnitTestSuite.php</file>
41+
</testsuite>
42+
<testsuite name="kernel">
43+
<file>./tests/TestSuites/KernelTestSuite.php</file>
44+
</testsuite>
45+
<testsuite name="functional">
46+
<file>./tests/TestSuites/FunctionalTestSuite.php</file>
47+
</testsuite>
48+
<testsuite name="functional-javascript">
49+
<file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
50+
</testsuite>
51+
</testsuites>
52+
<listeners>
53+
<listener class="\Drupal\Tests\Listeners\DrupalListener">
54+
</listener>
55+
<!-- The Symfony deprecation listener has to come after the Drupal listener -->
56+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
57+
</listener>
58+
</listeners>
59+
<!-- Filter for coverage reports. -->
60+
<filter>
61+
<whitelist>
62+
<directory>./includes</directory>
63+
<directory>./lib</directory>
64+
<directory>./modules</directory>
65+
<directory>../modules</directory>
66+
<directory>../sites</directory>
67+
<!-- Exclude all test modules, tests etc -->
68+
<exclude-pattern>*/tests/*</exclude-pattern>
69+
</whitelist>
70+
</filter>
71+
</phpunit>

0 commit comments

Comments
 (0)