Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

同一フォーム利用時にhtml属性のidが被る時があるため、被るフォーム項目はid属性を出力しないように対応 #3824

Merged
merged 8 commits into from
Sep 14, 2018
8 changes: 5 additions & 3 deletions codeception/_support/Page/Front/TopPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class TopPage extends AbstractFrontPage
{
public static $検索_カテゴリ選択 = ['id' => 'category_id'];
public static $検索_キーワード = ['id' => 'name'];
public static $検索_カテゴリ選択 = ['class' => 'category_id'];
public static $検索_キーワード = ['class' => 'search-name'];

public static function go(\AcceptanceTester $I)
{
Expand All @@ -29,6 +29,8 @@ public function 新着情報選択($rowNum)
{
$this->tester->click(['css' => "div.ec-newsRole__news > div:nth-child($rowNum) > div.ec-newsRole__newsHeading"]);

$this->tester->scrollTo(['css' => "div.ec-newsRole__news > div:nth-child($rowNum) > div.ec-newsRole__newsHeading"], 0, 200);

return $this;
}

Expand Down Expand Up @@ -58,7 +60,7 @@ public function カテゴリ選択($categories)
public function 検索($keyword = null)
{
if ($keyword) {
$this->tester->fillField(['id' => 'name'], $keyword);
$this->tester->fillField(['class' => 'search-name'], $keyword);
}
$this->tester->click('button.ec-headerSearch__keywordBtn');

Expand Down
6 changes: 3 additions & 3 deletions codeception/acceptance/EF01TopCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function topページ_初期表示(\AcceptanceTester $I)
// カテゴリ名(カテゴリ検索用)が表示されている
$categories = Fixtures::get('categories');
foreach ($categories as $category) {
$I->see($category->getName(), '#searchform #category_id option');
$I->see($category->getName(), '.searchform .category_id option');
}

//管理側のコンテンツ管理(新着情報管理)に設定されている情報が、順位順に表示されている
Expand Down Expand Up @@ -130,7 +130,7 @@ public function topページ_カテゴリ絞込検索(\AcceptanceTester $I)
$topPage = TopPage::go($I);

// カテゴリを選択する
$I->selectOption(['id' => 'category_id'], 'フルーツ');
$I->selectOption(['class' => 'category_id'], 'フルーツ');

// 虫眼鏡ボタンを押下する
$topPage->検索();
Expand All @@ -149,7 +149,7 @@ public function topページ_キーワード絞込検索(\AcceptanceTester $I)
$topPage = TopPage::go($I);

// キーワードを入力する
$I->fillField(['id' => 'name'], 'ジェラート');
$I->fillField(['class' => 'search-name'], 'ジェラート');

// 虫眼鏡ボタンを押下する
$topPage->検索();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ http://www.lockon.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% form_theme form 'Form/form_div_layout.twig' %}

<div class="ec-headerSearch">
<form method="get" id="searchform" action="{{ path('product_list') }}">
<form method="get" class="searchform" action="{{ path('product_list') }}">
<div class="ec-headerSearch__category">
<div class="ec-select ec-select_search">
{{ form_widget(form.category_id) }}
{{ form_widget(form.category_id, {'id': null, 'attr': {'class': 'category_id'}}) }}
</div>
</div>
<div class="ec-headerSearch__keyword">
<div class="ec-input">
{{ form_widget(form.name, {'attr': { 'placeholder' : 'common.search_keyword' }} ) }}
{{ form_widget(form.name, {'id': null, 'attr': {'class': 'search-name', 'placeholder' : 'common.search_keyword' }} ) }}
<button class="ec-headerSearch__keywordBtn" type="submit">
<div class="ec-icon">
<img src="{{ asset('assets/icon/search-dark.svg') }}" alt="">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,11 @@ file that was distributed with this source code.
{% endif %}
{% endif %}
{%- endblock checkbox_widget -%}

{%- block widget_attributes -%}
{%- if id %} id="{{ id }}"{% endif -%}
name="{{ full_name }}"
{%- if disabled %} disabled="disabled"{% endif -%}
{%- if required %} required="required"{% endif -%}
{{ block('attributes') }}
{%- endblock widget_attributes -%}
2 changes: 1 addition & 1 deletion tests/Eccube/Tests/Web/SearchProductControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function testCategory()
// Then
$this->assertTrue($this->client->getResponse()->isSuccessful());

$categoryNameLastElement = $crawler->filter('#category_id option')->last()->text();
$categoryNameLastElement = $crawler->filter('.category_id option')->last()->text();

$this->expected = $Category->getNameWithLevel();
$this->actual = $categoryNameLastElement;
Expand Down