You are here

public function EntityFormTest::providerTestSaveSettingsSetAndSave in Acquia Content Hub 8

Data provider for testSaveSettingsSetAndSave().

Return value

array Data.

File

tests/src/Unit/Form/EntityFormTest.php, line 344

Class

EntityFormTest
PHPUnit test for the EntityForm class.

Namespace

Drupal\Tests\acquia_contenthub\Unit\Form

Code

public function providerTestSaveSettingsSetAndSave() {
  $get_auto_update_true = TRUE;
  $get_auto_update_false = FALSE;
  $set_auto_update_true = 1;
  $set_auto_update_false = 0;
  $expect_call_set_pending_sync = 'setPendingSync';
  $expect_call_set_auto_update = 'setAutoUpdate';
  $expect_parameter_true = TRUE;
  $expect_parameter_false = FALSE;
  $expect_no_parameter = NULL;
  $data = [];

  // Case 1.
  // disabled -> disabled: setAutoUpdate(FALSE)
  $data['no local change, set auto update false'] = [
    $get_auto_update_false,
    $set_auto_update_false,
    $expect_call_set_auto_update,
    $expect_parameter_false,
  ];

  // Case 2.
  // disabled -> enabled: setPendingSync()
  // local change -> enabled: setPendingSync()
  // pending sync -> enabled: setPendingSync()
  // Note: when user indicates "enable", don't set "enable", instead, set to
  // the only state "pending sync" that will lead to "enabled".
  $data['no local change, set auto update true'] = [
    $get_auto_update_false,
    $set_auto_update_true,
    $expect_call_set_pending_sync,
    $expect_no_parameter,
  ];

  // Case 3.
  // enabled -> disabled: setAutoUpdate(FALSE)
  $data['yes local change, set auto update false'] = [
    $get_auto_update_true,
    $set_auto_update_false,
    $expect_call_set_auto_update,
    $expect_parameter_false,
  ];

  // Case 4.
  // enabled -> disabled: setAutoUpdate(TRUE)
  $data['yes local change, set auto update true'] = [
    $get_auto_update_true,
    $set_auto_update_true,
    $expect_call_set_auto_update,
    $expect_parameter_true,
  ];
  return $data;
}