PHPUnit错误未定义变量

I'm running PHPunit to test my ZF2 application. I tried it on my Windows machine (under xampp), and it worked fine. But when I moved it to a virtual Ubuntu 14.10 server, I keep getting the following error with every test:

Undefined variable: services

I went to /etc/php5/cli/php.ini and set error reporting as follows:

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE

The code the tests are pointing to is from one of my Module.php files

public function onBootstrap(MvcEvent $event)
{
    $sharedEventManager =  $event->getApplication()
        ->getEventManager()
        ->getSharedManager();

    $sharedEventManager->attach('user', 'log-fail', function($event) use ($services) {
        $username = $event->getParam('username');


        $log = $services->get('log');
        $log->warn("Error logging user [$username]");
    });
}

It's specifically complaining about the line $sharedEventManager->attach('user', 'log-fail', function($event) use ($services). Like I said, I tried editing the php.ini files to suppress warnings like this, but it isn't working. Is there something else I'm missing?

OK, I figured it out. It was just as Indrasinh Bihola said: I'd left a part out. Well, the book did. The snippet I borrowed is from an earlier section, but it skips crucial parts, and gives no indication of where the original part is (37 pages back!). Also, not to make excuses, but I've never used closures in PHP and I had no idea what use($services) actually did. Now I do. I won't make the same mistake again.