Skip to content

Commit 7f2b500

Browse files
committed
First attempt.
1 parent 83d338d commit 7f2b500

File tree

4 files changed

+119
-2
lines changed

4 files changed

+119
-2
lines changed

.ahoy.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ commands:
4545
4646
test:
4747
usage: Run all tests.
48-
cmd: ./.devtools/test.sh
48+
cmd: |
49+
pushd "build" >/dev/null || exit 1
50+
export SIMPLETEST_BASE_URL=http://localhost:8000
51+
vendor/bin/phpunit
52+
popd >/dev/null || exit 1
4953
5054
# Override entrypoint to alter default behaviour of Ahoy.
5155
entrypoint:

.devtools/build-codebase.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ for composer_suggest in $composer_suggests; do
107107
done
108108

109109
echo "> Copy tools configuration files."
110-
cp phpcs.xml phpstan.neon phpmd.xml rector.php .twig_cs.php "build/"
110+
cp phpcs.xml phpstan.neon phpmd.xml rector.php .twig_cs.php phpunit.xml "build/"
111111

112112
echo "> Symlink extension's code."
113113
rm -rf "build/web/${type}/custom" >/dev/null && mkdir -p "build/web/${type}/custom/${extension}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
.logs
12
composer.lock
23
build

phpunit.xml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- For how to customize PHPUnit configuration, see web/core/tests/README.md. -->
4+
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
5+
<!-- PHPUnit expects functional tests to be run with either a privileged user
6+
or your current system user. See core/tests/README.md and
7+
https://www.drupal.org/node/2116263 for details.
8+
-->
9+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
bootstrap="web/core/tests/bootstrap.php" colors="true"
11+
beStrictAboutTestsThatDoNotTestAnything="true"
12+
beStrictAboutOutputDuringTests="true"
13+
beStrictAboutChangesToGlobalState="true"
14+
failOnWarning="true"
15+
cacheResult="false"
16+
testdox="true"
17+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
18+
<php>
19+
<!-- Set error reporting to E_ALL. -->
20+
<ini name="error_reporting" value="32767"/>
21+
<!-- Do not limit the amount of memory tests take to run. -->
22+
<ini name="memory_limit" value="-1"/>
23+
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
24+
<env name="SIMPLETEST_BASE_URL" value=""/>
25+
<!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix -->
26+
<env name="SIMPLETEST_DB" value=""/>
27+
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
28+
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
29+
<!-- By default, browser tests will output links that use the base URL set
30+
in SIMPLETEST_BASE_URL. However, if your SIMPLETEST_BASE_URL is an internal
31+
path (such as may be the case in a virtual or Container-based environment),
32+
you can set the base URL used in the browser test output links to something
33+
reachable from your host machine here. This will allow you to follow them
34+
directly and view the output. -->
35+
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
36+
37+
<!-- Deprecation testing is managed through Symfony's PHPUnit Bridge.
38+
The environment variable SYMFONY_DEPRECATIONS_HELPER is used to configure
39+
the behaviour of the deprecation tests.
40+
See https://symfony.com/doc/current/components/phpunit_bridge.html#configuration
41+
Drupal core's testing framework is setting this variable to its defaults.
42+
Projects with their own requirements need to manage this variable
43+
explicitly.
44+
-->
45+
<!-- To disable deprecation testing completely uncomment the next line. -->
46+
<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> -->
47+
<!-- Deprecation errors can be selectively ignored by specifying a file of
48+
regular expression patterns for exclusion.
49+
See https://symfony.com/doc/current/components/phpunit_bridge.html#ignoring-deprecations
50+
Uncomment the line below to specify a custom deprecations ignore file.
51+
NOTE: it may be required to specify the full path to the file to run tests
52+
correctly.
53+
-->
54+
<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="ignoreFile=.deprecation-ignore.txt"/> -->
55+
56+
<!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' -->
57+
<env name="MINK_DRIVER_CLASS" value=''/>
58+
<!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
59+
<env name="MINK_DRIVER_ARGS" value=''/>
60+
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" -->
61+
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/>
62+
</php>
63+
<testsuites>
64+
<testsuite name="unit">
65+
<directory>web/modules/custom/*/tests/src/Unit</directory>
66+
<directory>web/themes/custom/*/tests/src/Unit</directory>
67+
</testsuite>
68+
<testsuite name="kernel">
69+
<directory>web/modules/custom/*/tests/src/Kernel</directory>
70+
<directory>web/themes/custom/*/tests/src/Kernel</directory>
71+
</testsuite>
72+
<testsuite name="functional">
73+
<directory>web/modules/custom/*/tests/src/Functional</directory>
74+
<directory>web/themes/custom/*/tests/src/Functional</directory>
75+
</testsuite>
76+
77+
<!-- Not implemented. -->
78+
<!-- See https://github.com/drevops/scaffold/issues/820 -->
79+
<!--
80+
<testsuite name="functional-javascript">
81+
<file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
82+
</testsuite>
83+
-->
84+
</testsuites>
85+
86+
<logging>
87+
<junit outputFile="../.logs/test_results/phpunit/phpunit.xml"/>
88+
</logging>
89+
90+
<!-- Settings for coverage reports. -->
91+
<coverage includeUncoveredFiles="true"
92+
pathCoverage="false"
93+
ignoreDeprecatedCodeUnits="true"
94+
disableCodeCoverageIgnore="false">
95+
<include>
96+
<directory>web/modules/custom</directory>
97+
<directory>web/themes/custom</directory>
98+
<directory>web/sites/default/includes</directory>
99+
<directory>web/sites/default/settings.php</directory>
100+
</include>
101+
102+
<exclude>
103+
<directory>web/modules/custom/*/tests</directory>
104+
<directory>web/themes/custom/*/tests</directory>
105+
</exclude>
106+
107+
<report>
108+
<html outputDirectory="../.logs/coverage/phpunit/.coverage-html" lowUpperBound="50" highLowerBound="90"/>
109+
<cobertura outputFile="../.logs/coverage/phpunit/cobertura.xml"/>
110+
</report>
111+
</coverage>
112+
</phpunit>

0 commit comments

Comments
 (0)