function ProtectedPrivates::protectedAdd
Same name in other branches
- 3.x modules/phpunit_example/src/ProtectedPrivates.php \Drupal\phpunit_example\ProtectedPrivates::protectedAdd()
- 4.0.x modules/phpunit_example/src/ProtectedPrivates.php \Drupal\phpunit_example\ProtectedPrivates::protectedAdd()
- 4.0.x modules/testing_example/src/ProtectedPrivates.php \Drupal\testing_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 phpunit_example/
tests/ src/ Unit/ Subclasses/ ProtectedPrivatesSubclass.php - A stub class so we can access a protected method.
File
-
phpunit_example/
src/ ProtectedPrivates.php, line 33
Class
- ProtectedPrivates
- A class with features to show how to do unit testing.
Namespace
Drupal\phpunit_exampleCode
protected function protectedAdd($a, $b) {
$adder = new AddClass();
return $adder->add($a, $b);
}