I have an Order model which has the following event which updates the reference column when the order has been created.
protected static function boot()
{
    parent::boot();
    static::created(function ($order) {
        $order->reference = 'X'.Hashids::encode($order->id);
        $order->save();
    });
}
I now want to right a unit test for this. But how? I need to assert the reference is null straight after creating then assert it is not null after the event.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire