Welcome Guest, Not a member yet? Register   Sign In
Controller Testing
#1

[eluser]Unknown[/eluser]
Hi,

I am currently trying to implement unit testing (phpunit) for the Controllers of my application written in CI. In my controllers, session variables are initialized and checked for the logged-in user. Is there a way I can initialize session variable from the command line or test case, and write test cases to test Controllers.

Also, some of my Controllers, after successful execution, are loading views and returning no data. Is there any way to check (in the test cases) if correct view is loaded after feeding correct input to the Controller.
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter community.

[quote author="ambi" date="1235223275"]Hi,

I am currently trying to implement unit testing (phpunit) for the Controllers of my application written in CI. In my controllers, session variables are initialized and checked for the logged-in user. Is there a way I can initialize session variable from the command line or test case, and write test cases to test Controllers.[/quote]

As far as I'm aware, no you can't. Sessions won't work via the command line, as consoles don't accept cookies.

Also, I don't think you can test your controllers like you might think. You'd probably need a different kind of unit tester running on a different server, that can check HTML output.

[quote author="ambi" date="1235223275"]
Also, some of my Controllers, after successful execution, are loading views and returning no data. Is there any way to check (in the test cases) if correct view is loaded after feeding correct input to the Controller.[/quote]

Not that I'm aware of, no. Sorry.




Theme © iAndrew 2016 - Forum software by © MyBB