Commit 0bef0fb1 authored by Jonathan Sacksick's avatar Jonathan Sacksick
Browse files

Issue #3274739 by jsacksick: Fix the failing tests.

parent aa52be1a
Loading
Loading
Loading
Loading

composer.json

0 → 100644
+10 −0
Original line number Diff line number Diff line
{
    "name": "drupal/commerce_fee",
    "type": "drupal-module",
    "description": "Provides a UI for managing fees via Drupal Commerce.",
    "homepage": "https://drupal.org/project/commerce_fee",
    "license": "GPL-2.0-or-later",
    "require": {
        "drupal/commerce": "~2.25"
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -2,15 +2,15 @@

namespace Drupal\commerce_fee\Event;

use Drupal\commerce\EventBase;
use Drupal\commerce_fee\Entity\FeeInterface;
use Symfony\Component\EventDispatcher\Event;

/**
 * Defines the fee event.
 *
 * @see \Drupal\commerce_fee\Event\FeeEvents
 */
class FeeEvent extends Event {
class FeeEvent extends EventBase {

  /**
   * The fee.
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class OrderPercentage extends OrderFeeBase {
      if (isset($amounts[$order_item->id()])) {
        $order_item->addAdjustment(new Adjustment([
          'type' => 'fee',
          'label' => $promotion->getDisplayName() ?: $this->t('Fee'),
          'label' => $fee->getDisplayName() ?: $this->t('Fee'),
          'amount' => $amounts[$order_item->id()],
          'percentage' => $percentage,
          'source_id' => $fee->id(),
+7 −10
Original line number Diff line number Diff line
@@ -3,24 +3,21 @@
namespace Drupal\Tests\commerce_fee\FunctionalJavascript;

use Drupal\commerce_fee\Entity\Fee;
use Drupal\Tests\commerce\Functional\CommerceBrowserTestBase;
use Drupal\Tests\commerce\FunctionalJavascript\JavascriptTestTrait;
use Drupal\Tests\commerce\FunctionalJavascript\CommerceWebDriverTestBase;

/**
 * Tests the admin UI for fees.
 *
 * @group commerce
 */
class FeeTest extends CommerceBrowserTestBase {

  use JavascriptTestTrait;
class FeeTest extends CommerceWebDriverTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
  protected static $modules = [
    'block',
    'path',
    'commerce_product',
@@ -50,12 +47,12 @@ class FeeTest extends CommerceBrowserTestBase {
    $this->getSession()->getPage()->fillField('name[0][value]', $name);
    $this->getSession()->getPage()->fillField('display_name[0][value]', 'Fee');
    $this->getSession()->getPage()->selectFieldOption('plugin[0][target_plugin_id]', 'order_item_percentage');
    $this->waitForAjaxToFinish();
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->getSession()->getPage()->fillField('plugin[0][target_plugin_configuration][order_item_percentage][percentage]', '10.0');

    // Change, assert any values reset.
    $this->getSession()->getPage()->selectFieldOption('plugin[0][target_plugin_id]', 'order_percentage');
    $this->waitForAjaxToFinish();
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertSession()->fieldValueNotEquals('plugin[0][target_plugin_configuration][order_percentage][percentage]', '10.0');
    $this->getSession()->getPage()->fillField('plugin[0][target_plugin_configuration][order_percentage][percentage]', '10.0');

@@ -68,7 +65,7 @@ class FeeTest extends CommerceBrowserTestBase {
    $vertical_tab_element = reset($vertical_tab_elements);
    $vertical_tab_element->click();
    $this->getSession()->getPage()->checkField('Current order total');
    $this->waitForAjaxToFinish();
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->getSession()->getPage()->fillField('conditions[form][order][order_total_price][configuration][form][amount][number]', '50.00');

    $this->submitForm([], t('Save'));
@@ -101,7 +98,7 @@ class FeeTest extends CommerceBrowserTestBase {
    $this->assertSession()->fieldExists('name[0][value]');

    $this->getSession()->getPage()->fillField('plugin[0][target_plugin_id]', 'order_percentage');
    $this->waitForAjaxToFinish();
    $this->assertSession()->assertWaitOnAjaxRequest();

    $name = $this->randomMachineName(8);
    $edit = [
+4 −20
Original line number Diff line number Diff line
@@ -2,13 +2,12 @@

namespace Drupal\Tests\commerce_fee\Kernel\Entity;

use Drupal\commerce_order\Entity\OrderItemType;
use Drupal\commerce_order\Entity\OrderType;
use Drupal\commerce_price\RounderInterface;
use Drupal\commerce_fee\Entity\Fee;
use Drupal\commerce_fee\Plugin\Commerce\Fee\OrderItemPercentage;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Tests\commerce\Kernel\CommerceKernelTestBase;
use Drupal\Tests\commerce_order\Kernel\OrderKernelTestBase;

/**
 * Tests the Fee entity.
@@ -17,43 +16,28 @@ use Drupal\Tests\commerce\Kernel\CommerceKernelTestBase;
 *
 * @group commerce
 */
class FeeTest extends CommerceKernelTestBase {
class FeeTest extends OrderKernelTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'entity_reference_revisions',
    'profile',
    'state_machine',
    'commerce_order',
    'commerce_product',
  protected static $modules = [
    'commerce_fee',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
  protected function setUp(): void {
    parent::setUp();

    $this->installEntitySchema('profile');
    $this->installEntitySchema('commerce_order');
    $this->installEntitySchema('commerce_order_item');
    $this->installEntitySchema('commerce_fee');
    $this->installConfig([
      'profile',
      'commerce_order',
      'commerce_fee',
    ]);

    OrderItemType::create([
      'id' => 'test',
      'label' => 'Test',
      'orderType' => 'default',
    ])->save();
  }

  /**
Loading