TestEventListener example

/* Some pseudo events */
    private const preFoo = 'pre.foo';
    private const postFoo = 'post.foo';
    private const preBar = 'pre.bar';

    private EventDispatcher $dispatcher;
    private TestEventListener $listener;

    protected function setUp(): void
    {
        $this->dispatcher = $this->createEventDispatcher();
        $this->listener = new TestEventListener();
    }

    protected function createEventDispatcher()
    {
        return new EventDispatcher();
    }

    public function testInitialState()
    {
        $this->assertEquals([]$this->dispatcher->getListeners());
        $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
        
/** * @var \Symfony\Component\EventDispatcher\EventDispatcher */
  private $dispatcher;
  private $listener;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    $this->dispatcher = $this->createEventDispatcher();
    $this->listener = new TestEventListener();
  }

  /** * {@inheritdoc} */
  protected function tearDown(): void {
    $this->dispatcher = NULL;
    $this->listener = NULL;
  }

  protected function createEventDispatcher() {
    
Home | Imprint | This part of the site doesn't use cookies.