dimanche 26 février 2017

PHPUnit: MySQL JSON Field Fails Assertion

I am testing that each field is properly created in the database. The interests field is a MySQL JSON datatype and it fails the seeInDatabase assertion. It does, however, get inserted into the database correctly.

I have tried it with and without the enclosing quotes. What am I missing?

public function testUserWithFullProfileIsCreated()
{
    $parameters = [
        'username'     => 'test_user-123',
        'email'        => 'test@user.com',
        'password'     => '123-abcd',
        'country_code' => 'US',
        'interests'    => '["movies", "science", "technology"]'
    ];

    $this->json('POST', '/v1/users', $parameters)
        ->seeJson([ 'created' => true ])
        ->seeInDatabase('users', [
            'username'     => 'test_user-123',
            'email'        => 'test@user.com',
            'password'     => '123-abcd',
            'country_code' => 'US',
            'interests'    => '["movies", "science", "technology"]'
        ]);
}

Actual Error:

UserTest::testUserWithFullProfileIsCreated -- Unable to find row in database table [users] that matched attributes [{"username":"test_user-123" ...]



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l08zhP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire