You are here

protected function PluginSelectTest::doTestConditions in Commerce Core 8.2

Tests the configuration common to testPluginSelect and testPluginRadios.

2 calls to PluginSelectTest::doTestConditions()
PluginSelectTest::testPluginRadios in tests/src/FunctionalJavascript/PluginSelectTest.php
Tests the plugin_radios widget.
PluginSelectTest::testPluginSelect in tests/src/FunctionalJavascript/PluginSelectTest.php
Tests the plugin_select widget.

File

tests/src/FunctionalJavascript/PluginSelectTest.php, line 112

Class

PluginSelectTest
Tests the plugin select widgets.

Namespace

Drupal\Tests\commerce\FunctionalJavascript

Code

protected function doTestConditions() {
  $entity = $this
    ->createEntity('entity_test', [
    'name' => 'Test',
  ]);
  $this
    ->drupalGet($entity
    ->toUrl('edit-form'));
  $this
    ->getSession()
    ->getPage()
    ->fillField('test_plugin[0][target_plugin_id]', 'order_email');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->submitForm([
    'test_plugin[0][target_plugin_configuration][order_email][mail]' => 'test@example.com',
  ], 'Save');
  $this
    ->assertSession()
    ->pageTextContains('entity_test 1 has been updated.');
  $this->entityTestStorage
    ->resetCache([
    $entity
      ->id(),
  ]);
  $entity = $this->entityTestStorage
    ->load($entity
    ->id());
  $this
    ->assertEquals([
    'mail' => 'test@example.com',
  ], $entity->test_plugin->target_plugin_configuration);

  // Select the other condition.
  $this
    ->drupalGet($entity
    ->toUrl('edit-form'));
  $this
    ->getSession()
    ->getPage()
    ->fillField('test_plugin[0][target_plugin_id]', 'order_total_price');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->submitForm([
    'test_plugin[0][target_plugin_configuration][order_total_price][operator]' => '<',
    'test_plugin[0][target_plugin_configuration][order_total_price][amount][number]' => '6.67',
  ], 'Save');
  $this
    ->assertSession()
    ->pageTextContains('entity_test 1 has been updated.');
  $this->entityTestStorage
    ->resetCache([
    $entity
      ->id(),
  ]);
  $entity = $this->entityTestStorage
    ->load($entity
    ->id());
  $this
    ->assertEquals([
    'operator' => '<',
    'amount' => [
      'number' => '6.67',
      'currency_code' => 'USD',
    ],
  ], $entity->test_plugin->target_plugin_configuration);
}