68 lines
3.3 KiB
PHP
Executable File
68 lines
3.3 KiB
PHP
Executable File
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\EventDispatcher\Tests;
|
|
|
|
use Symfony\Component\EventDispatcher\Event;
|
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
|
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
|
|
use Symfony\Contracts\EventDispatcher\Event as ContractsEvent;
|
|
|
|
/**
|
|
* @group legacy
|
|
*/
|
|
class LegacyEventDispatcherProxyTest extends EventDispatcherTest
|
|
{
|
|
/**
|
|
* @group legacy
|
|
* @expectedDeprecation The signature of the "Symfony\Component\EventDispatcher\Tests\TestLegacyEventDispatcher::dispatch()" method should be updated to "dispatch($event, string $eventName = null)", not doing so is deprecated since Symfony 4.3.
|
|
* @expectedDeprecation Calling the "Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.
|
|
*/
|
|
public function testLegacySignatureWithoutEvent()
|
|
{
|
|
$this->createEventDispatcher()->dispatch('foo');
|
|
}
|
|
|
|
/**
|
|
* @group legacy
|
|
* @expectedDeprecation The signature of the "Symfony\Component\EventDispatcher\Tests\TestLegacyEventDispatcher::dispatch()" method should be updated to "dispatch($event, string $eventName = null)", not doing so is deprecated since Symfony 4.3.
|
|
* @expectedDeprecation Calling the "Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.
|
|
*/
|
|
public function testLegacySignatureWithEvent()
|
|
{
|
|
$this->createEventDispatcher()->dispatch('foo', new Event());
|
|
}
|
|
|
|
/**
|
|
* @group legacy
|
|
* @expectedDeprecation The signature of the "Symfony\Component\EventDispatcher\Tests\TestLegacyEventDispatcher::dispatch()" method should be updated to "dispatch($event, string $eventName = null)", not doing so is deprecated since Symfony 4.3.
|
|
* @expectedDeprecation The signature of the "Symfony\Component\EventDispatcher\Tests\TestLegacyEventDispatcher::dispatch()" method should be updated to "dispatch($event, string $eventName = null)", not doing so is deprecated since Symfony 4.3.
|
|
* @expectedDeprecation Calling the "Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.
|
|
*/
|
|
public function testLegacySignatureWithNewEventObject()
|
|
{
|
|
$this->createEventDispatcher()->dispatch('foo', new ContractsEvent());
|
|
}
|
|
|
|
protected function createEventDispatcher()
|
|
{
|
|
return LegacyEventDispatcherProxy::decorate(new TestLegacyEventDispatcher());
|
|
}
|
|
}
|
|
|
|
class TestLegacyEventDispatcher extends EventDispatcher
|
|
{
|
|
public function dispatch($eventName, Event $event = null): Event
|
|
{
|
|
return parent::dispatch($event, $eventName);
|
|
}
|
|
}
|