You are here

public function ContrivedControllerTest::testAdd in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 testing_example/tests/src/Unit/Controller/ContrivedControllerTest.php \Drupal\Tests\testing_example\Unit\Controller\ContrivedControllerTest::testAdd()

Test add.

@dataProvider provideTestAdd

File

modules/testing_example/tests/src/Unit/Controller/ContrivedControllerTest.php, line 29

Class

ContrivedControllerTest
The class to test ContrivedController.

Namespace

Drupal\Tests\testing_example\Unit\Controller

Code

public function testAdd($expected, $first, $second) {
  $controller = $this
    ->getMockBuilder(ContrivedController::class)
    ->disableOriginalConstructor()
    ->getMock();
  $ref_add = new \ReflectionMethod($controller, 'add');
  $ref_add
    ->setAccessible(TRUE);
  $this
    ->assertEquals($expected, $ref_add
    ->invokeArgs($controller, [
    $first,
    $second,
  ]));
}