|
22 | 22 | use Magento\Store\Model\Store;
|
23 | 23 | use Magento\Store\Model\StoreManagerInterface;
|
24 | 24 | use Magento\TestFramework\TestCase\AbstractBackendController;
|
| 25 | +use PHPUnit\Framework\MockObject\MockObject; |
25 | 26 |
|
26 | 27 | /**
|
27 | 28 | * Tests for save customer via backend/customer/index/save controller.
|
@@ -224,6 +225,32 @@ public function createCustomerErrorsProvider(): array
|
224 | 225 | ];
|
225 | 226 | }
|
226 | 227 |
|
| 228 | + /** |
| 229 | + * Update customer with exceptions |
| 230 | + * |
| 231 | + * @magentoDbIsolation enabled |
| 232 | + * |
| 233 | + * @return void |
| 234 | + */ |
| 235 | + public function testUpdateCustomerErrors(): void |
| 236 | + { |
| 237 | + $postData = [ |
| 238 | + 'customer' => [ |
| 239 | + CustomerData::FIRSTNAME => 'John', |
| 240 | + CustomerData::LASTNAME => 'Doe', |
| 241 | + ], |
| 242 | + 'subscription' => '1', |
| 243 | + ]; |
| 244 | + $expectedMessages = [(string)__('Something went wrong while saving the customer.')]; |
| 245 | + $postData['customer']['entity_id'] = -1; |
| 246 | + $params = ['back' => true]; |
| 247 | + $this->dispatchCustomerSave($postData, $params); |
| 248 | + $this->assertSessionMessages( |
| 249 | + $this->equalTo($expectedMessages), |
| 250 | + MessageInterface::TYPE_ERROR |
| 251 | + ); |
| 252 | + } |
| 253 | + |
227 | 254 | /**
|
228 | 255 | * Update customer with subscription and redirect to edit page.
|
229 | 256 | *
|
@@ -512,15 +539,15 @@ private function assertCustomerSubscription(
|
512 | 539 | * @param array $sender
|
513 | 540 | * @param int $customerId
|
514 | 541 | * @param string|null $newEmail
|
515 |
| - * @return \PHPUnit\Framework\MockObject\MockObject |
| 542 | + * @return MockObject |
516 | 543 | */
|
517 | 544 | private function prepareEmailMock(
|
518 | 545 | int $occurrenceNumber,
|
519 | 546 | string $templateId,
|
520 | 547 | array $sender,
|
521 | 548 | int $customerId,
|
522 | 549 | $newEmail = null
|
523 |
| - ) : \PHPUnit\Framework\MockObject\MockObject { |
| 550 | + ) : MockObject { |
524 | 551 | $area = Area::AREA_FRONTEND;
|
525 | 552 | $customer = $this->customerRepository->getById($customerId);
|
526 | 553 | $storeId = $customer->getStoreId();
|
@@ -568,12 +595,12 @@ private function prepareEmailMock(
|
568 | 595 | /**
|
569 | 596 | * Add email mock to class
|
570 | 597 | *
|
571 |
| - * @param \PHPUnit\Framework\MockObject\MockObject $transportBuilderMock |
| 598 | + * @param MockObject $transportBuilderMock |
572 | 599 | * @param string $className
|
573 | 600 | * @return void
|
574 | 601 | */
|
575 | 602 | private function addEmailMockToClass(
|
576 |
| - \PHPUnit\Framework\MockObject\MockObject $transportBuilderMock, |
| 603 | + MockObject $transportBuilderMock, |
577 | 604 | $className
|
578 | 605 | ): void {
|
579 | 606 | $mocked = $this->_objectManager->create(
|
|
0 commit comments