Skip to content

Commit

Permalink
Merge pull request #465 from essexcountycouncil/feature/ECCW-693
Browse files Browse the repository at this point in the history
feat(ECCW-509): DDEV commands, phpcs*.xml, phpunit*.xml.
  • Loading branch information
Polynya authored Sep 2, 2024
2 parents 11bab60 + e51d0ce commit 33c61ed
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .ddev/commands/web/phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

## Description: Run phpcbf to automatically fix some phpcs errors.
## Usage: phpcbf
## Example: "ddev phpcbf"

{
/var/www/html/bin/phpcbf --standard=phpcbf-ecc.xml $*
} || {
echo Fix the remaining issues manually.
}
11 changes: 11 additions & 0 deletions .ddev/commands/web/phpcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

## Description: Run phpcs in the web container.
## Usage: phpcs
## Example: "ddev phpcs"

{
/var/www/html/bin/phpcs --standard=phpcs-ecc.xml $*
} || {
echo Please fix these issues.
}
8 changes: 8 additions & 0 deletions .ddev/commands/web/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

## Description: Run phpunit in the web container to run phpunit tests.
## Usage: phpunit
## Example: "ddev phpunit"

export SYMFONY_DEPRECATIONS_HELPER=weak
/var/www/html/bin/phpunit -c /var/www/html/phpunit-ecc.xml $*
8 changes: 8 additions & 0 deletions .ddev/commands/web/phpunit-lgd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

## Description: Run phpunit in the web container to run phpunit tests on LGD.
## Usage: phpunit-lgd
## Example: "ddev phpunit-lgd"

/var/www/html/bin/phpunit -c /var/www/html/phpunit-lgd.xml $*

7 changes: 7 additions & 0 deletions .ddev/commands/web/phpunit-with-deprecations
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

## Description: Run phpunit in the web container to run phpunit tests.
## Usage: phpunit-with-deprecations
## Example: "ddev phpunit-with-deprecations"

/var/www/html/bin/phpunit -c /var/www/html/phpunit-ecc.xml $*
12 changes: 12 additions & 0 deletions phpcbf-ecc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="ecc">
<description>PHP CodeSniffer configuration for ECC custom modules.</description>

<arg name="extensions" value="inc,install,module,php,profile,test,theme,yml"/>
<config name="drupal_core_version" value="10"/>

<file>web/modules/custom/</file>

<rule ref="./vendor/drupal/coder/coder_sniffer/Drupal"/>
<rule ref="./vendor/drupal/coder/coder_sniffer/DrupalPractice"/>
</ruleset>
13 changes: 13 additions & 0 deletions phpcs-ecc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="ecc">
<description>PHP CodeSniffer configuration for ECC.</description>

<arg name="extensions" value="inc,install,module,php,profile,test,theme,yml"/>
<config name="drupal_core_version" value="10"/>

<file>web/modules/custom/</file>
<file>web/themes/contrib/ecc_theme</file>

<rule ref="./vendor/drupal/coder/coder_sniffer/Drupal"/>
<rule ref="./vendor/drupal/coder/coder_sniffer/DrupalPractice"/>
</ruleset>
19 changes: 19 additions & 0 deletions phpcs-lgd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="localgovdrupal">
<description>PHP CodeSniffer configuration for LocalGovDrupal.</description>

<arg name="extensions" value="inc,install,module,php,profile,test,theme,yml"/>
<config name="drupal_core_version" value="10"/>

<file>web/modules/contrib/</file>
<file>web/profiles/contrib/localgov/</file>
<file>web/themes/contrib/</file>

<!-- Exclude 3rd party code -->
<exclude-pattern>web\/modules\/contrib\/(?!localgov_.*)</exclude-pattern>
<exclude-pattern>web\/themes\/contrib\/(?!localgov_.*)</exclude-pattern>

<rule ref="./vendor/drupal/coder/coder_sniffer/Drupal"/>
<rule ref="./vendor/drupal/coder/coder_sniffer/DrupalPractice"/>

</ruleset>
44 changes: 44 additions & 0 deletions phpunit-ecc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="web/core/tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter">

<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
<ini name="memory_limit" value="-1"/>
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
<env name="SIMPLETEST_BASE_URL" value="https://essex-public.ddev.site/"/>
<!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix -->
<env name="SIMPLETEST_DB" value="mysql://database:database@database/database"/>
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
<!-- To have browsertest output use an alternative base URL. For example if
SIMPLETEST_BASE_URL is an internal DDEV URL, you can set this to the
external DDev URL so you can follow the links directly.
-->
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
</php>

<testsuites>
<testsuite name="modules">
<directory>/var/www/html/web/modules/custom/</directory>
</testsuite>
<testsuite name="themes">
<directory>/var/www/html/web/themes/contrib/ecc_theme</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="\Drupal\Tests\Listeners\DrupalListener">
</listener>
<!-- The Symfony deprecation listener has to come after the Drupal listener -->
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
</listener>
</listeners>

</phpunit>
52 changes: 52 additions & 0 deletions phpunit-lgd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="web/core/tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter">

<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
<ini name="memory_limit" value="-1"/>
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
<env name="SIMPLETEST_BASE_URL" value="https://essex-public.ddev.site"/>
<!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix -->
<env name="SIMPLETEST_DB" value="mysql://database:database@database/database"/>
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
<!-- To have browsertest output use an alternative base URL. For example if
SIMPLETEST_BASE_URL is an internal DDEV URL, you can set this to the
external DDev URL so you can follow the links directly.
-->
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
</php>

<testsuites>
<testsuite name="profile">
<directory>/var/www/html/web/profiles/contrib/localgov</directory>
</testsuite>
<testsuite name="modules">
<directory>/var/www/html/web/modules/contrib/localgov_*</directory>
<exclude>/var/www/html/web/modules/contrib/localgov_alert_banner/modules/group_alert_banner/tests</exclude>
</testsuite>
<testsuite name="themes">
<directory>/var/www/html/web/themes/contrib/localgov_*</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="\Drupal\Tests\Listeners\DrupalListener">
</listener>
<!-- The Symfony deprecation listener has to come after the Drupal listener -->
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
</listener>
</listeners>

<logging>
<log type="testdox-text" target="php://stdout"/>
</logging>

</phpunit>

0 comments on commit 33c61ed

Please sign in to comment.