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

#226 【管理画面/会員編集】管理画面で退会にステータスを変更した場合、メールアドレスがランダムなものに変更されない #3397

Merged
merged 6 commits into from
Aug 9, 2018
11 changes: 11 additions & 0 deletions src/Eccube/Controller/Admin/Customer/CustomerEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
use Eccube\Controller\AbstractController;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Entity\Master\CustomerStatus;
use Eccube\Form\Type\Admin\CustomerType;
use Eccube\Repository\CustomerRepository;
use Eccube\Util\StringUtil;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -60,6 +62,8 @@ public function index(Request $request, $id = null)
if (is_null($Customer)) {
throw new NotFoundHttpException();
}

$oldStatusId = $Customer->getStatus()->getId();
// 編集用にデフォルトパスワードをセット
$previous_password = $Customer->getPassword();
$Customer->setPassword($this->eccubeConfig['eccube_default_password']);
Expand All @@ -68,6 +72,7 @@ public function index(Request $request, $id = null)
$Customer = $this->customerRepository->newCustomer();
$Customer->setBuyTimes(0);
$Customer->setBuyTotal(0);
$oldStatusId = null;
}

// 会員登録フォーム
Expand Down Expand Up @@ -103,6 +108,12 @@ public function index(Request $request, $id = null)
$Customer->setPassword($encoder->encodePassword($Customer->getPassword(), $Customer->getSalt()));
}

// 退会ステータスに更新の場合、ダミーのアドレスに更新
$newStatusId = $Customer->getStatus()->getId();
if ($oldStatusId != $newStatusId && $newStatusId == CustomerStatus::WITHDRAWING) {
$Customer->setEmail(StringUtil::random(60).'@dummy.dummy');
}

$this->entityManager->persist($Customer);
$this->entityManager->flush();

Expand Down
2 changes: 2 additions & 0 deletions src/Eccube/Controller/Mypage/WithdrawController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Eccube\Event\EventArgs;
use Eccube\Repository\Master\CustomerStatusRepository;
use Eccube\Service\MailService;
use Eccube\Util\StringUtil;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -96,6 +97,7 @@ public function index(Request $request)
// 退会ステータスに変更
$CustomerStatus = $this->customerStatusRepository->find(CustomerStatus::WITHDRAWING);
$Customer->setStatus($CustomerStatus);
$Customer->setEmail(StringUtil::random(60).'@dummy.dummy');

$this->entityManager->flush();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,22 @@ public function testNotShowProcessingOrder()
$orderListing = $crawler->filter('#orderHistory')->text();
$this->assertContains('この会員の購入履歴がありません', $orderListing);
}

/**
* testCustomerWithdraw
*/
public function testCustomerWithdraw()
{
$form = $this->createFormData();
$form['status'] = 3;
$this->client->request(
'POST',
$this->generateUrl('admin_customer_edit', ['id' => $this->Customer->getId()]),
['admin_customer' => $form]
);

$EditedCustomer = $this->container->get(CustomerRepository::class)->find($this->Customer->getId());

$this->assertRegExp('/@dummy.dummy/', $EditedCustomer->getEmail());
}
}
2 changes: 2 additions & 0 deletions tests/Eccube/Tests/Web/Mypage/WithdrawControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function testIndexWithPostComplete()
]
);

$this->assertRegExp('/@dummy.dummy/', $this->Customer->getEmail());

$this->assertTrue($this->client->getResponse()->isRedirect($this->generateUrl('mypage_withdraw_complete')));

$Messages = $this->getMailCollector(false)->getMessages();
Expand Down