description.html.twig

Same filename in this branch
  1. 8.x-1.x menu_example/templates/description.html.twig
  2. 8.x-1.x form_api_example/templates/description.html.twig
  3. 8.x-1.x js_example/templates/description.html.twig
  4. 8.x-1.x page_example/templates/description.html.twig
  5. 8.x-1.x node_type_example/templates/description.html.twig
  6. 8.x-1.x pager_example/templates/description.html.twig
  7. 8.x-1.x block_example/templates/description.html.twig
  8. 8.x-1.x tabledrag_example/templates/description.html.twig
  9. 8.x-1.x tour_example/templates/description.html.twig
  10. 8.x-1.x config_entity_example/templates/description.html.twig
  11. 8.x-1.x tests/modules/examples_description_test/templates/description.html.twig
  12. 8.x-1.x phpunit_example/templates/description.html.twig
  13. 8.x-1.x render_example/templates/description.html.twig
  14. 8.x-1.x field_permission_example/templates/description.html.twig
  15. 8.x-1.x stream_wrapper_example/templates/description.html.twig
  16. 8.x-1.x ajax_example/templates/description.html.twig
  17. 8.x-1.x hooks_example/templates/description.html.twig
  18. 8.x-1.x field_example/templates/description.html.twig
Same filename in other branches
  1. 3.x modules/menu_example/templates/description.html.twig
  2. 3.x modules/form_api_example/templates/description.html.twig
  3. 3.x modules/js_example/templates/description.html.twig
  4. 3.x modules/page_example/templates/description.html.twig
  5. 3.x modules/node_type_example/templates/description.html.twig
  6. 3.x modules/pager_example/templates/description.html.twig
  7. 3.x modules/block_example/templates/description.html.twig
  8. 3.x modules/tabledrag_example/templates/description.html.twig
  9. 3.x modules/rest_example/templates/description.html.twig
  10. 3.x modules/testing_example/templates/description.html.twig
  11. 3.x modules/tour_example/templates/description.html.twig
  12. 3.x modules/config_entity_example/templates/description.html.twig
  13. 3.x modules/phpunit_example/templates/description.html.twig
  14. 3.x modules/render_example/templates/description.html.twig
  15. 3.x modules/field_permission_example/templates/description.html.twig
  16. 3.x modules/stream_wrapper_example/templates/description.html.twig
  17. 3.x modules/ajax_example/templates/description.html.twig
  18. 3.x modules/hooks_example/templates/description.html.twig
  19. 3.x modules/field_example/templates/description.html.twig
  20. 3.x tests/modules/examples_description_test/templates/description.html.twig
  21. 4.0.x modules/menu_example/templates/description.html.twig
  22. 4.0.x modules/form_api_example/templates/description.html.twig
  23. 4.0.x modules/js_example/templates/description.html.twig
  24. 4.0.x modules/page_example/templates/description.html.twig
  25. 4.0.x modules/node_type_example/templates/description.html.twig
  26. 4.0.x modules/pager_example/templates/description.html.twig
  27. 4.0.x modules/block_example/templates/description.html.twig
  28. 4.0.x modules/tabledrag_example/templates/description.html.twig
  29. 4.0.x modules/rest_example/templates/description.html.twig
  30. 4.0.x modules/testing_example/templates/description.html.twig
  31. 4.0.x modules/tour_example/templates/description.html.twig
  32. 4.0.x modules/config_entity_example/templates/description.html.twig
  33. 4.0.x modules/phpunit_example/templates/description.html.twig
  34. 4.0.x modules/render_example/templates/description.html.twig
  35. 4.0.x modules/field_permission_example/templates/description.html.twig
  36. 4.0.x modules/stream_wrapper_example/templates/description.html.twig
  37. 4.0.x modules/ajax_example/templates/description.html.twig
  38. 4.0.x modules/hooks_example/templates/description.html.twig
  39. 4.0.x modules/field_example/templates/description.html.twig
  40. 4.0.x tests/modules/examples_description_test/templates/description.html.twig
  41. 4.0.x modules/config_simple_example/templates/description.html.twig
{#

Description text for the PHPUnit Example.

#}

{% set sum_in_hands = path('testing_example.sum_in_hands') %}

{% trans %}

Testing Frameworks in Drupal

This module provides a path so we can test it. The path takes two numeric arguments, and tells you how many hands are required to count the sum of both numbers.

How to use this example module

You really should be reading the various docblocks in the files under tests/src/.

How To:

  • PHPUnit-based Drupal tests go in the tests/src directory, so they will not be loaded by the autoloader during normal bootstrap.
  • Unit tests go in [your_module]/tests/src/Unit.
  • Kernel tests go in [your_module]/tests/src/Kernel.
  • Functional tests go in [your_module]/tests/src/Functional.
Type Location Namespace Subclass of
Unit test [your_module]/tests/src/Unit Drupal\Tests\[your_module]\Unit\ Drupal\Tests\UnitTestCase
Kernel test [your_module]/tests/src/Kernel Drupal\Tests\[your_module]\Kernel\ Drupal\KernelTests\KernelTestBase
Functional test [your_module]/tests/src/Functional Drupal\Tests\[your_module]\Functional\ Drupal\Tests\BrowserTestBase
FunctionalJavascript test [your_module]/tests/src/FunctionalJavascript Drupal\Tests\[your_module]\FunctionalJavascript\ Drupal\FunctionalJavascriptTests\WebDriverTestBase
Shared test traits [your_module]/tests/src/Traits Drupal\Tests\[your_module]\Traits\ n/a

Standard PHPUnit Practices

You can run PHPUnit from the command line or via the run-tests.sh command.

You can specify which type of test you're running via

phpunit --testsuite
and
run-tests.sh --types
.

There are many options to phpunit, but, for instance, to run all of the testing_example phpunit tests, you could

./vendor/phpunit/phpunit/phpunit -c core/ ./modules/examples/testing_example

{% endtrans %}

File

testing_example/templates/description.html.twig

View source
  1. {#
  2. Description text for the PHPUnit Example.
  3. #}
  4. {% set sum_in_hands = path('testing_example.sum_in_hands') %}
  5. {% trans %}
  6. <h2>Testing Frameworks in Drupal</h2>
  7. <p>This module <a href={{ sum_in_hands }}>provides a path</a> so we can test it.
  8. The path takes two numeric arguments, and tells you how many hands are
  9. required to count the sum of both numbers.</p>
  10. <h3>How to use this example module</h3>
  11. <p>You really should be reading the various docblocks in the files under
  12. <code>tests/src/</code>.</p>
  13. <h3>How To:</h3>
  14. <ul>
  15. <li>PHPUnit-based Drupal tests go in the <code>tests/src</code> directory, so
  16. they will not be loaded by the autoloader during normal bootstrap.
  17. </li>
  18. <li>Unit tests go in <code>[your_module]/tests/src/Unit</code>.</li>
  19. <li>Kernel tests go in <code>[your_module]/tests/src/Kernel</code>.</li>
  20. <li>Functional tests go in <code>[your_module]/tests/src/Functional</code>.</li>
  21. </ul>
  22. <table>
  23. <thead>
  24. <tr>
  25. <td><b>Type</b></td>
  26. <td><b>Location</b></td>
  27. <td><b>Namespace</b></td>
  28. <td><b>Subclass of</b></td>
  29. </tr>
  30. </thead>
  31. <tbody>
  32. <tr>
  33. <td>Unit test</td>
  34. <td>[your_module]/tests/src/Unit</td>
  35. <td>Drupal\Tests\[your_module]\Unit\</td>
  36. <td>Drupal\Tests\UnitTestCase</td>
  37. </tr>
  38. <tr>
  39. <td>Kernel test</td>
  40. <td>[your_module]/tests/src/Kernel</td>
  41. <td>Drupal\Tests\[your_module]\Kernel\</td>
  42. <td>Drupal\KernelTests\KernelTestBase</td>
  43. </tr>
  44. <tr>
  45. <td>Functional test</td>
  46. <td>[your_module]/tests/src/Functional</td>
  47. <td>Drupal\Tests\[your_module]\Functional\</td>
  48. <td>Drupal\Tests\BrowserTestBase</td>
  49. </tr>
  50. <tr>
  51. <td>FunctionalJavascript test</td>
  52. <td>[your_module]/tests/src/FunctionalJavascript</td>
  53. <td>Drupal\Tests\[your_module]\FunctionalJavascript\</td>
  54. <td>Drupal\FunctionalJavascriptTests\WebDriverTestBase</td>
  55. </tr>
  56. <tr>
  57. <td>Shared test traits</td>
  58. <td>[your_module]/tests/src/Traits</td>
  59. <td>Drupal\Tests\[your_module]\Traits\</td>
  60. <td>n/a</td>
  61. </tr>
  62. </tbody>
  63. </table>
  64. <h3>Standard PHPUnit Practices</h3>
  65. <p>You can run PHPUnit from the command line or via the run-tests.sh command.</p>
  66. <p>You can specify which type of test you're running via
  67. <pre><code>phpunit --testsuite</code></pre> and
  68. <pre><code>run-tests.sh --types</code><pre>.
  69. <p>There are many options to phpunit, but, for instance, to run all of the
  70. testing_example phpunit tests, you could
  71. <pre><code>./vendor/phpunit/phpunit/phpunit -c core/ ./modules/examples/testing_example</code></pre>
  72. </p>
  73. {% endtrans %}