EC-CUBE / EC-CUBE/ec-cube

受注編集テスト: 実画面に無い二重バインド経路と未ソートキーの是正

Open Beginner friendly
#6,942 0 comments 0 reactions 0 assignees View on GitHub
bug bug:Low test
Dominant language
PHP
Stars
788
Forks
719
Avg merge
4d 4h
Merged PRs (30d)
39

Description

## 背景

PR #6926 のレビュー (@nanasess) で、`tests/Eccube/Tests/Web/Admin/Order/AbstractEditControllerTestCase` 由来の 2 点が指摘された。いずれも #6926 で作り込んだ問題ではなく、既存のテストヘルパの前提が実画面とずれているもの。次のテスト整備でまとめて是正したい(#6934 のテスト結合是正とは別観点=テストの忠実性)。

## 是正したい点

### 1. 実画面に存在しない二重バインド経路を通っている

`edit.twig` は `form.Shipping.OrderItems` を一切レンダリングしない(`form_rest` も無い)ため、**実フォームは `order[Shipping][OrderItems]` を送信しない**。Crawler で実測しても送信されていない。

一方テストヘルパは `order[OrderItems][i]` と `order[Shipping][OrderItems][j]` の両方に同じ `OrderItem` をバインドする経路を通しており、実画面に無い二重バインド経路を検証していることになる。

### 2. キー生成が未ソートで、たまたま一致しているだけの可能性

`createFormDataForEdit` は `$Order->getOrderItems()`(**未ソート**)でキーを作るが、サーバ側は `OrderType::sortOrderItems`(`POST_SET_DATA`)により `$Order->getItems()` の**ソート済み**キーにマップする。現状は生成順が偶然ソート順と一致して通っているだけの可能性があるため、`$Order->getItems()` を使う方が前提が明示的になる。

## やること

- テストヘルパのフォームデータ生成を実画面のレンダリング内容に合わせる(`Shipping[OrderItems]` を送信しない)。
- キー生成を `$Order->getItems()`(ソート済み)ベースに揃える。
- 既存の受注編集テストが緑のままであることを確認。

## 参考

- PR #6926 / Issue #6444
- レビュー: https://github.com/EC-CUBE/ec-cube/pull/6926 (@nanasess のコメント、`EditControllerTest.php:911` へのインライン)

Contributor guide

Open the contributing guide

Research direction

Start with tests/Eccube/Tests/Web/Admin/Order/AbstractEditControllerTestCase and its createFormDataForEdit method, then compare the submitted fields with edit.twig. Check OrderType::sortOrderItems to confirm the expected item-key order. Done means the helper no longer submits Shipping[OrderItems], uses the sorted items, and the existing order-edit tests remain green.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, symfony
Domain
testing
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.