Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuelphp testing the after_load observer in Model
  • Hi guys, it seems that when loading a row from the database via the orm in a phpunit test, the model will not call the appropriate observers so I am not able to test them! 

    http://stackoverflow.com/questions/15600036/fuelphp-testing-the-after-load-observer-in-model-phpunit

    Any help would be much appreciated!

    EDIT: After reading this thread I think it might have something to do with unit tests not supporting the cascading file system of fuel? No idea if this is correct but it might be a clue..


  • Oh looks like I just fixed it! Nothing to do with cascading file system ha. Turns out I just needed to clear the cache of the model I was using. I did this by adding this method to the model:

    public static function clear_cache()
    {
    $class = get_called_class();
    unset(static::$_cached_objects[$class]);
    }

    and calling this from the phpunit tearDown() method so that the cache is cleared after every test.


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion