問題描述
如何使用 codeception seeRecord 函數來測試列的內容? (How can I use codeception seeRecord function for testing contents a column?)
我正在使用 Codeception 測試由 Laravel 開發的 REST API。
我使用這樣的 seeRecord 方法來測試列的值:
$I‑>seeRecord('organisations', ['id' => $id, 'first_name' => $value]);
但是 seeRecord
所做的是測試相等性。但是在某些情況下,我需要測試內容而不是相等性,例如:
WHERE columnX like %value%
看來我可以使用 seeRecord
的第三個參數來做到這一點,即 [Part] orm
雖然我找不到任何文檔或示例。
知道如何檢查 like
運算符的記錄嗎?
參考解法
方法 1:
[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');
(by MJBZA、Naktibalda)