|
9 | 9 | use Commercetools\Core\ApiTestCase; |
10 | 10 | use Commercetools\Core\Model\Common\Address; |
11 | 11 | use Commercetools\Core\Model\Common\AddressCollection; |
| 12 | +use Commercetools\Core\Model\Common\CreatedBy; |
| 13 | +use Commercetools\Core\Model\Common\LastModifiedBy; |
12 | 14 | use Commercetools\Core\Model\Customer\Customer; |
13 | 15 | use Commercetools\Core\Model\Customer\CustomerDraft; |
14 | 16 | use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft; |
@@ -547,7 +549,6 @@ public function testCompanyName() |
547 | 549 |
|
548 | 550 | $this->assertSame($customer->getVersion(), $result->getVersion()); |
549 | 551 | $this->assertSame($customer->getCompanyName(), $result->getCompanyName()); |
550 | | - |
551 | 552 | } |
552 | 553 |
|
553 | 554 | public function testDateOfBirth() |
@@ -653,6 +654,48 @@ public function testCustomField() |
653 | 654 | $this->assertSame($this->getTestRun(), $customer->getCustom()->getFields()->getTestField()); |
654 | 655 | } |
655 | 656 |
|
| 657 | + |
| 658 | + public function testSetExternalUserOnCustomerUpdate() |
| 659 | + { |
| 660 | + $draft = $this->getDraft('name'); |
| 661 | + |
| 662 | + $request = CustomerCreateRequest::ofDraft($draft); |
| 663 | + $request->setExternalUserId('custom-external-user-id'); |
| 664 | + |
| 665 | + $response = $request->executeWithClient($this->getClient()); |
| 666 | + $result = $request->mapResponse($response); |
| 667 | + |
| 668 | + $this->cleanupRequests[] = $this->deleteRequest = CustomerDeleteRequest::ofIdAndVersion( |
| 669 | + $result->getCustomer()->getId(), |
| 670 | + $result->getCustomer()->getVersion() |
| 671 | + ); |
| 672 | + $customer = $result->getCustomer(); |
| 673 | + |
| 674 | + $this->assertInstanceOf(Customer::class, $customer); |
| 675 | + $this->assertInstanceOf(CreatedBy::class, $customer->getCreatedBy()); |
| 676 | + $this->assertInstanceOf(LastModifiedBy::class, $customer->getLastModifiedBy()); |
| 677 | + $this->assertSame('custom-external-user-id', $customer->getCreatedBy()->getExternalUserId()); |
| 678 | + $this->assertSame('custom-external-user-id', $customer->getLastModifiedBy()->getExternalUserId()); |
| 679 | + |
| 680 | + $key = 'new-' . $this->getTestRun(); |
| 681 | + $request = CustomerUpdateRequest::ofIdAndVersion($customer->getId(), $customer->getVersion()) |
| 682 | + ->addAction( |
| 683 | + CustomerSetKeyAction::of()->setKey($key) |
| 684 | + ) |
| 685 | + ; |
| 686 | + $request->setExternalUserId('another-user'); |
| 687 | + |
| 688 | + $response = $request->executeWithClient($this->getClient()); |
| 689 | + $result = $request->mapResponse($response); |
| 690 | + $this->deleteRequest->setVersion($result->getVersion()); |
| 691 | + |
| 692 | + $this->assertInstanceOf(Customer::class, $result); |
| 693 | + $this->assertInstanceOf(CreatedBy::class, $result->getCreatedBy()); |
| 694 | + $this->assertInstanceOf(LastModifiedBy::class, $result->getLastModifiedBy()); |
| 695 | + $this->assertSame('custom-external-user-id', $result->getCreatedBy()->getExternalUserId()); |
| 696 | + $this->assertSame('another-user', $result->getLastModifiedBy()->getExternalUserId()); |
| 697 | + } |
| 698 | + |
656 | 699 | public function localeProvider() |
657 | 700 | { |
658 | 701 | return [ |
|
0 commit comments