AspectMock is not working well with Phalcon


I'm trying to mock a simple class that calls a static method with Phalcon and it's not working. I'm using Phalcon 2.0.7.

$client = new \stdClass();
$client->email = '[email protected]';
$client->active = 1;

$mailer = test::double('Mailer', ['send' => null]);
$clientEmails = new \ClientEmails();


When I run the test I got the error:

1) Test\ClientEmailsTestUnitTest::test_sendFirstNotifications
Expected Mailer::send to be invoked but it never occur.

I tried it without PhalconPHP and it worked well, so I think the problem is with the Phalcon Loader. On my TestHelper.php I have:

// Required for phalcon/incubator
include __DIR__ . "/../vendor/autoload.php";

$kernel = \AspectMock\Kernel::getInstance();
    'debug' => true,
    'includePaths' => [__DIR__ . '/../app/']

And on the PhalconLoader.php I have:

$loader = new \Phalcon\Loader();

Here is all the code: