I am using phpunit to test my php application.
In my application, one main window opens a new window for search, and after search when I click on any record, Record details appears in the main window.
How can i handle this scenario in phpunit.
Thanks,
Manoj
How to handle session between two windows in
Moderator: General Moderators
-
indiavitus
- Forum Newbie
- Posts: 5
- Joined: Wed Sep 01, 2010 5:23 am
Re: How to handle session between two windows in
Code: Select all
function testOne()
{
$_SESSION['foo'] = 'bar';
$this->assertEquals( 'bar', $_SESSION['foo'] );
}
So basically just set the session as if the user had had it set. Then run your assertions like a regular test. And clean up the $_SESSION as part of the tearDown()
If you are lucky enough to have a nice architecture you could look into using an object wrapper, so you can insert mock objects. Here in my example I would call a "mock array", for lack of a term. Using the mock object is better, because then you are creating a software where it is easy to alter the session behavior. If you don't have to use globals in your test, you don't have to use globals in the production code - and that's an ideal goal. Although PHP does have procedural callbacks for that in place (for example if you wanted the session data to come from a database, or other custom function).
-
indiavitus
- Forum Newbie
- Posts: 5
- Joined: Wed Sep 01, 2010 5:23 am
Re: How to handle session between two windows in
Thanks josh for your reply.
I have different problem with which i am struggling.
I have written a test case which is testing a web application. In my application, one search page get opens from a main page. upon entering some search criteria in the search page, it fetches all the related records on the search page itself.
But once I click over any record in the search page, details for that record in get displayed in the main page which invoked the search page.
In my test case, I am able to open the search page, search the data and click on any of the data. After clicking, how can i take the control of the main page.
This is where I got stuck.
Please suggest.
Thanks,
Manoj
I have different problem with which i am struggling.
I have written a test case which is testing a web application. In my application, one search page get opens from a main page. upon entering some search criteria in the search page, it fetches all the related records on the search page itself.
But once I click over any record in the search page, details for that record in get displayed in the main page which invoked the search page.
In my test case, I am able to open the search page, search the data and click on any of the data. After clicking, how can i take the control of the main page.
This is where I got stuck.
Please suggest.
Thanks,
Manoj