How to run php unit tests in Yii 1.1 - php

Please help. I've been at this for days.
PHPUnit version: 4.4.0
Whenever I try to run a unit test, I get this error:
PHP Fatal error: Uncaught exception 'CException' with message 'CHttpRequest is unable to determine the request URI.' in /var/www/framework/web/CHttpRequest.php:519
My bootstrap file:
// change the following paths if necessary
set_include_path(get_include_path() . PATH_SEPARATOR . '/var/www/protected/config/vendor/phpunit/phpunit-selenium');
$yiit=dirname(__FILE__).'/../../framework/yiit.php';
$config=dirname(__FILE__).'/../config/test.php';
require_once($yiit);
require_once(dirname(__FILE__).'/WebTestCase.php');
Yii::createWebApplication($config);
The error Stack trace:
#0 /vagrant/black-box/framework/web/CHttpRequest.php(431): CHttpRequest->getRequestUri()
#1 /vagrant/black-box/framework/web/CUrlManager.php(364): CHttpRequest->getPathInfo()
#2 /vagrant/black-box/protected/extensions/yii-debug-toolbar/YiiDebugToolbarRoute.php(113): CUrlManager->parseUrl(Object(CHttpRequest))
#3 /vagrant/black-box/framework/logging/CLogRouter.php(66): YiiDebugToolbarRoute->init()
#4 /vagrant/black-box/framework/base/CModule.php(387): CLogRouter->init()
#5 /vagrant/black-box/framework/base/CModule.php(523): CModule->getComponent('log')
#6 /vagrant/black-box/framework/base/CApplication.php(164): CModule->preloadComponents()
#7 /vagrant/black-box/framework/YiiBase.php(125): CApplication->__construct('/vagrant/black-...')
#8 /vagrant/black-box/framework/YiiBase.php(98): YiiBase::createApplication('CWebApplication', '/vagrant/blac in /vagrant/black-box/framework/web/CHttpRequest.php on line 519

Looks like you have configured the YiiDebugToolbarRoute in your configuration.
This is only useful in web environment and causes problems here.
Remove the configuration for logging from your application config in test ENV.

Related

[PHP/Symfony2][Tests] Functional test issue with PHPUnit

I try to make some tests for my project but I have issue.
When I launch Unit tests with PHPUnit it's works perfectly but when I try to do functional tests (with extends WebTestCase), there is an error.
I run phpunit -c app/ src/path/to/my/fileTest.php:
PHP Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'src/Eat/MainBundle/Tests/Controller/PaiementControllerTest' could not be found in '/Applications/MAMP/htdocs/PopLink/Symfony/src/Eat/MainBundle/Tests/Controller/PaiementControllerTest.php'. in phar:///usr/local/bin/phpunit/phpunit/Runner/StandardTestSuiteLoader.php:101
Stack trace:
#0 phar:///usr/local/bin/phpunit/phpunit/Runner/BaseTestRunner.php(130): PHPUnit\Runner\StandardTestSuiteLoader->load('src/Eat/MainBun...', '/Applications/M...')
#1 phar:///usr/local/bin/phpunit/phpunit/Runner/BaseTestRunner.php(73): PHPUnit\Runner\BaseTestRunner->loadSuiteClass('src/Eat/MainBun...', '/Applications/M...')
#2 phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php(162): PHPUnit\Runner\BaseTestRunner->getTest('src/Eat/MainBun...', '/Applications/M...', Array)
#3 phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php(141): PHPUnit\TextUI\Command->run(Array, true)
#4 /usr/local/bin/phpunit(546): PHPUnit\TextUI\Command::main()
#5 {main}
thrown in phar:///usr/local/bin/phpunit/phpunit/Runner/StandardTestSuiteLoader.php on line 101
I have read some topics about this error but I still don't understand.
Can you help me ?
Thanks.

CakePHP and Memcached error - php5.6

