A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearCreating a testing environment with php cli - page 1
User InfoPosts
Creating a testing environment with php cli#1
I want to use php in console mode and create an environment to test my functions.

I do not want to be forced to use a web browser and create a new file each time I want to test a function.

I want to access the function in the console and then it return the result.

How do I do this?

Update:

Perhaps I have explained this badly. I only want to see what result the function's return.

Maybe I have to learn unit testing but for the moment I only want an interactive console which allows me to test all functions one by one.

In my case I have to load the wordpress functions (I know how do it with a regular .php file and then a browser to parse the file) but i don't if it is possible to do it with php from the command line.

posted date: 2008-12-30 01:53:00


Re: Creating a testing environment with php cli#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-30 01:53:01


Re: Creating a testing environment with php cli#3
You are going to want to read up on "Unit Testing" in a generic sense and then try and apply them to PHP.The framework you are using (if any), the style of code, and the tests you want to run are going to determine the exact methods you need to use. Only by first understanding the concept of Unit Tests and implementing them into your coding best-practices will you be able to make progress in this regard.

posted date: 2008-12-30 01:56:00


Re: Creating a testing environment with php cli#4
I read your question and your follow-up explanation but still don't fully understand what you're trying to achieve. Do you want to execute shell PHP to verify the wordpress function return the correct value?

posted date: 2008-12-30 02:53:00


Re: Creating a testing environment with php cli#5
How about:php -aAnd if you compile php with readline support it'll be more fancy.

posted date: 2008-12-30 03:08:00


Re: Creating a testing environment with php cli#6
I have used phpsh in the past and found it very useful. Once you start it you will need to chdir() to where your files are and then obviously require() any files containing functions you need to test. You can then just test your function calls by typing them into the shell e.g. var_dump(some_function(1, 2));

posted date: 2008-12-30 03:47:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.