Welcome Guest, Not a member yet? Register   Sign In
Model test with Postgre, which assertion do I need?
#1

Hi,
New to CodeIgniter and TDD, I'm trying an "easy" test.

I've got a model with a create() method which is just a "insert into" statement.

I know by reading the doc, that using the query() method with Postgre doesn't return a boolean.

I know the row is correctly inserted but the fact that an object is returned is blowing my test.

So which assertion would you use for that?

Here is my test:

PHP Code:
public function testUserCreation()
{
    
$this->assertTrue(User::create('John'));


And the result is:


Quote:There were 1 failure:

1) App\Models\UserTest::testUserCreation
Failed asserting that CodeIgniter\Database\Postgre\Result Object &000000001e0d8b9e0000000043ec1359 (
    'connID' => resource(170) of type (pgsql link)
    'resultID' => resource(174) of type (pgsql result)
    'resultArray' => Array &0 ()
    'resultObject' => Array &1 ()
    'customResultObject' => Array &2 ()
    'currentRow' => 0
    'numRows' => null
    'rowData' => null
) is true.


Thanks for any advice.
Reply
#2

Show the code for User::create()
Reply




Theme © iAndrew 2016 - Forum software by © MyBB