You are here

public function MobileNumberFieldTest::submitNodeForm in Mobile Number 8

Same name and namespace in other branches
  1. 2.0.x src/Tests/MobileNumberFieldTest.php \Drupal\mobile_number\Tests\MobileNumberFieldTest::submitNodeForm()

Submit node form.

2 calls to MobileNumberFieldTest::submitNodeForm()
MobileNumberFieldTest::createMobileNumberNode in src/Tests/MobileNumberFieldTest.php
Create node with mobile number(s).
MobileNumberFieldTest::createMobileNumberNodeFromInput in src/Tests/MobileNumberFieldTest.php
Create node with mobile number(s).

File

src/Tests/MobileNumberFieldTest.php, line 298

Class

MobileNumberFieldTest
Mobile number field functionality.'.

Namespace

Drupal\mobile_number\Tests

Code

public function submitNodeForm($node_type, $values, $number) {
  $values += [
    'body' => [
      Language::LANGCODE_NOT_SPECIFIED => [
        [],
      ],
    ],
    'title' => $this
      ->randomMachineName(8),
    'comment' => 2,
    'changed' => \Drupal::time()
      ->getRequestTime(),
    'moderate' => 0,
    'promote' => 0,
    'revision' => 1,
    'log' => '',
    'status' => 1,
    'sticky' => 0,
    'type' => $node_type,
    'revisions' => NULL,
    'language' => Language::LANGCODE_NOT_SPECIFIED,
  ];
  $node = \Drupal::entityTypeManager()
    ->getStorage('node')
    ->create($values);
  $form = \Drupal::entityTypeManager()
    ->getFormObject('node', 'default')
    ->setEntity($node);
  $form_state = new FormState();
  $form_state
    ->setValues($values);
  $form_state
    ->setValue('op', t('Save'));
  $form_state
    ->setProgrammedBypassAccessCheck(TRUE);
  $form_state
    ->setCached(FALSE);
  \Drupal::formBuilder()
    ->submitForm($form, $form_state);
  unset($_SESSION['mobile_number_verification'][$number]['verified']);
  return $form_state
    ->getErrors();
}