Skip to content

Commit c1c1dfe

Browse files
committed
MC-32126: Admin: Create/update/delete customer
1 parent 8aa3ffb commit c1c1dfe

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/SaveTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SaveTest extends AbstractBackendController
3636
*
3737
* @var string
3838
*/
39-
private $_baseControllerUrl = 'http://localhost/index.php/backend/customer/index/';
39+
private $baseControllerUrl = 'backend/customer/index/';
4040

4141
/** @var CustomerRepositoryInterface */
4242
private $customerRepository;
@@ -83,7 +83,7 @@ public function testCreateCustomer(array $postData, array $expectedData): void
8383
$this->equalTo([(string)__('You saved the customer.')]),
8484
MessageInterface::TYPE_SUCCESS
8585
);
86-
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'index/key/'));
86+
$this->assertRedirect($this->stringContains($this->baseControllerUrl . 'index/key/'));
8787
$this->assertCustomerData(
8888
$postData['customer'][CustomerData::EMAIL],
8989
(int)$postData['customer'][CustomerData::WEBSITE_ID],
@@ -158,7 +158,7 @@ public function testCreateCustomerErrors(array $postData, array $expectedData, a
158158
);
159159
$this->assertNotEmpty($this->session->getCustomerFormData());
160160
$this->assertArraySubset($expectedData, $this->session->getCustomerFormData());
161-
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new/key/'));
161+
$this->assertRedirect($this->stringContains($this->baseControllerUrl . 'new/key/'));
162162
}
163163

164164
/**
@@ -251,8 +251,8 @@ public function testUpdateCustomer(): void
251251
$this->equalTo([(string)__('You saved the customer.')]),
252252
MessageInterface::TYPE_SUCCESS
253253
);
254-
$this->assertRedirect($this->stringStartsWith(
255-
$this->_baseControllerUrl . 'edit/id/' . $customerData->getId()
254+
$this->assertRedirect($this->stringContains(
255+
$this->baseControllerUrl . 'edit/id/' . $customerData->getId()
256256
));
257257
$this->assertCustomerData($customerData->getEmail(), (int)$customerData->getWebsiteId(), $expectedData);
258258
$this->assertCustomerSubscription(
@@ -289,7 +289,7 @@ public function testExistingCustomerUnsubscribeNewsletter(): void
289289
$this->equalTo([(string)__('You saved the customer.')]),
290290
MessageInterface::TYPE_SUCCESS
291291
);
292-
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'index/key/'));
292+
$this->assertRedirect($this->stringContains($this->baseControllerUrl . 'index/key/'));
293293
$this->assertCustomerSubscription(
294294
(int)$customerData->getId(),
295295
(int)$customerData->getWebsiteId(),
@@ -344,7 +344,7 @@ public function testExistingCustomerChangeEmail(): void
344344
* Check that no errors were generated and set to session
345345
*/
346346
$this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_ERROR);
347-
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'index/key/'));
347+
$this->assertRedirect($this->stringContains($this->baseControllerUrl . 'index/key/'));
348348
}
349349

350350
/**
@@ -384,7 +384,7 @@ public function testCreateSameEmailFormatDateError(): void
384384
true,
385385
'Customer form data should be formatted'
386386
);
387-
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new/key/'));
387+
$this->assertRedirect($this->stringContains($this->baseControllerUrl . 'new/key/'));
388388
}
389389

390390
/**
@@ -449,7 +449,7 @@ private function dispatchCustomerSave(array $postData, array $params = []): void
449449
if (!empty($params)) {
450450
$this->getRequest()->setParams($params);
451451
}
452-
$this->dispatch('backend/customer/index/save');
452+
$this->dispatch($this->baseControllerUrl . 'save');
453453
}
454454

455455
/**

dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
namespace Magento\Customer\Controller\Adminhtml;
88

99
use Magento\Backend\Model\Session;
10+
use Magento\Customer\Api\CustomerNameGenerationInterface;
1011
use Magento\Customer\Api\CustomerRepositoryInterface;
11-
use Magento\Customer\Helper\View;
1212
use Magento\Customer\Model\EmailNotification;
1313
use Magento\TestFramework\Helper\Bootstrap;
1414
use Magento\Framework\App\Request\Http as HttpRequest;
@@ -25,23 +25,22 @@ class IndexTest extends AbstractBackendController
2525
*
2626
* @var string
2727
*/
28-
protected $_baseControllerUrl;
28+
private $baseControllerUrl = 'backend/customer/index/';
2929

3030
/** @var CustomerRepositoryInterface */
31-
protected $customerRepository;
31+
private $customerRepository;
3232

33-
/** @var View */
34-
protected $customerViewHelper;
33+
/** @var CustomerNameGenerationInterface */
34+
private $customerViewHelper;
3535

3636
/**
3737
* @inheritDoc
3838
*/
3939
protected function setUp()
4040
{
4141
parent::setUp();
42-
$this->_baseControllerUrl = 'http://localhost/index.php/backend/customer/index/';
4342
$this->customerRepository = $this->_objectManager->get(CustomerRepositoryInterface::class);
44-
$this->customerViewHelper = $this->_objectManager->get(View::class);
43+
$this->customerViewHelper = $this->_objectManager->get(CustomerNameGenerationInterface::class);
4544
}
4645

4746
/**
@@ -173,7 +172,7 @@ public function testResetPasswordActionNoCustomerId()
173172
// No customer ID in post, will just get redirected to base
174173
$this->getRequest()->setMethod(HttpRequest::METHOD_GET);
175174
$this->dispatch('backend/customer/index/resetPassword');
176-
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl));
175+
$this->assertRedirect($this->stringContains($this->baseControllerUrl));
177176
}
178177

179178
/**
@@ -185,7 +184,7 @@ public function testResetPasswordActionBadCustomerId()
185184
$this->getRequest()->setMethod(HttpRequest::METHOD_GET);
186185
$this->getRequest()->setPostValue(['customer_id' => '789']);
187186
$this->dispatch('backend/customer/index/resetPassword');
188-
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl));
187+
$this->assertRedirect($this->stringContains($this->baseControllerUrl));
189188
}
190189

191190
/**
@@ -200,7 +199,7 @@ public function testResetPasswordActionSuccess()
200199
$this->equalTo(['The customer will receive an email with a link to reset password.']),
201200
\Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
202201
);
203-
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'edit'));
202+
$this->assertRedirect($this->stringContains($this->baseControllerUrl . 'edit'));
204203
}
205204

206205
/**

0 commit comments

Comments
 (0)