예제 #1
0
 /**
  * @test
  */
 public function clear_disposes_all_contained_disposables_but_not_the_composite_disposable()
 {
     $disposed1 = false;
     $disposed2 = false;
     $d1 = new CallbackDisposable(function () use(&$disposed1) {
         $disposed1 = true;
     });
     $d2 = new CallbackDisposable(function () use(&$disposed2) {
         $disposed2 = true;
     });
     $disposable = new CompositeDisposable(array($d1, $d2));
     $disposable->clear();
     $this->assertTrue($disposed1);
     $this->assertTrue($disposed2);
     $disposed3 = false;
     $d3 = new CallbackDisposable(function () use(&$disposed3) {
         $disposed3 = true;
     });
     $disposable->add($d3);
     $this->assertFalse($disposed3);
 }