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

Problem with Code Coverage Reporting #13

Closed
kenjis opened this issue Mar 10, 2016 · 1 comment
Closed

Problem with Code Coverage Reporting #13

kenjis opened this issue Mar 10, 2016 · 1 comment

Comments

@kenjis
Copy link
Member

kenjis commented Mar 10, 2016

Now I can't generate code coverage report.

[vagrant@localhost project]$ phpunit --colors --coverage-text=coverage.txt --coverage-html=coverage
PHPUnit 5.0.10 by Sebastian Bergmann and contributors.

...............................................................  63 / 272 ( 23%)
............................................................... 126 / 272 ( 46%)
............................................................... 189 / 272 ( 69%)
............................................................... 252 / 272 ( 92%)
....................                                            272 / 272 (100%)

Time: 15.86 seconds, Memory: 14.00Mb

OK (272 tests, 514 assertions)

Generating code coverage report in HTML format ...PHP Fatal error:  Cannot declare class CodeIgniter\PageNotFoundException, because the name is already in use in /mnt/project/system/Debug/CustomExceptions.php on line 49
PHP Stack trace:
PHP   1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
PHP   3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:105
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:154
PHP   5. PHP_CodeCoverage_Report_HTML->process() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:486
PHP   6. PHP_CodeCoverage->getReport() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php:68
PHP   7. PHP_CodeCoverage_Report_Factory->create() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:144
PHP   8. PHP_CodeCoverage->getData() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php:24
PHP   9. PHP_CodeCoverage->addUncoveredFilesFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:178
PHP  10. PHP_CodeCoverage->processUncoveredFileFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:680
PHP  11. include_once() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:707

Fatal error: Cannot declare class CodeIgniter\PageNotFoundException, because the name is already in use in /mnt/project/system/Debug/CustomExceptions.php on line 49

Call Stack:
    0.0041     355592   1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
    0.0349    1003128   2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
    0.0349    1003240   3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:105
    0.7600    4106488   4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:154
   15.8625   10192872   5. PHP_CodeCoverage_Report_HTML->process() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:486
   15.8630   10192928   6. PHP_CodeCoverage->getReport() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php:68
   15.8650   10213464   7. PHP_CodeCoverage_Report_Factory->create() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:144
   15.8651   10213464   8. PHP_CodeCoverage->getData() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php:24
   15.8651   10213464   9. PHP_CodeCoverage->addUncoveredFilesFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:178
   15.9923   10478424  10. PHP_CodeCoverage->processUncoveredFileFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:680
   15.9972   10538168  11. include_once('/mnt/project/system/Debug/Exceptions.php') /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:707

This is because of the following require:

--- a/system/Debug/Exceptions.php
+++ b/system/Debug/Exceptions.php
@@ -35,7 +35,7 @@
  * @filesource
  */

