如何使用 codeception seeRecord 函數來測試列的內容? (How can I use codeception seeRecord function for testing contents a column?)


問題描述

如何使用 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 MJBZANaktibalda)

參考文件

  1. How can I use codeception seeRecord function for testing contents a column? (CC BY‑SA 2.5/3.0/4.0)

#Testing #Laravel #PHP #codeception






相關問題

在線庫報告的錯誤 (Online repository for reported bugs)

INSTAL_PARSE_FAILED_NO_CERTIFICATES - 試圖在 robotsium 上測試不是我的 .apk 文件 (INSTAL_PARSE_FAILED_NO_CERTIFICATES - trying to test not my .apk file on robotium)

沒有模擬器的Android測試 (Android tests without emulator)

Protractor 測試框架的可重用函數 (Reusable functions for Protractor test framework)

隨機失敗的驗收測試錯誤:斷言失敗:在銷毀對像上調用集合 (randomly failing acceptance-tests with Error: Assertion Failed: calling set on destroyed object)

如何在嵌入式系統中執行回歸測試 (How to perform regression tests in embedded systems)

移動應用測試 (Mobile application testing)

互聯網瀏覽器測試 (Internet explorer testing)

在 VS2010 中創建帶有斷言的編碼 UI 測試的工作流程是什麼? (What is the workflow for creating a coded UI test with assertions in VS2010?)

谷歌播放保護阻止安裝我的調試 apk (Google play protect is preventing the installation of my debug apk)

如何使用 codeception seeRecord 函數來測試列的內容? (How can I use codeception seeRecord function for testing contents a column?)

將 JSON 文件作為 Post Request Flask 發送 (Sending JSON File as Post Request Flask)







留言討論