Page 1 of 1

How to access member values?

Posted: Wed Nov 08, 2006 11:38 pm
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;

?>

Posted: Wed Nov 08, 2006 11:49 pm
by feyd
Your method doesn't return anything.

Posted: Thu Nov 09, 2006 12:19 am
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.

Posted: Thu Nov 09, 2006 1:01 am
by Chris Corbyn
Put the 3 values into an array and return the array.

Posted: Thu Nov 09, 2006 2:57 am
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.