Unit tests

Last updated on
10 September 2020

Creating and running unit tests

To create the Open Social unit tests, these tests need to be placed in certain predefined directories.
These directories are added to the file: phpunit.xml.dist in the distribution.

If you look at:

html/profiles/contrib/social/phpunit.xml.dist

you'll see we have several suites, 

we run all the social tests from the following 

<testsuite name="social">
      <directory>modules/*/*/tests/src/Unit</directory>
      <directory>modules/*/*/*/tests/src/Unit</directory>
      <exclude>
        <file>modules/contrib/address/tests/src/Unit/Plugin/Validation/Constraint/CountryConstraintValidatorTest.php</file>
      </exclude>
</testsuite>

so all tests written in features or custom modules within open social are tested.
Do you want to test something else? You can use the core-contrib or unit-core suite.

Running unit tests in Docker

To run the unit tests in a docker environment use the dev-scripts/unit_tests.sh script.

docker exec -it social_web bash /var/www/dev-scripts/unit-tests.sh

Help improve this page

Page status: No known problems

You can: