Exemplo n.º 1
0
 public function setUp()
 {
     $this->connection = DB::getConnection('testdb');
     $this->driver = $this->connection->getDriver();
     // Clean up events before every test
     $this->triggeredEvents = array();
     $this->triggeredArguments = array();
     $that = $this;
     foreach ($this->queryEvents as $event) {
         Event::removeListeners($event);
         Event::on($event, function () use($event, $that) {
             $that->triggeredEvents[] = $event;
             $that->triggeredArguments[] = func_get_args();
         });
     }
 }
Exemplo n.º 2
0
 public function testAddRemove()
 {
     Event::removeListeners();
     $id1 = uniqid("", true);
     $id2 = uniqid("", true);
     $listener = function () {
     };
     Event::on($id1, $listener);
     Event::on($id2, $listener);
     $listeners1 = Event::listeners($id1);
     $listeners2 = Event::listeners($id2);
     $this->assertEquals($listeners1, $listeners2);
     $this->assertCount(1, $listeners1);
     $this->assertCount(1, $listeners2);
     Event::removeListener($id1, $listener);
     $listeners1 = Event::listeners($id1);
     $listeners2 = Event::listeners($id2);
     $this->assertCount(0, $listeners1);
     $this->assertCount(1, $listeners2);
     Event::removeListener($id2, $listener);
     $listeners1 = Event::listeners($id1);
     $listeners2 = Event::listeners($id2);
     $this->assertCount(0, $listeners1);
     $this->assertCount(0, $listeners2);
     Event::on($id1, $listener);
     Event::on($id2, $listener);
     $listeners1 = Event::listeners($id1);
     $listeners2 = Event::listeners($id2);
     $this->assertEquals($listeners1, $listeners2);
     $this->assertCount(1, $listeners1);
     $this->assertCount(1, $listeners2);
     Event::removeListeners();
     $listeners1 = Event::listeners($id1);
     $listeners2 = Event::listeners($id2);
     $this->assertCount(0, $listeners1);
     $this->assertCount(0, $listeners2);
 }