I'm trying to migrate our company application from php 5.3 to php 5.6. This app uses cakephp 2.4.3 and memcached, but when I try to execute ./cake bake command, the next error comes up:
Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured.' in /cluster/data/deploy/clickdelivery/current/lib/Cake/Cache/Cache.php:181
Stack trace:
#0 /cluster/data/deploy/clickdelivery/current/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_')
#1 /cluster/data/deploy/clickdelivery/current/app/Config/core.php(381): Cache::config('_cake_core_', Array)
#2 /cluster/data/deploy/clickdelivery/current/lib/Cake/Core/Configure.php(72): include('/cluster/data/d...')
#3 /cluster/data/deploy/clickdelivery/current/lib/Cake/bootstrap.php(177): Configure::bootstrap(true)
#4 /cluster/data/deploy/clickdelivery/current/lib/Cake/Console/ShellDispatcher.php(136): require('/cluster/data/d...')
#5 /cluster/data/deploy/clickdelivery/current/lib/Cake/Console/ShellDispatcher.php(98): ShellDispatcher->_bootstrap()
#6 /cluster/data/deploy/clickdelivery/current/lib/Cake/Console/ShellDispatcher.php(54): ShellDispatcher->_initEnvironment()
#7 /cluster/data/deploy/clickdelivery/cu in /cluster/data/deploy/clickdelivery/current/lib/Cake/Cache/Cache.php on line 181
Persistent and models directory are created with +W.
Thanks in advance.

Developing PHPUnit: how to run its tests

