So, I've run into this issue, and it's a really annoying one. I'm not 100% sure on this, but I believe this is the cause.
Whenever Codeception (or PHPUnit) runs a test using the Laravel 4 module, it essentially boots up the framework before each test. However, all of Laravel's classes are only autoloaded once. This is normally perfectly fine, except in the case of Eloquent's boot methods. Why?
Take a look at the source code for an Eloquent model:
protected static $booted = array();
/* snip */
protected function bootIfNotBooted()
{
if ( ! isset(static::$booted[get_class($this)]))
{
static::$booted[get_class($this)] = true;
$this->fireModelEvent('booting', false);
static::boot();
$this->fireModelEvent('booted', false);
}
}
The Eloquent model sets the $booted[classname] static property to true whenever it calls the boot method. But since the class is already loaded, the next time the framework is loaded, Eloquent still thinks the model is booted because the static property is already set.
This is why the tests run fine individually, but not when run collectively. When test #2 runs, Laravel still thinks Eloquent is booted, even though (since the framework still gets re-initialized every time) you still need to run the code in the boot method.