class ProtectedPrivatesSubclass
A class for testing ProtectedPrivate::protectedAdd().
We could use reflection to test protected methods, just as with private ones. But in some circumstances it might make more sense to make a subclass and then run the tests against it.
This subclass allows us to get access to the protected method.
Hierarchy
- class \Drupal\testing_example\ProtectedPrivates
- class \Drupal\Tests\testing_example\Unit\Subclasses\ProtectedPrivatesSubclass extends \Drupal\testing_example\ProtectedPrivates
 
 
Expanded class hierarchy of ProtectedPrivatesSubclass
Related topics
1 file declares its use of ProtectedPrivatesSubclass
- ProtectedPrivatesTest.php in modules/
testing_example/ tests/ src/ Unit/ ProtectedPrivatesTest.php  
File
- 
              modules/
testing_example/ tests/ src/ Unit/ Subclasses/ ProtectedPrivatesSubclass.php, line 18  
Namespace
Drupal\Tests\testing_example\Unit\SubclassesView source
class ProtectedPrivatesSubclass extends ProtectedPrivates {
  
  /**
   * A stub class so we can access a protected method.
   *
   * We use a naming convention to make it clear that we are using a
   * shimmed method.
   */
  public function subclassProtectedAdd($a, $b) {
    return $this->protectedAdd($a, $b);
  }
}
Members
| Title Sort descending | Modifiers | Object type | Summary | 
|---|---|---|---|
| ProtectedPrivates::privateAdd | private | function | A simple addition method with validity checking. | 
| ProtectedPrivates::protectedAdd | protected | function | A simple addition method with validity checking. | 
| ProtectedPrivatesSubclass::subclassProtectedAdd | public | function | A stub class so we can access a protected method. |