How to access member values?

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

How to access member values?

Post by kpraman »

Code: Select all

<?php

class MembersTest extends PHPUnit_TestCase {


public function testing_insertData()
  {
      $newinsertdata=new Members;
			
      $newinsertdata->AddMember('1','testFname','testLname','testAddress','testCity','testState','123456','India','1234567','test@testmail.com','1234567890','true','members');
      $memberid_insertd=mysql_insert_id();
      $resExpectedInsertd=array((string)$memberid_insertd,'1','testFname','testLname','testAddress','testCity','testState','123456','India','1234567','test@testmail.com','1234567890','true');
$query=mysql_query("SELECT * FROM members WHERE memberId=$memberid_insertd");
$resActualInsertd=mysql_fetch_row($query);

$this->assertEquals($resExpectedInsertd,$resActualInsertd, "COULD NOT INSERT DATA.");
}

}

?>

How to access values of $resExpectedInsertd, $resActualInsertd?

This is not working.

Code: Select all

<?php
$new=new MembersTest;

$values=$new->testing_insertData()->$resExpectedInsertd;

?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your method doesn't return anything.
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

withput using return value, can't we fetch? if its not possible, then how can i return 3 array values. These 3 array values will be used to display.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Put the 3 values into an array and return the array.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

What exactly are you trying to do???

To access a variable, it must be returned from the called method. If you are trying to adapt the Reporter element of PHPUnit (as you seemed aimed at in another thread) then the values have been passed into the TestCase and recorded there (i.e. it should record all data associated with a specific test, e.g. your $this->assertEquals() call).

So, you can either access it down the line in a reporter, or return an array/stdClass from the test method.
Post Reply