Warm tip: This article is reproduced from stackoverflow.com, please click
codeception laravel php testing

How can I use codeception seeRecord function for testing contents a column?

发布于 2020-04-23 11:06:06

I am using Codeception for testing a REST API developed by Laravel.

I use seeRecord method like this for testing value of a columns:

 $I->seeRecord('organisations', ['id' => $id, 'first_name' => $value]);

But what the seeRecord does is testing equality. However in some cases I need to test the contents and not the equality, something like:

WHERE columnX like %value%

It seems I can do it with the third parameter of the seeRecord which is [Part] orm while I couldn't find any documentation or sample for that.

Any idea that how can I check the record for like operator?

Questioner
Mahdi J.Ansari
Viewed
18
Naktibalda 2020-02-10 15:55

[Part] orm is not a parameter, it means that it is possible to import only that part of the module (ORM methods) to actor class.

The only way to use different comparison functions with data is to fetch the record and use assertions from Asserts module.

$org = $I->grabRecord('organisations', ['id' => $id]);
$I->assertStringContainsString('value', $org['first_name'], 'First name doesnt contain value');