Skip to content

Commit

Permalink
Merge pull request #1 from okazy/feature/#4716_fix_adminpage_order_se…
Browse files Browse the repository at this point in the history
…arch

受注のマルチ検索で、会社名はスペースを除去せず検索
  • Loading branch information
morry48 authored Nov 14, 2020
2 parents 42609b5 + 328bacd commit c7c415d
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Eccube/Repository/OrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ public function getQueryBuilderBySearchDataForAdmin($searchData)
}
$qb
->andWhere('o.id = :multi OR CONCAT(o.name01, o.name02) LIKE :likemulti OR '.
'CONCAT(o.kana01, o.kana02) LIKE :likemulti OR o.company_name LIKE :likemulti OR '.
'CONCAT(o.kana01, o.kana02) LIKE :likemulti OR o.company_name LIKE :company_name OR '.
'o.order_no LIKE :likemulti OR o.email LIKE :likemulti OR o.phone_number LIKE :likemulti')
->setParameter('multi', $multi)
->setParameter('likemulti', '%'.$clean_key_multi.'%');
->setParameter('likemulti', '%'.$clean_key_multi.'%')
->setParameter('company_name', '%'.$searchData['multi'].'%'); // 会社名はスペースを除去せず検索
}

// order_id_end
Expand Down
73 changes: 71 additions & 2 deletions tests/Eccube/Tests/Repository/OrderRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace Eccube\Tests\Repository;

use Eccube\Entity\Customer;
use Eccube\Entity\Order;
use Eccube\Entity\Master\OrderStatus;
use Eccube\Entity\Order;
use Eccube\Repository\OrderRepository;
use Eccube\Tests\EccubeTestCase;

Expand Down Expand Up @@ -125,12 +125,81 @@ public function testGetQueryBuilderBySearchDataForAdmin_multi_2147483648()
$Order = $this->createOrder($this->createCustomer('[email protected]'));
$Order->setOrderStatus($this->entityManager->find(OrderStatus::class, OrderStatus::NEW));
$this->orderRepository->save($Order);
$this->entityManager->flush();;
$this->entityManager->flush();

$actual = $this->orderRepository->getQueryBuilderBySearchDataForAdmin(['multi' => '2147483648'])
->getQuery()
->getResult();

self::assertEquals($Order, $actual[0]);
}

/**
* @dataProvider dataGetQueryBuilderBySearchDataForAdmin_nameProvider
*/
public function testGetQueryBuilderBySearchDataForAdmin_name(string $formName, string $searchWord, int $expected)
{
$this->Order
->setOrderStatus($this->entityManager->find(OrderStatus::class, OrderStatus::NEW))
->setName01('')
->setName02('')
->setKana01('セイ')
->setKana02('メイ')
->setCompanyName('株式会社 会社名'); // 全角スペース
$this->orderRepository->save($this->Order);
$this->entityManager->flush();

$actual = $this->orderRepository->getQueryBuilderBySearchDataForAdmin([$formName => $searchWord])
->getQuery()
->getResult();

self::assertCount($expected, $actual);
}

public function dataGetQueryBuilderBySearchDataForAdmin_nameProvider()
{
return [
['multi', '', 1],
['multi', '', 1],
['multi', '姓名', 1],
['multi', '姓 名', 1],
['multi', '姓 名', 1],
['multi', 'セイ', 1],
['multi', 'メイ', 1],
['multi', 'セイメイ', 1],
['multi', 'セイ メイ', 1],
['multi', 'セイ メイ', 1],
['multi', '株式会社', 1],
['multi', '会社名', 1],
['multi', '株式会社会社名', 0],
['multi', '株式会社 会社名', 0], // 半角スペース
['multi', '株式会社 会社名', 1], // 全角スペース
['multi', '', 0],
['multi', 'キューブ', 0],
['multi', '姓 球部', 0],
['multi', 'セイ 名', 0],
['multi', '姓 メイ', 0],
['name', '', 1],
['name', '', 1],
['name', '姓名', 1],
['name', '姓 名', 1],
['name', '姓 名', 1],
['name', 'セイ', 0],
['name', '株式会社 会社名', 0],
['kana', 'セイ', 1],
['kana', 'メイ', 1],
['kana', 'セイメイ', 1],
['kana', 'セイ メイ', 1],
['kana', 'セイ メイ', 1],
['kana', '', 0],
['kana', '株式会社 会社名', 0],
['company_name', '株式会社', 1],
['company_name', '会社名', 1],
['company_name', '株式会社会社名', 0],
['company_name', '株式会社 会社名', 0], // 半角スペース
['company_name', '株式会社 会社名', 1], // 全角スペース
['company_name', '', 0],
['company_name', 'セイ', 0],
];
}
}

0 comments on commit c7c415d

Please sign in to comment.