fmalk / codeigniter-phpunit

Hack to make CodeIgniter work with PHPUnit.
234 stars 61 forks source link

PHP Fatal error: Call to undefined function get_instance() in application/tests/controllers/ControllerTest.php on line 9 #46

Closed liakong closed 8 years ago

liakong commented 8 years ago

I used CI 2.1.4. and I modified my code totally from the code "fmalk/codeigniter-phpunit". I entered direcotry application/tests/controllers and ran "phpunit ControllerTest", and the ouput was : "PHP Fatal error: Call to undefined function get_instance() in application/tests/controllers/ControllerTest.php on line 9". Anthor try , I ran "phpunit ControllerTest -c ../../../phpunit.xml ", it output "PHP Fatal error: Call to a member function elapsed_time() on a non-object in xxx/system/core/Output.php on line 360 ". What should I do? What does phpunit.xml do?

liakong commented 8 years ago

I require 'system/core/CodeIgniter.php' in ControllerTest.php, and ran "phpunit ControllerTest", and the ouput was : "No direct script access allowed"

liakong commented 8 years ago

Stupid question. The running method I tried above did not adapt the phpnunit under CI. As readme says, I ran phpunit -c phpunit.xml under my CI project root direcotry and it worked.