function ContrivedControllerTest::testHandCount

Same name in other branches
  1. 3.x modules/testing_example/tests/src/Unit/Controller/ContrivedControllerTest.php \Drupal\Tests\testing_example\Unit\Controller\ContrivedControllerTest::testHandCount()
  2. 4.0.x modules/testing_example/tests/src/Unit/Controller/ContrivedControllerTest.php \Drupal\Tests\testing_example\Unit\Controller\ContrivedControllerTest::testHandCount()

Test hand count.

@dataProvider provideTestHandCount

File

testing_example/tests/src/Unit/Controller/ContrivedControllerTest.php, line 57

Class

ContrivedControllerTest
The class to test ContrivedController.

Namespace

Drupal\Tests\testing_example\Unit\Controller

Code

public function testHandCount($expected, $first, $second) {
    // Get a mock translation service.
    $mock_translation = $this->getStringTranslationStub();
    // Create a new controller with our mocked translation service.
    $controller = new ContrivedController($mock_translation);
    // Set up a reflection for handCount().
    $ref_hand_count = new \ReflectionMethod($controller, 'handCount');
    // Set handCount() to be public.
    $ref_hand_count->setAccessible(TRUE);
    // Check out whether handCount() meets our expectation.
    $message = $ref_hand_count->invokeArgs($controller, [
        $first,
        $second,
    ]);
    $this->assertEquals($expected, (string) $message);
}