diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2050a712c13653ce131f5310f91714804c7875cd..04ce40f3ed66677736eb520fdd4067022c367404 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,60 +41,6 @@ include: - '/includes/include.drupalci.variables.yml' - '/includes/include.drupalci.workflows.yml' -################ -# Pipeline configuration variables -# -# These are the variables provided to the Run Pipeline form that a user may want to override. -# -# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml -################ -# variables: -# SKIP_ESLINT: '1' - - -################################################################################### -# -# * -# /( -# ((((, -# /((((((( -# ((((((((((* -# ,((((((((((((((( -# ,((((((((((((((((((( -# ((((((((((((((((((((((((* -# *((((((((((((((((((((((((((((( -# ((((((((((((((((((((((((((((((((((* -# *(((((((((((((((((( .(((((((((((((((((( -# ((((((((((((((((((. /(((((((((((((((((* -# /((((((((((((((((( .(((((((((((((((((, -# ,(((((((((((((((((( (((((((((((((((((( -# .(((((((((((((((((((( .((((((((((((((((( -# ((((((((((((((((((((((( ((((((((((((((((/ -# (((((((((((((((((((((((((((/ ,(((((((((((((((* -# .((((((((((((((/ /(((((((((((((. ,((((((((((((((( -# *(((((((((((((( ,(((((((((((((/ *((((((((((((((. -# ((((((((((((((, /(((((((((((((. ((((((((((((((, -# (((((((((((((/ ,(((((((((((((* ,(((((((((((((, -# *((((((((((((( .((((((((((((((( ,((((((((((((( -# ((((((((((((/ /((((((((((((((((((. ,((((((((((((/ -# ((((((((((((( *(((((((((((((((((((((((* *(((((((((((( -# ((((((((((((( ,(((((((((((((..((((((((((((( *(((((((((((( -# ((((((((((((, /((((((((((((* /((((((((((((/ (((((((((((( -# ((((((((((((( /((((((((((((/ (((((((((((((* (((((((((((( -# (((((((((((((/ /(((((((((((( ,((((((((((((, *(((((((((((( -# (((((((((((((( *(((((((((((/ *((((((((((((. ((((((((((((/ -# *((((((((((((((((((((((((((, /((((((((((((((((((((((((( -# ((((((((((((((((((((((((( ((((((((((((((((((((((((, -# .(((((((((((((((((((((((/ ,((((((((((((((((((((((( -# ((((((((((((((((((((((/ ,(((((((((((((((((((((/ -# *((((((((((((((((((((( (((((((((((((((((((((, -# ,(((((((((((((((((((((, ((((((((((((((((((((/ -# ,(((((((((((((((((((((* /(((((((((((((((((((( -# ((((((((((((((((((((((, ,/((((((((((((((((((((, -# ,((((((((((((((((((((((((((((((((((((((((((((((((((( -# .((((((((((((((((((((((((((((((((((((((((((((( -# .((((((((((((((((((((((((((((((((((((,. -# .,(((((((((((((((((((((((((. -# -################################################################################### - +variables: + SKIP_STYLELINT: '1' + _CSPELL_WORDS: 'advancedqueue, Ubercart, ubercart' diff --git a/commerce_license.info.yml b/commerce_license.info.yml index a8b8fa5cadc5c30848f3b74c125838b4cff04c7e..f3bbf5e17e8472c4a7be372c6383780fc59fcbec 100644 --- a/commerce_license.info.yml +++ b/commerce_license.info.yml @@ -1,7 +1,7 @@ name: Commerce License type: module description: Provides a framework for selling access to local or remote resources. -core_version_requirement: ^9.3 || ^10 +core_version_requirement: ^9.3 || ^10 || ^11 package: 'Commerce (contrib)' configure: entity.commerce_license.collection dependencies: diff --git a/composer.json b/composer.json index 7f29484d399b9a22b35d0b4ab71556cccf268990..ef5f686260b3a764007c07e768c767ae5a2d9d95 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,7 @@ "drupal/interval": "^1.11" }, "require-dev": { - "drupal/commerce_recurring": "^1.0@beta", - "dms/phpunit-arraysubset-asserts": "^0.3" + "drupal/commerce_recurring": "^1.0@beta" }, "conflict": { "drupal/recurring_period": "1.*" diff --git a/config/schema/commerce_license.schema.yml b/config/schema/commerce_license.schema.yml index e1d04466ea29e95b00631b6a51e613f93c1672ab..c04bab7c51bd230fd85dd0df9dcec9e6f73fc440 100644 --- a/config/schema/commerce_license.schema.yml +++ b/config/schema/commerce_license.schema.yml @@ -13,10 +13,10 @@ commerce_product.commerce_product_variation_type.*.third_party.commerce_license: label: 'Allow renewal of license before expiration' interval: type: text - label: 'Allow renewal of license within this timeframe of expiration (multiplier)' + label: 'Allow renewal of license within this time frame of expiration (multiplier)' period: type: text - label: 'Allow renewal of license within this timeframe of expiration (period unit)' + label: 'Allow renewal of license within this time frame of expiration (period unit)' views.field.commerce_license__entity_label: type: views.field.entity_label diff --git a/src/EventSubscriber/LicenseRenewalCartEventSubscriber.php b/src/EventSubscriber/LicenseRenewalCartEventSubscriber.php index 27ae023f036c58400a5824c6c0f2be3e92af8276..605139cbd497d43420195bc08be536c94a0b894f 100644 --- a/src/EventSubscriber/LicenseRenewalCartEventSubscriber.php +++ b/src/EventSubscriber/LicenseRenewalCartEventSubscriber.php @@ -61,9 +61,9 @@ class LicenseRenewalCartEventSubscriber implements EventSubscriberInterface { * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ public function __construct( - EntityTypeManagerInterface $entity_type_manager, - MessengerInterface $messenger, - DateFormatterInterface $date_formatter + EntityTypeManagerInterface $entity_type_manager, + MessengerInterface $messenger, + DateFormatterInterface $date_formatter, ) { $this->licenseStorage = $entity_type_manager->getStorage('commerce_license'); $this->entityTypeManager = $entity_type_manager; diff --git a/src/FormAlter/ProductVariationTypeFormAlter.php b/src/FormAlter/ProductVariationTypeFormAlter.php index e6b36aac67de34f9eddebf2462d378eff53f3c8a..5a831b7d545a13713a7006dabbb5a427022b2e74 100644 --- a/src/FormAlter/ProductVariationTypeFormAlter.php +++ b/src/FormAlter/ProductVariationTypeFormAlter.php @@ -75,7 +75,7 @@ class ProductVariationTypeFormAlter implements FormAlterInterface { $our_form['license']['activate_on_place'] = [ '#type' => 'checkbox', '#title' => $this->t('Activate license when order is placed'), - '#description' => $this->t('Activates the license as soon as the customer completes checkout, rather than waiting for payment to be taken. If payment subsequently fails, canceling the order will cancel the license. This only has an effect with order types that use validation or fulfilment states and payment gateways that are asynchronous.'), + '#description' => $this->t('Activates the license as soon as the customer completes checkout, rather than waiting for payment to be taken. If payment subsequently fails, canceling the order will cancel the license. This only has an effect with order types that use validation or fulfillment states and payment gateways that are asynchronous.'), '#default_value' => $product_variation_type->getThirdPartySetting('commerce_license', 'activate_on_place', FALSE), ]; diff --git a/src/LicenseAvailabilityCheckerExistingRights.php b/src/LicenseAvailabilityCheckerExistingRights.php index d0c8f2bae9a5e512079e7e0eb5410c4728c2cbec..5ca238b49981b80e41f5c1e9adccbde2000e73f9 100644 --- a/src/LicenseAvailabilityCheckerExistingRights.php +++ b/src/LicenseAvailabilityCheckerExistingRights.php @@ -116,7 +116,7 @@ class LicenseAvailabilityCheckerExistingRights implements AvailabilityCheckerInt return AvailabilityResult::neutral(); } - // Handle licence renewal. + // Handle license renewal. /** @var \Drupal\commerce_license\Entity\LicenseInterface $existing_license */ $existing_license = $this->entityTypeManager ->getStorage('commerce_license') diff --git a/tests/modules/commerce_license_set_expiry_test/commerce_license_set_expiry_test.info.yml b/tests/modules/commerce_license_set_expiry_test/commerce_license_set_expiry_test.info.yml index a15c19cc08573f8731100386cc8530d5b3231a8f..4cfdfe9e025157969f8fcfa2545056b58393bbfc 100644 --- a/tests/modules/commerce_license_set_expiry_test/commerce_license_set_expiry_test.info.yml +++ b/tests/modules/commerce_license_set_expiry_test/commerce_license_set_expiry_test.info.yml @@ -2,4 +2,3 @@ name: 'Commerce License Set Expiry Test' type: module description: 'Test module for Commerce License' package: Testing -core_version_requirement: ^9.3 || ^10 diff --git a/tests/modules/commerce_license_set_expiry_test/src/Plugin/Commerce/LicensePeriod/CommerceLicenseSetExpiryTest.php b/tests/modules/commerce_license_set_expiry_test/src/Plugin/Commerce/LicensePeriod/CommerceLicenseSetExpiry.php similarity index 90% rename from tests/modules/commerce_license_set_expiry_test/src/Plugin/Commerce/LicensePeriod/CommerceLicenseSetExpiryTest.php rename to tests/modules/commerce_license_set_expiry_test/src/Plugin/Commerce/LicensePeriod/CommerceLicenseSetExpiry.php index 47d0a4b22d9b84dab8f310f0203f64a3c6736e16..652ab2bf180672b594eb00b597a070f707061400 100644 --- a/tests/modules/commerce_license_set_expiry_test/src/Plugin/Commerce/LicensePeriod/CommerceLicenseSetExpiryTest.php +++ b/tests/modules/commerce_license_set_expiry_test/src/Plugin/Commerce/LicensePeriod/CommerceLicenseSetExpiry.php @@ -13,7 +13,7 @@ use Drupal\commerce_license\Plugin\Commerce\LicensePeriod\LicensePeriodBase; * description = @Translation("Set expiry test"), * ) */ -class CommerceLicenseSetExpiryTest extends LicensePeriodBase { +class CommerceLicenseSetExpiry extends LicensePeriodBase { /** * {@inheritdoc} diff --git a/tests/modules/commerce_license_test/commerce_license_test.info.yml b/tests/modules/commerce_license_test/commerce_license_test.info.yml index 2690ee7511931154defaebeff1bdc75d110d3ab6..023aa235c1fd72412283613d1930d823b3c3ce82 100644 --- a/tests/modules/commerce_license_test/commerce_license_test.info.yml +++ b/tests/modules/commerce_license_test/commerce_license_test.info.yml @@ -2,6 +2,5 @@ name: 'Commerce License Test' type: module description: 'Provides test license types.' package: Testing -core_version_requirement: ^9.3 || ^10 dependencies: - commerce_license:commerce_license diff --git a/tests/modules/commerce_license_test/src/Plugin/Commerce/LicenseType/LicenseStateChangeTest.php b/tests/modules/commerce_license_test/src/Plugin/Commerce/LicenseType/StateChange.php similarity index 92% rename from tests/modules/commerce_license_test/src/Plugin/Commerce/LicenseType/LicenseStateChangeTest.php rename to tests/modules/commerce_license_test/src/Plugin/Commerce/LicenseType/StateChange.php index 453e6d464499fb975858194e4dfb94f91c681413..91bfaccc645c8197ee35741df170d10aac59728b 100644 --- a/tests/modules/commerce_license_test/src/Plugin/Commerce/LicenseType/LicenseStateChangeTest.php +++ b/tests/modules/commerce_license_test/src/Plugin/Commerce/LicenseType/StateChange.php @@ -12,7 +12,7 @@ use Drupal\commerce_license\Entity\LicenseInterface; * label = @Translation("State change test"), * ) */ -class LicenseStateChangeTest extends TestLicenseBase { +class StateChange extends TestLicenseBase { /** * {@inheritdoc} diff --git a/tests/src/Kernel/CommerceAvailabilityExistingRightsTest.php b/tests/src/Kernel/CommerceAvailabilityExistingRightsTest.php index c730800698f9370f8abc11f2c526bd0a5779a24f..c6785a408a7e63d23577ec8081077c79b237c14f 100644 --- a/tests/src/Kernel/CommerceAvailabilityExistingRightsTest.php +++ b/tests/src/Kernel/CommerceAvailabilityExistingRightsTest.php @@ -69,9 +69,9 @@ class CommerceAvailabilityExistingRightsTest extends CartKernelTestBase { 'orderType' => $order_type->id(), 'traits' => ['commerce_license_order_item_type'], ]); - $this->traitManager = \Drupal::service('plugin.manager.commerce_entity_trait'); - $trait = $this->traitManager->createInstance('commerce_license_order_item_type'); - $this->traitManager->installTrait($trait, 'commerce_order_item', $order_item_type->id()); + $trait_manager = \Drupal::service('plugin.manager.commerce_entity_trait'); + $trait = $trait_manager->createInstance('commerce_license_order_item_type'); + $trait_manager->installTrait($trait, 'commerce_order_item', $order_item_type->id()); // Create a product variation type with the license trait, using our order // item type. @@ -81,13 +81,14 @@ class CommerceAvailabilityExistingRightsTest extends CartKernelTestBase { 'orderItemType' => 'license_order_item_type', 'traits' => ['commerce_license'], ]); - $trait = $this->traitManager->createInstance('commerce_license'); - $this->traitManager->installTrait($trait, 'commerce_product_variation', $product_variation_type->id()); + $trait = $trait_manager->createInstance('commerce_license'); + $trait_manager->installTrait($trait, 'commerce_product_variation', $product_variation_type->id()); // Create a product variation which grants a license. $this->variation = $this->createEntity('commerce_product_variation', [ 'type' => 'license_pv_type', 'sku' => $this->randomMachineName(), + 'title' => $this->randomString(), 'price' => [ 'number' => 999, 'currency_code' => 'USD', @@ -115,7 +116,7 @@ class CommerceAvailabilityExistingRightsTest extends CartKernelTestBase { $this->variation->save(); // Create a user to use for orders. - $this->user = $this->createUser(); + $this->createUser(); } /** diff --git a/tests/src/Kernel/CommerceOrderSyncRenewalTest.php b/tests/src/Kernel/CommerceOrderSyncRenewalTest.php index 20f10fbe906ffb00ab167ab7e3e90aac1e828118..720c18d431508e7ec94b71663ace8d4ac9fe2e3d 100644 --- a/tests/src/Kernel/CommerceOrderSyncRenewalTest.php +++ b/tests/src/Kernel/CommerceOrderSyncRenewalTest.php @@ -7,8 +7,10 @@ use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Entity\EntityInterface; use Drupal\Tests\commerce_cart\Kernel\CartKernelTestBase; +// cspell:ignore nrpv + /** - * Tests renewable behaviour on the license. + * Tests renewable behavior on the license. * * @group commerce_license */ @@ -131,9 +133,9 @@ class CommerceOrderSyncRenewalTest extends CartKernelTestBase { 'orderType' => 'license_order_type', 'traits' => ['commerce_license_order_item_type'], ]); - $this->traitManager = \Drupal::service('plugin.manager.commerce_entity_trait'); - $trait = $this->traitManager->createInstance('commerce_license_order_item_type'); - $this->traitManager->installTrait($trait, 'commerce_order_item', $order_item_type->id()); + $trait_manager = \Drupal::service('plugin.manager.commerce_entity_trait'); + $trait = $trait_manager->createInstance('commerce_license_order_item_type'); + $trait_manager->installTrait($trait, 'commerce_order_item', $order_item_type->id()); // Create a product variation type with the license trait, using our order // item type. @@ -143,8 +145,8 @@ class CommerceOrderSyncRenewalTest extends CartKernelTestBase { 'orderItemType' => 'license_order_item_type', 'traits' => ['commerce_license'], ]); - $trait = $this->traitManager->createInstance('commerce_license'); - $this->traitManager->installTrait($trait, 'commerce_product_variation', $this->variationType->id()); + $trait = $trait_manager->createInstance('commerce_license'); + $trait_manager->installTrait($trait, 'commerce_product_variation', $this->variationType->id()); $this->variationType->setThirdPartySetting('commerce_license', 'allow_renewal', TRUE); $this->variationType->setThirdPartySetting('commerce_license', 'interval', '1'); @@ -195,7 +197,7 @@ class CommerceOrderSyncRenewalTest extends CartKernelTestBase { 'orderItemType' => 'license_order_item_type', 'traits' => ['commerce_license'], ]); - $this->traitManager->installTrait($trait, 'commerce_product_variation', $this->nonRenewableVariationType->id()); + $trait_manager->installTrait($trait, 'commerce_product_variation', $this->nonRenewableVariationType->id()); $this->nonRenewableVariationType->setThirdPartySetting('commerce_license', 'allow_renewal', FALSE); $this->nonRenewableVariationType->save(); @@ -204,6 +206,7 @@ class CommerceOrderSyncRenewalTest extends CartKernelTestBase { $this->nonRenewableVariation = $this->createEntity('commerce_product_variation', [ 'type' => 'license_nrpv_type', 'sku' => $this->randomMachineName(), + 'title' => $this->randomString(), 'price' => [ 'number' => 999, 'currency_code' => 'USD', diff --git a/tests/src/Kernel/CommerceOrderSyncTest.php b/tests/src/Kernel/CommerceOrderSyncTest.php index cc63ca07c499169c415090b703ad32f2fcaf7063..c904ca470c53b41d0f09b0ed39a296bb7d15d003 100644 --- a/tests/src/Kernel/CommerceOrderSyncTest.php +++ b/tests/src/Kernel/CommerceOrderSyncTest.php @@ -113,6 +113,7 @@ class CommerceOrderSyncTest extends CartKernelTestBase { // Create a product variation which grants a license. $this->variation = $this->createEntity('commerce_product_variation', [ 'type' => 'license_pv_type', + 'title' => $this->randomString(), 'sku' => $this->randomMachineName(), 'price' => [ 'number' => 999, diff --git a/tests/src/Kernel/CommerceRecurringSubscriptionLifecycleTest.php b/tests/src/Kernel/CommerceRecurringSubscriptionLifecycleTest.php index d734fc0d3cb39037985db11881dd60b6b373a127..023f0425dcf6adcf599060fc1f340e85abba6e0e 100644 --- a/tests/src/Kernel/CommerceRecurringSubscriptionLifecycleTest.php +++ b/tests/src/Kernel/CommerceRecurringSubscriptionLifecycleTest.php @@ -26,6 +26,13 @@ use Drupal\Tests\commerce_order\Kernel\OrderKernelTestBase; */ class CommerceRecurringSubscriptionLifecycleTest extends OrderKernelTestBase { + /** + * A test billing schedule. + * + * @var \Drupal\commerce_recurring\Entity\BillingScheduleInterface + */ + protected $billingSchedule; + /** * The license storage. * @@ -33,6 +40,27 @@ class CommerceRecurringSubscriptionLifecycleTest extends OrderKernelTestBase { */ protected $licenseStorage; + /** + * A test payment method. + * + * @var \Drupal\commerce_payment\Entity\PaymentMethodInterface + */ + protected $paymentMethod; + + /** + * A sample user. + * + * @var \Drupal\user\UserInterface + */ + protected $user; + + /** + * The variation to test against. + * + * @var \Drupal\commerce_product\Entity\ProductVariationInterface + */ + protected $variation; + /** * Modules to enable. * @@ -126,12 +154,12 @@ class CommerceRecurringSubscriptionLifecycleTest extends OrderKernelTestBase { 'plugin' => 'example_onsite', ]); $payment_gateway->save(); - $this->paymentGateway = $this->reloadEntity($payment_gateway); + $payment_gateway = $this->reloadEntity($payment_gateway); /** @var \Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method */ $payment_method = PaymentMethod::create([ 'type' => 'credit_card', - 'payment_gateway' => $this->paymentGateway, + 'payment_gateway' => $payment_gateway, 'uid' => $this->user->id(), ]); $payment_method->save(); @@ -202,7 +230,7 @@ class CommerceRecurringSubscriptionLifecycleTest extends OrderKernelTestBase { $this->assertCount(0, $subscriptions); $order->set('total_paid', $order->getTotalPrice()); - $order->getState()->applyTransitionByid('place'); + $order->getState()->applyTransitionById('place'); $order->save(); $subscriptions = Subscription::loadMultiple(); diff --git a/tests/src/Kernel/LicenseCronExpiryTest.php b/tests/src/Kernel/LicenseCronExpiryTest.php index 7f752dc1b89a27c2d680c7a5cb60bb2cc6fa3009..d71a8886ba3c53b64fd8a88021a7823b131a9884 100644 --- a/tests/src/Kernel/LicenseCronExpiryTest.php +++ b/tests/src/Kernel/LicenseCronExpiryTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\commerce_license\Kernel\System; -use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use Drupal\advancedqueue\Entity\Queue; use Drupal\advancedqueue\Job; use Drupal\commerce_license\Cron; @@ -17,7 +16,6 @@ use Drupal\Tests\commerce_order\Kernel\OrderKernelTestBase; class LicenseCronExpiryTest extends OrderKernelTestBase { use AssertMailTrait; - use ArraySubsetAsserts; /** * The number of seconds in one day. @@ -264,7 +262,9 @@ class LicenseCronExpiryTest extends OrderKernelTestBase { $this->assertEquals([Job::STATE_QUEUED => 1], $counts); $job1 = $queue->getBackend()->claimJob(); - self::assertArraySubset(['license_id' => $license->id()], $job1->getPayload()); + $this->assertEquals([ + 'license_id' => $license->id(), + ], $job1->getPayload()); $this->assertEquals('commerce_license_expire', $job1->getType()); }