You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tests not working with form_validation library #43
When I comment out the line number the error goes away but I can't leave it un commmented .
How can I fix this issue?
Below is my controller code and test code
class Welcome extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library(["form_validation"]);
//$this->load->helper(["html"]);
}
public function testCode(){
return "hi";
}
}
Test code
require_once('CITestCase.php');
class MyTestController extends CITestCase
{
public function testHome()
{
$this->requireController('Welcome');
$CI = new Welcome();
$CI->testCode();
}
}
Does it happen to every helper, or just this form_validation?
It is one thing for the issue to be with this project, and another to be with a helper library...
I've not tried with other helpers. I'm using the testing code as is, downloaded from GitHub. I've not added any test cases of my own. when I run phpunit in my project folder, it fails with this error: ~/workspace/cargo/carrier-suite(develop ✗) phpunit PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
...PHP Fatal error: Call to a member function helper() on a non-object in /Users/cnadig-cc/workspace/cargo/carrier-suite/system/libraries/Form_validation.php on line 147 PHP Stack trace: PHP 1. {main}() /usr/local/bin/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /usr/local/bin/phpunit:545 PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:100 PHP 4. PHPUnit_TextUI_TestRunner->doRun() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:149 PHP 5. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php:440 PHP 6. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:747 PHP 7. PHPUnit_Framework_TestCase->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:747 PHP 8. PHPUnit_Framework_TestResult->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:724 PHP 9. PHPUnit_Framework_TestCase->runBare() phar:///usr/local/bin/phpunit/phpunit/Framework/TestResult.php:612 PHP 10. PHPUnit_Framework_TestCase->runTest() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:768 PHP 11. ReflectionMethod->invokeArgs() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:909 PHP 12. ControllersTest->testLoadController() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:909 PHP 13. CI_Controller->__construct() /Users/cnadig-cc/workspace/cargo/carrier-suite/application/tests/core/ControllersTest.php:33 PHP 14. load_class() /Users/cnadig-cc/workspace/cargo/carrier-suite/system/core/Controller.php:75 PHP 15. CI_Form_validation->__construct() /Users/cnadig-cc/workspace/cargo/carrier-suite/system/core/Common.php:196
@cnadig-cc so, what you're doing is: you downloaded vanilla CI, latest version, then downloaded this project, installed as instructed but you can't run any tests. Is that your sequence?
If it is, I'll try to replicate it and see what I can find. It could be from a new CI version incompatibility I'm not aware of.
Yes. I downloaded vanilla CI (3.0.4), added the test cases as is from GitHub.com, set $autoload['libraries']=array('form_validation') ; , and I get this error.
If I remove 'form_validation' from autoload, it runs fine.
Also, In my actual project, I have other libraries that are autoloaded. But when I run phpunit, I get errors like : PHP Fatal error: Class 'CI_Tracks_Auth' not found in /Library/WebServer/Documents/cargo/testci/system/core/Common.php on line 196
The library class name is "Tracks_Auth". I don't know why it adds the "CI_" prefix and looks for CI_Tracks_Auth
Activity
cnadig-cc commentedon Apr 27, 2016
+1
I'm facing the same problem
eldan88 commentedon Apr 28, 2016
This seems to work well...
https://github.com/kenjis/ci-phpunit-test
cnadig-cc commentedon Apr 29, 2016
@eldan88 I ran into problems using ci-phpunit-test too.
fmalk commentedon Apr 29, 2016
Does it happen to every helper, or just this
form_validation?It is one thing for the issue to be with this project, and another to be with a helper library...
cnadig-cc commentedon Apr 29, 2016
I've not tried with other helpers. I'm using the testing code as is, downloaded from GitHub. I've not added any test cases of my own. when I run phpunit in my project folder, it fails with this error:
~/workspace/cargo/carrier-suite(develop ✗) phpunitPHPUnit 4.8.21 by Sebastian Bergmann and contributors....PHP Fatal error: Call to a member function helper() on a non-object in /Users/cnadig-cc/workspace/cargo/carrier-suite/system/libraries/Form_validation.php on line 147PHP Stack trace:PHP 1. {main}() /usr/local/bin/phpunit:0PHP 2. PHPUnit_TextUI_Command::main() /usr/local/bin/phpunit:545PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:100PHP 4. PHPUnit_TextUI_TestRunner->doRun() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:149PHP 5. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php:440PHP 6. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:747PHP 7. PHPUnit_Framework_TestCase->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:747PHP 8. PHPUnit_Framework_TestResult->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:724PHP 9. PHPUnit_Framework_TestCase->runBare() phar:///usr/local/bin/phpunit/phpunit/Framework/TestResult.php:612PHP 10. PHPUnit_Framework_TestCase->runTest() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:768PHP 11. ReflectionMethod->invokeArgs() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:909PHP 12. ControllersTest->testLoadController() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:909PHP 13. CI_Controller->__construct() /Users/cnadig-cc/workspace/cargo/carrier-suite/application/tests/core/ControllersTest.php:33PHP 14. load_class() /Users/cnadig-cc/workspace/cargo/carrier-suite/system/core/Controller.php:75PHP 15. CI_Form_validation->__construct() /Users/cnadig-cc/workspace/cargo/carrier-suite/system/core/Common.php:196fmalk commentedon Apr 29, 2016
@cnadig-cc so, what you're doing is: you downloaded vanilla CI, latest version, then downloaded this project, installed as instructed but you can't run any tests. Is that your sequence?
If it is, I'll try to replicate it and see what I can find. It could be from a new CI version incompatibility I'm not aware of.
cnadig-cc commentedon Apr 30, 2016
$autoload['libraries']=array('form_validation') ;, and I get this error.PHP Fatal error: Class 'CI_Tracks_Auth' not found in /Library/WebServer/Documents/cargo/testci/system/core/Common.php on line 196The library class name is "Tracks_Auth". I don't know why it adds the "CI_" prefix and looks for CI_Tracks_Auth
cnadig-cc commentedon Apr 30, 2016
What's described here is what is happening when I try to auto load libraries.