-require dirname(__FILE__).'/CustomExceptions.php';
+require_once dirname(__FILE__).'/CustomExceptions.php';

 class Exceptions
 {

The above patch fixes the error but then it seems it shows debug bar and raise another error:

PHP Fatal error:  Uncaught Error: Call to undefined method PHP_CodeCoverage::renderTimeline() in /mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php:38
Stack trace:
#0 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(707): include_once()
#1 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(680): PHP_CodeCoverage->processUncoveredFileFromWhitelist('/mnt/project/sy...', Array, Array)
#2 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(178): PHP_CodeCoverage->addUncoveredFilesFromWhitelist()
#3 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php(24): PHP_CodeCoverage->getData()
#4 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(144): PHP_CodeCoverage_Report_Factory->create(Object(PHP_CodeCoverage))
#5 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php(68): PHP_CodeCoverage->getReport()
#6 /home/vagrant/.composer/vendor/phpunit/phpunit in /mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php on line 38

Fatal error: Uncaught Error: Call to undefined method PHP_CodeCoverage::renderTimeline() in /mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php on line 38

Error: Call to undefined method PHP_CodeCoverage::renderTimeline() in /mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php on line 38

Call Stack:
    0.0059     355592   1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
    0.0361    1003128   2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
    0.0361    1003240   3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:105
    0.5748    4106488   4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:154
   15.0706   10192872   5. PHP_CodeCoverage_Report_HTML->process() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:486
   15.0711   10192928   6. PHP_CodeCoverage->getReport() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php:68
   15.0756   10213464   7. PHP_CodeCoverage_Report_Factory->create() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:144
   15.0757   10213464   8. PHP_CodeCoverage->getData() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php:24
   15.0757   10213464   9. PHP_CodeCoverage->addUncoveredFilesFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:178
   15.3139   10653368  10. PHP_CodeCoverage->processUncoveredFileFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:680
   15.3232   10683384  11. include_once('/mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php') /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:707
@kenjis
Copy link
Member Author

kenjis commented Mar 10, 2016

I was able to generate report. See #14

Code Coverage Report:        
  2016-03-10 16:45:43        

 Summary:                    
  Classes: 40.62% (26/64)    
  Methods: 39.49% (154/390)  
  Lines:   47.98% (1246/2597)

@exbit exbit mentioned this issue Mar 16, 2016
Sosko added a commit to Sosko/CodeIgniter4 that referenced this issue Sep 24, 2020
If thy table haven't primary key, and i pass $returnID = false, than the ci4 throw this error:
```
CRITICAL - 2020-09-24 00:47:00 --> pg_query(): Query failed: ERROR:  lastval is not yet defined in this session
#0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'pg_query(): Que...', '/var/www/ci4/sy...', 196, Array)
codeigniter4#1 /var/www/ci4/system/Database/Postgre/Connection.php(196): pg_query(Resource id codeigniter4#9, 'SELECT LASTVAL(...')
codeigniter4#2 /var/www/ci4/system/Database/BaseConnection.php(741): CodeIgniter\Database\Postgre\Connection->execute('SELECT LASTVAL(...')
codeigniter4#3 /var/www/ci4/system/Database/BaseConnection.php(669): CodeIgniter\Database\BaseConnection->simpleQuery('SELECT LASTVAL(...')
codeigniter4#4 /var/www/ci4/system/Database/Postgre/Connection.php(519): CodeIgniter\Database\BaseConnection->query('SELECT LASTVAL(...')
codeigniter4#5 /var/www/ci4/system/Model.php(887): CodeIgniter\Database\Postgre\Connection->insertID()
codeigniter4#6 /var/www/ci4/app/Models/MyModel.php(46): CodeIgniter\Model->insert(Array, false)
codeigniter4#7 /var/www/ci4/app/Controllers/MyController.php(113): App\Models\MyModel->new_connection('1', '1')
codeigniter4#8 /var/www/ci4/app/Controllers/MyController.php(54): App\Controllers\MyController->do_create_connection()
codeigniter4#9 /var/www/ci4/system/CodeIgniter.php(918): App\Controllers\MyController->create_connection()
codeigniter4#10 /var/www/ci4/system/CodeIgniter.php(404): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\MyController))
codeigniter4#11 /var/www/ci4/system/CodeIgniter.php(312): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
codeigniter4#12 /var/www/ci4/public/index.php(45): CodeIgniter\CodeIgniter->run()
codeigniter4#13 {main}
CRITICAL - 2020-09-24 00:47:00 --> Uncaught CodeIgniter\Format\Exceptions\FormatException: Failed to parse json string, error: "Type is not supported". in /var/www/ci4/system/Format/Exceptions/FormatException.php:9
Stack trace:
#0 /var/www/ci4/system/Format/JSONFormatter.php(71): CodeIgniter\Format\Exceptions\FormatException::forInvalidJSON('Type is not sup...')
codeigniter4#1 /var/www/ci4/system/API/ResponseTrait.php(414): CodeIgniter\Format\JSONFormatter->format(Array)
codeigniter4#2 /var/www/ci4/system/API/ResponseTrait.php(134): CodeIgniter\Debug\Exceptions->format(Array)
codeigniter4#3 /var/www/ci4/system/Debug/Exceptions.php(168): CodeIgniter\Debug\Exceptions->respond(Array, 500)
codeigniter4#4 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException))
codeigniter4#5 {main}
  thrown
#0 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
codeigniter4#1 {main}
```
This will skip to getting inserted ID
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