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

dev/core#2316 - Symfony EventDispatcher dispatch() signature kerfuffle - try 3 #24132

Merged
merged 14 commits into from
Nov 11, 2022
Merged
Prev Previous commit
Next Next commit
unit test updates
  • Loading branch information
demeritcowboy committed Nov 11, 2022
commit f6313472b50a5a0d836392f047632bee62445a31
8 changes: 4 additions & 4 deletions Civi/API/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class Kernel {

/**
* @var \Symfony\Component\EventDispatcher\EventDispatcher
* @var \Civi\Core\CiviEventDispatcherInterface
*/
protected $dispatcher;

Expand All @@ -33,7 +33,7 @@ class Kernel {
protected $apiProviders;

/**
* @param \Symfony\Component\EventDispatcher\EventDispatcher $dispatcher
* @param \Civi\Core\CiviEventDispatcherInterface $dispatcher
* The event dispatcher which receives kernel events.
* @param array $apiProviders
* Array of ProviderInterface.
Expand Down Expand Up @@ -462,14 +462,14 @@ public function registerApiProvider($apiProvider) {
}

/**
* @return \Symfony\Component\EventDispatcher\EventDispatcher
* @return \Civi\Core\CiviEventDispatcherInterface
*/
public function getDispatcher() {
return $this->dispatcher;
}

/**
* @param \Symfony\Component\EventDispatcher\EventDispatcher $dispatcher
* @param \Civi\Core\CiviEventDispatcherInterface $dispatcher
* The event dispatcher which receives kernel events.
* @return Kernel
*/
Expand Down
4 changes: 2 additions & 2 deletions Civi/Core/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public function createAngularManager() {
}

/**
* @return \Symfony\Component\EventDispatcher\EventDispatcher
* @return \Civi\Core\CiviEventDispatcherInterface
*/
public function createEventDispatcher() {
// Continue building on the original dispatcher created during bootstrap.
Expand Down Expand Up @@ -490,7 +490,7 @@ public static function createLockManager() {
}

/**
* @param \Symfony\Component\EventDispatcher\EventDispatcher $dispatcher
* @param \Civi\Core\CiviEventDispatcherInterface $dispatcher
* @param $magicFunctionProvider
*
* @return \Civi\API\Kernel
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/Civi/API/Event/PrepareEventTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Civi\API\Event;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Civi\Core\CiviEventDispatcher;
use Civi\API\Kernel;

/**
Expand All @@ -10,7 +10,7 @@ class PrepareEventTest extends \CiviUnitTestCase {
const MOCK_VERSION = 3;

/**
* @var \Symfony\Component\EventDispatcher\EventDispatcher
* @var \Civi\Core\CiviEventDispatcher
*/
public $dispatcher;

Expand All @@ -21,7 +21,7 @@ class PrepareEventTest extends \CiviUnitTestCase {

protected function setUp(): void {
parent::setUp();
$this->dispatcher = new EventDispatcher();
$this->dispatcher = new CiviEventDispatcher();
$this->kernel = new Kernel($this->dispatcher);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/Civi/API/KernelTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Civi\API;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Civi\Core\CiviEventDispatcher;

/**
*/
Expand All @@ -15,7 +15,7 @@ class KernelTest extends \CiviUnitTestCase {
public $actualEventSequence;

/**
* @var \Symfony\Component\EventDispatcher\EventDispatcher
* @var \Civi\Core\CiviEventDispatcher
*/
public $dispatcher;

Expand All @@ -27,7 +27,7 @@ class KernelTest extends \CiviUnitTestCase {
protected function setUp(): void {
parent::setUp();
$this->actualEventSequence = [];
$this->dispatcher = new EventDispatcher();
$this->dispatcher = new CiviEventDispatcher();
$this->monitorEvents(Events::allEvents());
$this->kernel = new Kernel($this->dispatcher);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Civi\API\Kernel;
use Civi\API\Provider\StaticProvider;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Civi\Core\CiviEventDispatcher;

/**
*/
Expand All @@ -19,7 +19,7 @@ class DynamicFKAuthorizationTest extends \CiviUnitTestCase {
const FORBIDDEN_ID = 30;

/**
* @var \Symfony\Component\EventDispatcher\EventDispatcher
* @var \Civi\Core\CiviEventDispatcher
*/
public $dispatcher;

Expand Down Expand Up @@ -67,7 +67,7 @@ protected function setUp(): void {
]
);

$this->dispatcher = new EventDispatcher();
$this->dispatcher = new CiviEventDispatcher();
$this->kernel = new Kernel($this->dispatcher);
$this->kernel
->registerApiProvider($fileProvider)
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/Civi/API/Subscriber/WhitelistSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Civi\API\Kernel;
use Civi\API\WhitelistRule;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Civi\Core\CiviEventDispatcher;

/**
* The WhitelistSubscriber enforces security policies
Expand Down Expand Up @@ -371,7 +371,7 @@ public function testEach($apiRequest, $rules, $expectSuccess) {

$whitelist = WhitelistRule::createAll($rules);

$dispatcher = new EventDispatcher();
$dispatcher = new CiviEventDispatcher();
$kernel = new Kernel($dispatcher);
$kernel->registerApiProvider($sprocketProvider);
$kernel->registerApiProvider($widgetProvider);
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/Civi/Token/TokenProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

use Civi\Token\Event\TokenRegisterEvent;
use Civi\Token\Event\TokenValueEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Civi\Core\CiviEventDispatcher;

class TokenProcessorTest extends \CiviUnitTestCase {

/**
* @var \Symfony\Component\EventDispatcher\EventDispatcher
* @var \Civi\Core\CiviEventDispatcher
*/
protected $dispatcher;

Expand All @@ -21,7 +21,7 @@ class TokenProcessorTest extends \CiviUnitTestCase {
protected function setUp(): void {
$this->useTransaction(TRUE);
parent::setUp();
$this->dispatcher = new EventDispatcher();
$this->dispatcher = new CiviEventDispatcher();
$this->dispatcher->addListener('civi.token.list', [$this, 'onListTokens']);
$this->dispatcher->addListener('civi.token.eval', [$this, 'onEvalTokens']);
$this->counts = [
Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/E2E/Core/AssetBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ protected function setUp(): void {
\Civi::dispatcher()->addListener('hook_civicrm_buildAsset', array($this, 'buildSquareJs'));
}

protected function tearDown(): void {
\Civi::dispatcher()->removeListener('hook_civicrm_buildAsset', array($this, 'counter'));
\Civi::dispatcher()->removeListener('hook_civicrm_buildAsset', array($this, 'buildSquareTxt'));
\Civi::dispatcher()->removeListener('hook_civicrm_buildAsset', array($this, 'buildSquareJs'));
parent::tearDown();
}

/**
* @param \Civi\Core\Event\GenericHookEvent $e
* @see \CRM_Utils_Hook::buildAsset()
Expand Down