function ProtectedPrivates::protectedAdd
Same name in this branch
- 4.0.x modules/phpunit_example/src/ProtectedPrivates.php \Drupal\phpunit_example\ProtectedPrivates::protectedAdd()
Same name in other branches
- 3.x modules/phpunit_example/src/ProtectedPrivates.php \Drupal\phpunit_example\ProtectedPrivates::protectedAdd()
- 8.x-1.x phpunit_example/src/ProtectedPrivates.php \Drupal\phpunit_example\ProtectedPrivates::protectedAdd()
A simple addition method with validity checking.
Parameters
int|float $a: A number to add.
int|float $b: Another number to add.
Return value
int|float The sum of $a and $b.
Throws
\InvalidArgumentException If either $a or $b is non-numeric, we can't add, so we throw.
1 call to ProtectedPrivates::protectedAdd()
- ProtectedPrivatesSubclass::subclassProtectedAdd in modules/
testing_example/ tests/ src/ Unit/ Subclasses/ ProtectedPrivatesSubclass.php - A stub class so we can access a protected method.
File
-
modules/
testing_example/ src/ ProtectedPrivates.php, line 33
Class
- ProtectedPrivates
- A class with features to show how to do unit testing.
Namespace
Drupal\testing_exampleCode
protected function protectedAdd($a, $b) {
$adder = new AddClass();
return $adder->add($a, $b);
}