|
14 | 14 | use Scn\EvalancheSoapStruct\Struct\Mandator\MandatorInterface; |
15 | 15 | use stdClass; |
16 | 16 |
|
17 | | -/** |
18 | | - * Class MandatorClientTest |
19 | | - * |
20 | | - * @package Scn\EvalancheSoapApiConnector\Client\Mandator |
21 | | - */ |
22 | 17 | class MandatorClientTest extends TestCase |
23 | 18 | { |
24 | 19 | /** |
@@ -48,7 +43,12 @@ class MandatorClientTest extends TestCase |
48 | 43 |
|
49 | 44 | public function setUp(): void |
50 | 45 | { |
51 | | - $this->soapClient = $this->getWsdlMock(['getById', 'getList']); |
| 46 | + $this->soapClient = $this->getWsdlMock([ |
| 47 | + 'getById', |
| 48 | + 'getList', |
| 49 | + 'create', |
| 50 | + 'importScenario', |
| 51 | + ]); |
52 | 52 | $this->responseMapper = $this->getMockBuilder(ResponseMapperInterface::class)->getMock(); |
53 | 53 | $this->hydratorConfigFactory = $this->getMockBuilder(HydratorConfigFactoryInterface::class)->getMock(); |
54 | 54 | $this->extractor = $this->getMockBuilder(ExtractorInterface::class)->getMock(); |
@@ -124,4 +124,87 @@ public function testGetListCanReturnArrayOfMandatorInterface() |
124 | 124 | $this->subject->getList() |
125 | 125 | ); |
126 | 126 | } |
| 127 | + |
| 128 | + public function testCreateReturnsMandatorInstance(): void |
| 129 | + { |
| 130 | + $config = $this->getMockBuilder(HydratorConfigInterface::class)->getMock(); |
| 131 | + $object = $this->getMockBuilder(MandatorInterface::class)->getMock(); |
| 132 | + |
| 133 | + $result = new stdClass(); |
| 134 | + $result->createResult = $object; |
| 135 | + |
| 136 | + $name = 'some-name'; |
| 137 | + $demo_mode = true; |
| 138 | + $pricemodel_id = 123; |
| 139 | + $description = 'some-description'; |
| 140 | + $industry_type = 111; |
| 141 | + |
| 142 | + $this->hydratorConfigFactory->expects($this->once())->method('createMandatorConfig') |
| 143 | + ->willReturn($config); |
| 144 | + |
| 145 | + $this->soapClient |
| 146 | + ->expects($this->once()) |
| 147 | + ->method('create') |
| 148 | + ->with([ |
| 149 | + 'name' => $name, |
| 150 | + 'demo_mode' => $demo_mode, |
| 151 | + 'pricemodel_id' => $pricemodel_id, |
| 152 | + 'description' => $description, |
| 153 | + 'industry_type' => $industry_type, |
| 154 | + ]) |
| 155 | + ->willReturn($result); |
| 156 | + |
| 157 | + $this->responseMapper |
| 158 | + ->expects($this->once()) |
| 159 | + ->method('getObject') |
| 160 | + ->with($result, 'createResult', $config) |
| 161 | + ->willReturn($object); |
| 162 | + |
| 163 | + self::assertSame( |
| 164 | + $object, |
| 165 | + $this->subject->create( |
| 166 | + $name, |
| 167 | + $demo_mode, |
| 168 | + $pricemodel_id, |
| 169 | + $description, |
| 170 | + $industry_type |
| 171 | + ) |
| 172 | + ); |
| 173 | + } |
| 174 | + |
| 175 | + public function testImportScenarioImports(): void |
| 176 | + { |
| 177 | + $object = $this->getMockBuilder(MandatorInterface::class)->getMock(); |
| 178 | + |
| 179 | + $result = new stdClass(); |
| 180 | + $result->importScenarioResult = $object; |
| 181 | + |
| 182 | + $mandator_id = 666; |
| 183 | + $scenario_content = 'some-data'; |
| 184 | + $language_code = 'some-language'; |
| 185 | + |
| 186 | + $this->soapClient |
| 187 | + ->expects($this->once()) |
| 188 | + ->method('importScenario') |
| 189 | + ->with([ |
| 190 | + 'mandator_id' => $mandator_id, |
| 191 | + 'scenario_data' => $scenario_content, |
| 192 | + 'language_code' => $language_code, |
| 193 | + ]) |
| 194 | + ->willReturn($result); |
| 195 | + |
| 196 | + $this->responseMapper |
| 197 | + ->expects($this->once()) |
| 198 | + ->method('getBoolean') |
| 199 | + ->with($result, 'importScenarioResult') |
| 200 | + ->willReturn(true); |
| 201 | + |
| 202 | + self::assertTrue( |
| 203 | + $this->subject->importScenario( |
| 204 | + $mandator_id, |
| 205 | + $scenario_content, |
| 206 | + $language_code, |
| 207 | + ) |
| 208 | + ); |
| 209 | + } |
127 | 210 | } |
0 commit comments