Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setupFunctions() method to Mocker. #871

Closed
wants to merge 1 commit into from
Closed

Add setupFunctions() method to Mocker. #871

wants to merge 1 commit into from

Conversation

bayleedev
Copy link
Member

This allows you to declare which methods you are going to define later on. This, for instance, may be helpful if something like apc is caching the full namespace of a method. The first time you call a global function, it might be cached, so stubbing it would not work.

This allows you to declare which methods you are going to define later on. This, for instance, may be helpful if something like apc is caching the full namespace of a method. The first time you call a global function, it might be cached, so stubbing it would not work.
@bayleedev
Copy link
Member Author

Looks like it failed hitting google.com in two of the sets in the matrix. These are integration tests, but I still feel we should be stubbing external requests. Imo death to _hasNetwork().

@nateabele
Copy link
Member

Sounds like a good opportunity to eat your own setupFunctions() dog food. ;-)

@jails
Copy link
Contributor

jails commented Mar 29, 2013

Yeah Google seems to fail answering pretty often...

@jails
Copy link
Contributor

jails commented Apr 18, 2013

Ok after some experiments looks like there's no other way to make things works w/o a executing a setup at a bootstrap level.

Maybe we can complete this PR with a kind of :

if (!Environment::is('production')) {
    Mocker::setupFunctions(array(
        'lithium\util\getmxrr',
        'lithium\console\command\shell_exec',
        'lithium\console\command\is_dir',
        'lithium\net\socket\feof',
        'lithium\net\socket\fopen',
        'lithium\net\socket\stream_socket_client',
        'lithium\net\socket\stream_get_contents',
        'lithium\net\socket\stream_context_create',
        'lithium\net\socket\stream_get_meta_data',
        'lithium\tests\cases\net\socket\stream_context_get_options',
        'lithium\net\socket\curl_init',
        'lithium\net\socket\curl_setopt',
        'lithium\net\socket\curl_close',
        'lithium\net\socket\curl_exec'
    );
}

in a config/boostrap.php in the lithium repo.

I know Environment is not accessible at this stage, but I hope we can refactor the framework on day to set the environnment earlier.

Did you find other solutions ?

@jails
Copy link
Contributor

jails commented Apr 20, 2013

Vote up on the bug guys: https://bugs.php.net/bug.php?id=63201, with any luck it'll be solved in the next decade ;-)

@bayleedev bayleedev closed this Jun 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants