473,324 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to test Procedural code using "PHPUnit" Framework?

Hi All,

I have written some PHPUnit test code by using classes.
test.php
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. require_once('PHPUnit/Framework.php');
  4. include("hello.php");
  5.  class Test1 extends  PHPUnit_Framework_TestCase
  6.  {
  7.  
  8.         function testAdd() {
  9.             $a=3;
  10.             $b=6;
  11.              $r=add($a,$b);
  12.             $this->assertNotNull($r);
  13.             $this->assertEquals($r,9);
  14.             $this->assertTrue($r>0);
  15.         }
  16. }
  17. ?>
  18.  
hello.php
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.   function add($a,$b)
  4.  {
  5.       return ($a+$b);
  6. }
  7. ?>
  8.  
Here I am able to test whether the function is returning the expected value for the given input paramaters or not.

But, How to test the code inside the function "add()".

I mean, the testing should be done to the php code (for example:- for loops, if conditions etc.) present inside the "add()" function body.

Pl. do reply me.
Sep 27 '07 #1
0 1751

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jacob Atzen | last post by:
Howdy, For the last couple of days I've been trying to get PHPUnit2 (the one from Pear) working on my system. I have read the documentation over and over but still can't get any tests to run....
2
by: tuergeist | last post by:
Hi *, I searched for best practises for php apps, especially if you're using phpunit as testframework. I found nothing interesting, so I ask you, what do you think is a best practise on...
1
by: Harris Kosmidhs | last post by:
Hello, I recently installed eclipse with the php plugin. My question is: can eclipse be used in a medium size site where php file include others? Or when you use an MVC approach. To be more...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.