Page 1 of 1

Check this

Posted: Tue Oct 17, 2006 6:09 am
by kpraman
JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php 
set_include_path("library/"); 

require_once 'members.php'; 
require_once 'PHPUnit/Framework/TestCase.php'; 
require_once 'PHPUnit.php'; 

class MembersTest extends PHPUnit_TestCase { 



function test_insert() 
{ 
$new=new Members; 
$dbActual=$new->AddOrUpdateMember('a','b','c','d','e','f','g','h','i','j','k','','table1'); 
$dbExpected=1; 
$this->assertTrue($dbExpected=="$dbActual", "INSERT FAILED"); 
} 

} 

$suite = new PHPUnit_TestSuite('MembersTest'); 
$result = PHPUnit::run($suite); 
print $result->toHTML(); 
?>

is there anything wrong in the code? I also want to know, if i change the function name test_insert(), it does not work. If i want to write a new function, what should i do?


JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Oct 17, 2006 7:33 am
by Chris Corbyn
All test case methods must start with the word "test..." so if you remove the initial 4 letters it won't run. You can add your own functions but you'll have to call them manually. If you're testing something make a new method like "testSomethingElse()". I'm sure this will be covered in the PHPUnit documentation/cookbook :)

Posted: Tue Oct 17, 2006 7:42 am
by feyd
kpraman, please try to make a slightly more descriptive subject line next time, and also please start using the highlighting tags. If you don't know what they are or how they work, follow the links that have been added to your post above by JayBird.

Posted: Wed Oct 18, 2006 1:02 am
by kpraman
Thanks for ur replies.

I have writte the code for delete, update etc. When i run, i get results,

TestCase MembersTest->testing_insert() passed
TestCase MembersTest->testing_insertNotable() passed
TestCase MembersTest->testing_insertWithoutid() passed
TestCase MembersTest->testing_update() passed
TestCase MembersTest->testing_updateNoid() passed
TestCase MembersTest->testing_updateData() passed
TestCase MembersTest->testing_insertData() passed
TestCase MembersTest->test_DeleteNoid() passed
TestCase MembersTest->test_Delete() passed
TestCase MembersTest->test_EnableMemberTest() passed
TestCase MembersTest->test_EnableMemberNottrueTest() passed

What should i do next?