1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Webapi\Routing;
use Magento\TestModule5\Service\V1\Entity\AllSoapAndRest;
class GettersTest extends \Magento\Webapi\Routing\BaseService
{
/**
* @var string
*/
protected $_version;
/**
* @var string
*/
protected $_restResourcePath;
/**
* @var string
*/
protected $_soapService = 'testModule5AllSoapAndRest';
protected function setUp()
{
$this->_version = 'V1';
$this->_soapService = "testModule5AllSoapAndRest{$this->_version}";
$this->_restResourcePath = "/{$this->_version}/TestModule5/";
}
public function testGetters()
{
$itemId = 1;
$serviceInfo = [
'rest' => [
'resourcePath' => $this->_restResourcePath . $itemId,
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
],
'soap' => [
'service' => $this->_soapService,
'operation' => $this->_soapService . 'Item',
],
];
$requestData = [AllSoapAndRest::ID => $itemId];
$item = $this->_webApiCall($serviceInfo, $requestData);
$this->assertEquals($itemId, $item[AllSoapAndRest::ID], 'Item was retrieved unsuccessfully');
$isEnabled = isset($item[AllSoapAndRest::ENABLED]) && $item[AllSoapAndRest::ENABLED] === true;
$this->assertTrue($isEnabled, 'Getter with "is" prefix is processed incorrectly.');
$hasOrder = isset($item[AllSoapAndRest::HAS_ORDERS]) && $item[AllSoapAndRest::HAS_ORDERS] === true;
$this->assertTrue($hasOrder, 'Getter with "has" prefix is processed incorrectly.');
}
}