ajout systeme d'evenement

This commit is contained in:
Gregory Letellier
2023-10-27 15:47:08 +02:00
parent 5c09234cf5
commit bc7fa33473
5 changed files with 111 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
<?php
use Kletellier\PdoWrapper\Db;
use Kletellier\PdoWrapper\EventDispatcher;
use Kletellier\PdoWrapper\Model;
use Kletellier\PdoWrapper\QueryBuilder;
@@ -98,3 +99,15 @@ test("update row", function() {
expect(count($rows))->toBe(1);
expect($rows[0]->col1)->toBe("testupdate");
});
test("event", function() {
$ret = null;
EventDispatcher::on("on.query",function($event,$query) use (&$ret) {
$ret = $query;
});
$qb = new QueryBuilder("test");
$qb->find(1);
expect($ret)->toBeObject();
});