Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix init of TC module #3511

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fix-init-of-tc-module
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: tweak

Init TicketsCommerce Module as soon as possible. [ETP-972]
3 changes: 3 additions & 0 deletions src/Tickets/Commerce/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function register() {
$this->container->singleton( Notice_Handler::class );

$this->container->singleton( Module::class );
// We need to init for the registration as a module to take place early.
$this->container->get( Module::class );
Comment on lines 63 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->container->singleton( Module::class );
// We need to init for the registration as a module to take place early.
$this->container->get( Module::class );
// We need to init for the registration as a module to take place early.
$this->container->singleton( Module::class, Module::class );

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ? if the the 2 first arguments are the same this is completely unnecessary. The singleton method already does that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing as 2nd param loads it immediately.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, i dont see it :(


$this->container->singleton( Attendee::class );
$this->container->singleton( Order::class );
$this->container->singleton( Ticket::class );
Expand Down
13 changes: 13 additions & 0 deletions tests/commerce_integration/_Load/CommerceModuleLoaded_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace ET;

use Codeception\TestCase\WPTestCase;
use Tribe__Tickets__Tickets as Tickets;
use TEC\Tickets\Commerce\Module;

class CommerceModuleLoaded_Test extends WPTestCase {
public function test_commerce_module_is_loaded_early() {
$this->assertArrayHasKey( Module::class, Tickets::modules() );
}
}
1 change: 0 additions & 1 deletion tests/commerce_integration/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use \TEC\Tickets\Commerce\Provider as Commerce_Provider;
use Tribe\Tickets\Promoter\Triggers\Dispatcher;

$tec_support = dirname( __DIR__, 3 ) . '/the-events-calendar/tests/_support';
Codeception\Util\Autoload::addNamespace( 'Tribe\Events\Test', $tec_support );
Expand Down
Loading