public function PaymentLineItemsInputTest::testGetElementId in Payment 8.2
@covers ::getElementId
File
- tests/
src/ Unit/ Element/ PaymentLineItemsInputTest.php, line 538
Class
- PaymentLineItemsInputTest
- @coversDefaultClass \Drupal\payment\Element\PaymentLineItemsInput
Namespace
Drupal\Tests\payment\Unit\ElementCode
public function testGetElementId() {
$element_build = array(
'#name' => $this
->randomMachineName(),
'#parents' => array(
$this
->randomMachineName(),
$this
->randomMachineName(),
),
);
$id_prefix = Html::getId('payment-element-payment_line_items_input');
$form_state = new FormState();
$method = new \ReflectionMethod($this->sut, 'getElementId');
$method
->setAccessible(TRUE);
// Check twice, because once the ID has been set it must not change.
$id = $method
->invoke($this->sut, $element_build, $form_state);
$this
->assertSame(0, strpos($id, $id_prefix));
$this
->assertSame($id, $method
->invoke($this->sut, $element_build, $form_state));
}