tags:

views:

42

answers:

1

I am working on PHPunit tests and so far everything is great. There is one issue, however, and it is with the following setup. Ideally I'd like to select the next value in the sequence (postgreSQL) and pass that into the function so I can validate it against the array returned from my class being tested (new row in database).

The issue is that before the array is returned from the data provider (if I echo it) it is the correct value, but during the test it comes through as blank. Is there a particular series of steps I'm missing in here in terms of what I expect or must I do this a different way?

/**
* @dataProvider testSignupProvider
*/
public function testSignup($a, $b, $c)
{
    ...stuff is done with $a,$b,$c
}


public function testSignupProvider()
{
    $uid = fetchOne(X("SELECT currval('users_id_seq')"));

    return array(
        array(false, array(), $error4)
        ,array('email'=>'[email protected]','password'=>'youaintgonnagetit'), $error3)
        ,array(array('id'=>$uid,'email'=>'[email protected]','username'=>'Guest'), array('email'=>'[email protected]','password'=>'youaintgonnagetit'), null)
    );
}

Output:

Array
 (
-    [id] =>
+    [id] => 2
     [email] => [email protected]
     [username] => Guest
 )
A: 

I've gotten around this by assigning the 'id' array element to '@id' and in the function test I pull the current id in the sequence at that time.

Still will accept an answer to anyone who can tell me why this behavior occurs but hopefully this will help anyone else with this issue.

methodin