TestEventSubscriber example

public function testRemoveListener()
    {
        $this->dispatcher->addListener('pre.bar', $this->listener);
        $this->assertTrue($this->dispatcher->hasListeners(self::preBar));
        $this->dispatcher->removeListener('pre.bar', $this->listener);
        $this->assertFalse($this->dispatcher->hasListeners(self::preBar));
        $this->dispatcher->removeListener('notExists', $this->listener);
    }

    public function testAddSubscriber()
    {
        $eventSubscriber = new TestEventSubscriber();
        $this->dispatcher->addSubscriber($eventSubscriber);
        $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
        $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
    }

    public function testAddSubscriberWithPriorities()
    {
        $eventSubscriber = new TestEventSubscriber();
        $this->dispatcher->addSubscriber($eventSubscriber);

        $eventSubscriber = new TestEventSubscriberWithPriorities();
        


  public function testRemoveListener() {
    $this->dispatcher->addListener('pre.bar', $this->listener);
    $this->assertTrue($this->dispatcher->hasListeners(self::PREBAR));
    $this->dispatcher->removeListener('pre.bar', $this->listener);
    $this->assertFalse($this->dispatcher->hasListeners(self::PREBAR));
    $this->dispatcher->removeListener('notExists', $this->listener);
  }

  public function testAddSubscriber() {
    $eventSubscriber = new TestEventSubscriber();
    $this->dispatcher->addSubscriber($eventSubscriber);
    $this->assertTrue($this->dispatcher->hasListeners(self::PREFOO));
    $this->assertTrue($this->dispatcher->hasListeners(self::POSTFOO));
  }

  public function testAddSubscriberWithPriorities() {
    $eventSubscriber = new TestEventSubscriber();
    $this->dispatcher->addSubscriber($eventSubscriber);

    $eventSubscriber = new TestEventSubscriberWithPriorities();
    $this->dispatcher->addSubscriber($eventSubscriber);

    
Home | Imprint | This part of the site doesn't use cookies.