Example: Testing

This example demonstrates Drupal 8 testing frameworks.

This module creates a new node type called 'Testing Example Node Type,' so that we can test it.

This code was originally written to accompany the tutorial at http://drupal.org/node/890654. That's a Drupal 7 example, but can still teach you much.

Parent topics

File

modules/testing_example/testing_example.module, line 12

Functions

Title Sort descending File name Summary
testing_example_node_access modules/testing_example/testing_example.module Implements hook_node_access().
testing_example_test_node_view modules/testing_example/tests/modules/testing_example_test/testing_example_test.module Implements hook_ENTITY_TYPE_view().

Classes

Title Sort descending File name Summary
DisplayManager modules/testing_example/src/DisplayManager.php An example class to demonstrate unit testing.
DisplayManagerTest modules/testing_example/tests/src/Unit/DisplayManagerTest.php DisplayManager unit test with doubles.
ExampleFixtureManagementTest modules/testing_example/tests/src/Kernel/ExampleFixtureManagementTest.php Demonstrate manipulating fixture data in a kernel test.
PHPUnitExampleMenuTest modules/testing_example/tests/src/Functional/PHPUnitExampleMenuTest.php Test the user-facing menus in PHPUnit Example.
ProtectedPrivates modules/testing_example/src/ProtectedPrivates.php A class with features to show how to do unit testing.
ProtectedPrivatesSubclass modules/testing_example/tests/src/Unit/Subclasses/ProtectedPrivatesSubclass.php A class for testing ProtectedPrivate::protectedAdd().
ProtectedPrivatesTest modules/testing_example/tests/src/Unit/ProtectedPrivatesTest.php ProtectedPrivates unit testing of restricted methods.
SkeletonTest modules/testing_example/tests/src/Functional/SkeletonTest.php Skeleton functional test.
TestingExampleMenuTest modules/testing_example/tests/src/Functional/TestingExampleMenuTest.php Test the user-facing menus in Testing Example.

Interfaces

Title Sort descending File name Summary
DisplayInfoInterface modules/testing_example/src/DisplayInfoInterface.php An interface to objects that provide displayable information.