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

I installed the package by composer,but it couldn't include by composer? #36

Closed
zhushengwen opened this issue Aug 29, 2018 · 4 comments
Closed

Comments

@zhushengwen
Copy link

When debugging into composer,I found the composer.json not including “autoload” config! Is there any wrong?

@mougrim
Copy link
Contributor

mougrim commented Aug 30, 2018

@zhushengwen, could you provide more details, for example, do you use phpunit?
If not how you require vendor/autoload.php.
Also could you provide soft-mocks install-log though composer?

@zhushengwen
Copy link
Author

@mougrim, I use composer to install soft-mocks,and php frameworks is Yii2,then I use the code below.
` public function actionTest()
{
\Badoo\SoftMocks::setRewriteInternal(true);
\Badoo\SoftMocks::redefineFunction(
'strlen',
'$a',
'return \Badoo\SoftMocks::callOriginal("strlen", [trim($a)]));'
);

    echo strlen('  aaa888   ').PHP_EOL;
}`

`PHP Fatal error: Class 'Badoo\SoftMocks' not found in /data/www/projects/yii2/console/controllers/MeController.php on line 121
PHP Stack trace:
PHP 1. {main}() /data/www/projects/yii2/yii:0
PHP 2. yii\base\Application->run() /data/www/projects/yii2/yii:23
PHP 3. yii\console\Application->handleRequest($request = class yii\console\Request { private $_params = array (0 => 'me/test'); private ${yii\base\Request}:_scriptFile = NULL; private ${yii\base\Request}:_isConsoleRequest = NULL; private ${yii\base\Component}:_events = array (); private ${yii\base\Component}:_eventWildcards = array (); private ${yii\base\Component}:_behaviors = NULL }) /data/www/projects/yii2/vendor/yiisoft/yii2/base/Application.php:386
PHP 4. yii\console\Application->runAction($route = 'me/test', $params = array ()) /data/www/projects/yii2/vendor/yiisoft/yii2/console/Application.php:147
PHP 5. yii\base\Module->runAction($route = 'me/test', $params = array ()) /data/www/projects/yii2/vendor/yiisoft/yii2/console/Application.php:180
PHP 6. yii\console\Controller->runAction($id = 'test', $params = array ()) /data/www/projects/yii2/vendor/yiisoft/yii2/base/Module.php:528
PHP 7. yii\base\Controller->runAction($id = 'test', $params = array ()) /data/www/projects/yii2/vendor/yiisoft/yii2/console/Controller.php:148
PHP 8. yii\base\InlineAction->runWithParams($params = array ()) /data/www/projects/yii2/vendor/yiisoft/yii2/base/Controller.php:157
PHP 9. call_user_func_array:{/data/www/projects/yii2/vendor/yiisoft/yii2/base/InlineAction.php:57}(array (0 => class console\controllers\MeController { private $cloudSetting = NULL; public $interactive = TRUE; public $color = NULL; public $help = NULL; private ${yii\console\Controller}:_passedOptions = array (...); private ${yii\console\Controller}:_reflections = array (...); public $id = 'me'; public $module = class yii\console\Application { ... }; public $defaultAction = 'index'; public $layout = NULL; public $action = class yii\base\InlineAction { ... }; private ${yii\base\Controller}:_view = NULL; private ${yii\base\Controller}:_viewPath = NULL; private ${yii\base\Component}:_events = array (...); private ${yii\base\Component}:_eventWildcards = array (...); private ${yii\base\Component}:_behaviors = array (...) }, 1 => 'actionTest'), array ()) /data/www/projects/yii2/vendor/yiisoft/yii2/base/InlineAction.php:57
PHP 10. console\controllers\MeController->actionTest() /data/www/projects/yii2/vendor/yiisoft/yii2/base/InlineAction.php:57
PHP Fatal Error 'yii\base\ErrorException' with message 'Class 'Badoo\SoftMocks' not found'

in /data/www/projects/yii2/console/controllers/MeController.php:121

Stack trace:
#0 /data/www/projects/yii2/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/data/www/projects/yii2/vendor/yiisoft/yii2/base/InlineAction.php:57}('array (0 => cla...', 'array ()')
#1 /data/www/projects/yii2/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams('array ()')
#2 /data/www/projects/yii2/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction(''test'', 'array ()')
#3 /data/www/projects/yii2/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction(''test'', 'array ()')
#4 /data/www/projects/yii2/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction(''me/test'', 'array ()')
#5 /data/www/projects/yii2/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction(''me/test'', 'array ()')
#6 /data/www/projects/yii2/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest('class yii\conso...')
#7 /data/www/projects/yii2/yii(23): yii\base\Application->run()
#8 {main}
-bash: echo: write error: No space left on device`

@mougrim
Copy link
Contributor

mougrim commented Aug 31, 2018

@zhushengwen, looks like you run tests not through vendor/bin/phpunit.
So you should modify your run script, you can details in Usage in readme:

The thing that sets SoftMocks apart (and also limits their usage) is that they need to be initiated at the earliest phase of the app launch.

@mougrim
Copy link
Contributor

mougrim commented Nov 14, 2018

Close, because there is no answer for long time.

@mougrim mougrim closed this as completed Nov 14, 2018
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

No branches or pull requests

2 participants