I want to play around with changing PHPUnit's source, but first I'd like to be able to run its tests to make sure I don't break anything.
I used git to get version 4.7.7 out into a directory. In that directory, I then ran composer install.
Then I cd into tests and run:
phpunit --bootstrap ./bootstrap.php ./
(The version of PHPUnit I'm using to run the tests is also 4.7.7.)
but I get this:
PHP Fatal error: Uncaught exception 'Exception' with message 'PHPUnit suppresses exceptions thrown outside of test case function' in C:\Users\jodes\Documents\NetBeansProjects\PHPUnit\phpunit\tests\Regression\GitHub\873\Issue873Test.php:7
Stack trace:
#0 phar://C:/phpbin/phpunit.phar/phpunit/Util/Fileloader.php(52): include_once()
#1 phar://C:/phpbin/phpunit.phar/phpunit/Util/Fileloader.php(36): PHPUnit_Util_Fileloader::load('C:\Users\jody\D...')
#2 phar://C:/phpbin/phpunit.phar/phpunit/Framework/TestSuite.php(334): PHPUnit_Util_Fileloader::checkAndLoad('C:\Users\jody\D...')
#3 phar://C:/phpbin/phpunit.phar/phpunit/Framework/TestSuite.php(406): PHPUnit_Framework_TestSuite->addTestFile('C:\Users\jody\D...')
#4 phar://C:/phpbin/phpunit.phar/phpunit/Runner/BaseTestRunner.php(57): PHPUnit_Framework_TestSuite->addTestFiles(Array)
#5 phar://C:/phpbin/phpunit.phar/phpunit/TextUI/Command.php(121): PHPUnit_Runner_BaseTestRunner->getTest('.\tests\', '', Array)
#6 phar://C:/phpbin/phpunit.phar/phpunit/TextUI/Command.php(99): PHPUnit_TextU in C:\Users\jody\Documents\NetBeansProjects\PHPUnit\phpunit\tests\Regression\GitHub\873\Issue873Test.php on line 7
Fatal error: Uncaught exception 'Exception' with message 'PHPUnit suppresses exceptions thrown outside of test case function' in C:\Users\jodes\Documents\NetBeansProjects\PHPUnit\phpunit\tests\Regression\GitHub\873\Issue873Test.php:7
Stack trace:
#0 phar://C:/phpbin/phpunit.phar/phpunit/Util/Fileloader.php(52): include_once()
#1 phar://C:/phpbin/phpunit.phar/phpunit/Util/Fileloader.php(36): PHPUnit_Util_Fileloader::load('C:\Users\jody\D...')
#2 phar://C:/phpbin/phpunit.phar/phpunit/Framework/TestSuite.php(334): PHPUnit_Util_Fileloader::checkAndLoad('C:\Users\jody\D...')
#3 phar://C:/phpbin/phpunit.phar/phpunit/Framework/TestSuite.php(406): PHPUnit_Framework_TestSuite->addTestFile('C:\Users\jody\D...')
#4 phar://C:/phpbin/phpunit.phar/phpunit/Runner/BaseTestRunner.php(57): PHPUnit_Framework_TestSuite->addTestFiles(Array)
#5 phar://C:/phpbin/phpunit.phar/phpunit/TextUI/Command.php(121): PHPUnit_Runner_BaseTestRunner->getTest('.\tests\', '', Array)
#6 phar://C:/phpbin/phpunit.phar/phpunit/TextUI/Command.php(99): PHPUnit_TextU in C:\Users\jody\Documents\NetBeansProjects\PHPUnit\phpunit\tests\Regression\GitHub\873\Issue873Test.php on line 7
What am I doing wrong? Thanks
If your class "Success" have a namespace, you better use your autoloader with phpunit's --bootstrap parameter
if this situation is related with autoloading, you maybe want to read http://jes.st/2011/phpunit-bootstrap-and-autoloading-classes/ (an old one, but a clear one)

Configure boostrap file for PHPUnit in Yii

If I'm using this YiiPimple for dependency injection, then how to configure bootstrap file for phpunit?
Below given bootstrap file content:
$yiit=dirname(__FILE__).'/../../../../../yii-assets/framework/yiit.php';
$config=dirname(__FILE__).'/../config/test.php';
require_once($yiit);
require_once(dirname(__FILE__).'/WebTestCase.php');
require_once(dirname(__FILE__).'/../../../components/WebApplication.php');
Yii::createApplication('WebApplication', $config)->run();
But when I run this phpunit following error occurs:
Fatal error: Uncaught exception 'CHttpException' with message 'Unable to resolve
the request "site".' in D:\xampp\htdocs\yii-assets\framework\web\CWebApplicatio
n.php:286
Stack trace:
#0 D:\xampp\htdocs\yii-assets\framework\web\CWebApplication.php(141): CWebApplic
ation->runController('')
#1 D:\xampp\htdocs\yii-assets\framework\base\CApplication.php(180): CWebApplicat
ion->processRequest()
#2 D:\xampp\htdocs\AdlugeCore\protected\modules\lead\tests\bootstrap.php(11): CA
pplication->run()
#3 D:\xampp\php\pear\PHPUnit\Util\Fileloader.php(92): include_once('D:\xampp\htd
ocs...')
#4 D:\xampp\php\pear\PHPUnit\Util\Fileloader.php(76): PHPUnit_Util_Fileloader::l
oad('D:\xampp\htdocs...')
#5 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(778): PHPUnit_Util_Fileloader::c
heckAndLoad('D:\xampp\htdocs...')
#6 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(606): PHPUnit_TextUI_Command->ha
ndleBootstrap('D:\xampp\htdocs...')
#7 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(138): PHPUnit_TextUI_Command->ha
ndleArguments(Array)
#8 D:\xampp\php\pear\PH in D:\xampp\htdocs\yii-assets\framework\web\CWebApplicat
ion.php on line 286
You shouldn't run the application in the phpunit bootstrap file.
Try changing
Yii::createApplication('WebApplication', $config)->run();
To
Yii::createApplication('WebApplication', $config);

Unable to write cache folder for smarty project on pagodabox

I have created project in smarty and now i am trying to host it on pagodabox.com. I have created application on pagodabox.com and uploaded all code on to this application but problem is this now i am unable to configure cache and compiler directory in pagodabox.com that's why it output fetal error because cache and compiler directory is read only mode. I have try Boxfile to resolve this issue but failing to solve. I am not aware how i can make these directory writable. please help me. this is url of project http://moviestock.pagodabox.com/ and following is my Boxfile configuration
web1: #component type & number
name: blog #component settings
shared_writable_dirs:
- var/secured/cache
- var/secured/compiler
- var/sessions
document_root: app
php_version: 5.3.8
and i am getting this following error :
Fatal error: Uncaught exception 'SmartyException' with message 'unable to write file
shared/secured/compiler/wrt50c17dfaca2932.90478039' in
/var/www/libs/sysplugins/smarty_internal_write_file.php:44 Stack trace: #0
/var/www/libs/sysplugins/smarty_internal_template.php(201):
Smarty_Internal_Write_File::writeFile('shared/secured/...', 'compileTemplateSource() #2
/var/www/libs/sysplugins/smarty_internal_templatebase.php(374):
Smarty_Internal_TemplateBase->fetch('extends:layout....', '6666cd76f969564...', NULL,
NULL, true) #3 /var/www/classes/BaseController.php(22): Smarty_Internal_TemplateBase-
>display('extends:layout....', '6666cd76f969564...') #4
/var/www/secured/controllers/HomeController.php(6): BaseController->render('home') #5
[internal function]: HomeController->indexAction('') #6
/var/www/classes/Router.php(26): call_user_func_array(Array, Array) #7
/var/www/index.php(10): Router::run() #8 in
/var/www/libs/sysplugins/smarty_internal_write_file.php on line 44
I think it has to do with the filepath that smarty is trying to write to. In the error, the filepath is shared/secured/compiler/wrt50c17dfaca2932.90478039. It should be var/secured/compiler/wrt50c17dfaca2932.90478039
Not sure but maybe #chmod(PATH,0770); will make a trick?

Categories