user_id
, user_name
という属性を持つUserモデルがあり、$user
というインスタンスが存在するとします。
あるAPIはその値をそれぞれ以下のようにid
とname
に加工してJSONで出力するとします。
PHP
1return [ 2 'id' -> $user->user_id, 3 'name' -> $user->user_name 4]
json
1{ 2 id: 1 3 name: hoge 4}
この時、idはUserのuser_id
、nameはUserのuser_name
から取得しているというテストをする方法はありますか?
どなたかよろしくお願いします。
あなたの回答
tips
プレビュー