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

$CI =& get_instance(); return null in createAndCallController function in CIPHPUnitTestRequest.php #332

Closed
biechao opened this issue May 28, 2020 · 2 comments

Comments

@biechao
Copy link

biechao commented May 28, 2020

In CIPHPUnitTestRequest.php there is a function createAndCallController funtion.
When I try to test my controller with code:

class Saml_test extends TestCase
{

	public function test_ut_test()
	{
		$output = $this->request('GET', "saml/ut_test");
		$this->assertContains('1', $output);
	}

}

I got this error message in console:

Saml_test::test_ut_test
RuntimeException: Argument 1 passed to CIPHPUnitTestCase::setCI() must be an instance of CI_Controller, instance of CIPHPUnitTestNullCodeIgniter given, called in xxx

After further debugging, I found this function return null, and it supposes to return an instance of CI.

		// Create controller
		if (CIPHPUnitTest::wiredesignzHmvcInstalled())
		{
			new CI();
		}
		$controller = new $class;
		$CI =& get_instance();
		**// The $CI is null here**
		// Set CodeIgniter instance to TestCase
		$this->testCase->setCI($CI);
@kenjis
Copy link
Owner

kenjis commented May 28, 2020

@biechao Read the error message carefully, so you might have any clue.

@biechao biechao changed the title Maximum function nesting level of '256' reached $CI =& get_instance(); return null in createAndCallController function in CIPHPUnitTestRequest.php May 29, 2020
@kenjis
Copy link
Owner

kenjis commented May 29, 2020

@biechao I don't know why the $CI is null.
And the error message says the argument is CIPHPUnitTestNullCodeIgniter, not null.

@kenjis kenjis closed this as completed Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants