Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreditmemoAddCommentTest.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  const SERVICE_READ_NAME = 'salesCreditmemoCommentRepositoryV1';
20 
24  const SERVICE_VERSION = 'V1';
25 
29  const CREDITMEMO_INCREMENT_ID = '100000001';
30 
34  protected $objectManager;
35 
41  protected function setUp()
42  {
44  }
45 
51  public function testCreditmemoAddComment()
52  {
54  $creditmemoCollection =
55  $this->objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection::class);
56  $creditmemo = $creditmemoCollection->getFirstItem();
57 
58  $commentData = [
59  Comment::COMMENT => 'Hello world!',
60  Comment::ENTITY_ID => null,
61  Comment::CREATED_AT => null,
62  Comment::PARENT_ID => $creditmemo->getId(),
63  Comment::IS_VISIBLE_ON_FRONT => 1,
64  Comment::IS_CUSTOMER_NOTIFIED => 1,
65  ];
66 
67  $requestData = ['entity' => $commentData];
68  $serviceInfo = [
69  'rest' => [
70  'resourcePath' => '/V1/creditmemo/' . $creditmemo->getId() . '/comments',
72  ],
73  'soap' => [
74  'service' => self::SERVICE_READ_NAME,
75  'serviceVersion' => self::SERVICE_VERSION,
76  'operation' => self::SERVICE_READ_NAME . 'save',
77  ],
78  ];
79 
80  $result = $this->_webApiCall($serviceInfo, $requestData);
81 
82  self::assertNotEmpty($result);
83  self::assertNotEmpty($result[Comment::ENTITY_ID]);
84  self::assertEquals($creditmemo->getId(), $result[Comment::PARENT_ID]);
85  }
86 }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)