You are here

protected function QuoteTest::createQuote in Ubercart 8.4

Creates a flat rate shipping quote with optional conditions.

Parameters

array $edit: Data to use to create shipping quote.

bool $condition: If specified, a RulesAnd component defining the conditions to apply for this method.

Return value

\Drupal\uc_quote\Entity\ShippingQuoteMethod The shipping quote configuration entity.

2 calls to QuoteTest::createQuote()
QuoteTest::testNoQuote in shipping/uc_quote/src/Tests/QuoteTest.php
Verifies shipping pane is hidden when there are no shippable items.
QuoteTest::testQuote in shipping/uc_quote/src/Tests/QuoteTest.php
Tests basic flatrate shipping quote functionality.

File

shipping/uc_quote/src/Tests/QuoteTest.php, line 56

Class

QuoteTest
Tests shipping quote functionality.

Namespace

Drupal\uc_quote\Tests

Code

protected function createQuote(array $edit = [], $condition = FALSE) {
  $edit += [
    'id' => $this
      ->randomMachineName(),
    'label' => $this
      ->randomMachineName(),
    'status' => 1,
    'weight' => 0,
    'plugin' => 'flatrate',
    'settings' => [
      'base_rate' => mt_rand(1, 10),
      'product_rate' => mt_rand(1, 10),
    ],
  ];
  $method = ShippingQuoteMethod::create($edit);
  $method
    ->save();

  // if ($condition) {
  //   $name = 'get_quote_from_flatrate_' . $method->mid;
  //   $condition['LABEL'] = $edit['label'] . ' conditions';
  //   $oldconfig = rules_config_load($name);
  //   $newconfig = rules_import([$name => $condition]);
  //   $newconfig->id = $oldconfig->id;
  //   unset($newconfig->is_new);
  //   $newconfig->status = ENTITY_CUSTOM;
  //   $newconfig->save();
  //   entity_flush_caches();
  // }
  return $method;
}