Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

I cant use unit-test, "Cannot bind an instance to a static closure" happens.

I would like to unit-test some of my codes. Im using the newest Phpunit. My phpunit.xml:

<?php<phpunit  bootstrap="../bootstrap.php" backupGlobals="false" backupStaticAttributes="false" verbose="true" colors="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" syntaxCheck="true">
    <testsuite name="sdf">

that bootstrap.php:

\Phalcon\Di::setDefault(new \Phalcon\DI\FactoryDefault());

\Phalcon\Di::getDefault()->setShared('t', function() {

and now if I would like to use this from a static method:


it dies:

Cannot bind an instance to a static closure

what it can be?

its Php 5.6.16 and Phalcon 2.1.0b

edited Mar '16

Try to work around this documentation

I am using unit tests with phalcon with my own UnitTestCase, which supports internal DI object. You can completely omit DI section in your bootstrap and use only DI object from UnitTestCase, set it as default and dynamicaly register services which are needed for particular unit test.


yea, right, I didnt see the documentation havin unit-test chapter. I was using it as the old fashion way.