!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/alt/php54/usr/share/pear/test/EventDispatcher/Symfony/Component/EventDispatcher/Tests/   drwxr-xr-x
Free 293.98 GB of 429.69 GB (68.42%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     ContainerAwareEventDispatcherTest.php (7.31 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?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\DependencyInjection\Container;
use 
Symfony\Component\DependencyInjection\Scope;
use 
Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
use 
Symfony\Component\EventDispatcher\Event;
use 
Symfony\Component\EventDispatcher\EventSubscriberInterface;

class 
ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase
{
    public function 
testAddAListenerService()
    {
        
$event = new Event();

        
$service $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');

        
$service
            
->expects($this->once())
            ->
method('onEvent')
            ->
with($event)
        ;

        
$container = new Container();
        
$container->set('service.listener'$service);

        
$dispatcher = new ContainerAwareEventDispatcher($container);
        
$dispatcher->addListenerService('onEvent', array('service.listener''onEvent'));

        
$dispatcher->dispatch('onEvent'$event);
    }

    public function 
testAddASubscriberService()
    {
        
$event = new Event();

        
$service $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService');

        
$service
            
->expects($this->once())
            ->
method('onEvent')
            ->
with($event)
        ;

        
$container = new Container();
        
$container->set('service.subscriber'$service);

        
$dispatcher = new ContainerAwareEventDispatcher($container);
        
$dispatcher->addSubscriberService('service.subscriber''Symfony\Component\EventDispatcher\Tests\SubscriberService');

        
$dispatcher->dispatch('onEvent'$event);
    }

    public function 
testPreventDuplicateListenerService()
    {
        
$event = new Event();

        
$service $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');

        
$service
            
->expects($this->once())
            ->
method('onEvent')
            ->
with($event)
        ;

        
$container = new Container();
        
$container->set('service.listener'$service);

        
$dispatcher = new ContainerAwareEventDispatcher($container);
        
$dispatcher->addListenerService('onEvent', array('service.listener''onEvent'), 5);
        
$dispatcher->addListenerService('onEvent', array('service.listener''onEvent'), 10);

        
$dispatcher->dispatch('onEvent'$event);
    }

    
/**
     * @expectedException \InvalidArgumentException
     */
    
public function testTriggerAListenerServiceOutOfScope()
    {
        
$service $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');

        
$scope = new Scope('scope');
        
$container = new Container();
        
$container->addScope($scope);
        
$container->enterScope('scope');

        
$container->set('service.listener'$service'scope');

        
$dispatcher = new ContainerAwareEventDispatcher($container);
        
$dispatcher->addListenerService('onEvent', array('service.listener''onEvent'));

        
$container->leaveScope('scope');
        
$dispatcher->dispatch('onEvent');
    }

    public function 
testReEnteringAScope()
    {
        
$event = new Event();

        
$service1 $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');

        
$service1
            
->expects($this->exactly(2))
            ->
method('onEvent')
            ->
with($event)
        ;

        
$scope = new Scope('scope');
        
$container = new Container();
        
$container->addScope($scope);
        
$container->enterScope('scope');

        
$container->set('service.listener'$service1'scope');

        
$dispatcher = new ContainerAwareEventDispatcher($container);
        
$dispatcher->addListenerService('onEvent', array('service.listener''onEvent'));
        
$dispatcher->dispatch('onEvent'$event);

        
$service2 $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');

        
$service2
            
->expects($this->once())
            ->
method('onEvent')
            ->
with($event)
        ;

        
$container->enterScope('scope');
        
$container->set('service.listener'$service2'scope');

        
$dispatcher->dispatch('onEvent'$event);

        
$container->leaveScope('scope');

        
$dispatcher->dispatch('onEvent');
    }

    public function 
testHasListenersOnLazyLoad()
    {
        
$event = new Event();

        
$service $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');

        
$container = new Container();
        
$container->set('service.listener'$service);

        
$dispatcher = new ContainerAwareEventDispatcher($container);
        
$dispatcher->addListenerService('onEvent', array('service.listener''onEvent'));

        
$event->setDispatcher($dispatcher);
        
$event->setName('onEvent');

        
$service
            
->expects($this->once())
            ->
method('onEvent')
            ->
with($event)
        ;

        
$this->assertTrue($dispatcher->hasListeners());

        if (
$dispatcher->hasListeners('onEvent')) {
            
$dispatcher->dispatch('onEvent');
        }
    }

    public function 
testGetListenersOnLazyLoad()
    {
        
$service $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');

        
$container = new Container();
        
$container->set('service.listener'$service);

        
$dispatcher = new ContainerAwareEventDispatcher($container);
        
$dispatcher->addListenerService('onEvent', array('service.listener''onEvent'));

        
$listeners $dispatcher->getListeners();

        
$this->assertTrue(isset($listeners['onEvent']));

        
$this->assertCount(1$dispatcher->getListeners('onEvent'));
    }

    public function 
testRemoveAfterDispatch()
    {
        
$service $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');

        
$container = new Container();
        
$container->set('service.listener'$service);

        
$dispatcher = new ContainerAwareEventDispatcher($container);
        
$dispatcher->addListenerService('onEvent', array('service.listener''onEvent'));

        
$dispatcher->dispatch('onEvent', new Event());
        
$dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent'));
        
$this->assertFalse($dispatcher->hasListeners('onEvent'));
    }

    public function 
testRemoveBeforeDispatch()
    {
        
$service $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');

        
$container = new Container();
        
$container->set('service.listener'$service);

        
$dispatcher = new ContainerAwareEventDispatcher($container);
        
$dispatcher->addListenerService('onEvent', array('service.listener''onEvent'));

        
$dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent'));
        
$this->assertFalse($dispatcher->hasListeners('onEvent'));
    }
}

class 
Service
{
    public function 
onEvent(Event $e)
    {
    }
}

class 
SubscriberService implements EventSubscriberInterface
{
    public static function 
getSubscribedEvents()
    {
        return array(
            
'onEvent' => 'onEvent',
            
'onEvent' => array('onEvent'10),
            
'onEvent' => array('onEvent'),
        );
    }

    public function 
onEvent(Event $e)
    {
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.095 ]--