/**
  * Test JEventDispatcher::detach().
  *
  * @since 11.3
  *
  * @return void
  */
 public function testDetach()
 {
     // Adding 3 events to detach later
     $observer1 = array('handler' => 'fakefunction', 'event' => 'onTestEvent');
     $observer2 = array('handler' => 'JEventMockFunction', 'event' => 'onTestEvent');
     $this->object->attach($observer2);
     $observer3 = new JEventInspector($this->object);
     $this->object->attach($observer3);
     // Test removing a non-existing observer
     $this->assertThat(TestReflection::getValue($this->object, '_methods'), $this->equalTo(array('ontestevent' => array(0, 1))));
     $this->assertThat(TestReflection::getValue($this->object, '_observers'), $this->equalTo(array($observer2, $observer3)));
     $return = $this->object->detach($observer1);
     $this->assertFalse($return);
     $this->assertThat(TestReflection::getValue($this->object, '_methods'), $this->equalTo(array('ontestevent' => array(0, 1))));
     $this->assertThat(TestReflection::getValue($this->object, '_observers'), $this->equalTo(array($observer2, $observer3)));
     // Test removing a functional observer
     $return = $this->object->detach($observer2);
     $this->assertTrue($return);
     $this->assertThat(TestReflection::getValue($this->object, '_methods'), $this->equalTo(array('ontestevent' => array(1 => 1))));
     $this->assertThat(TestReflection::getValue($this->object, '_observers'), $this->equalTo(array(1 => $observer3)));
     // Test removing an object observer with more than one event
     $return = $this->object->detach($observer3);
     $this->assertTrue($return);
     $this->assertThat(TestReflection::getValue($this->object, '_methods'), $this->equalTo(array('ontestevent' => array())));
     $this->assertThat(TestReflection::getValue($this->object, '_observers'), $this->equalTo(array()));
 }