1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\ActivityContactBundle\Bundle\Tests\Unit\Api\Processor\Config; |
4
|
|
|
|
5
|
|
|
use Oro\Bundle\ApiBundle\Tests\Unit\Processor\Config\ConfigProcessorTestCase; |
6
|
|
|
use Oro\Bundle\EntityConfigBundle\Config\Config; |
7
|
|
|
use Oro\Bundle\EntityConfigBundle\Config\Id\EntityConfigId; |
8
|
|
|
use OroCRM\Bundle\ActivityContactBundle\Api\Processor\Config\UpdateActivityContactFields; |
9
|
|
|
use OroCRM\Bundle\ActivityContactBundle\EntityConfig\ActivityScope; |
10
|
|
|
|
11
|
|
|
class UpdateActivityContactFieldsTest extends ConfigProcessorTestCase |
12
|
|
|
{ |
13
|
|
|
/** @var \PHPUnit_Framework_MockObject_MockObject */ |
14
|
|
|
protected $doctrineHelper; |
15
|
|
|
|
16
|
|
|
/** @var \PHPUnit_Framework_MockObject_MockObject */ |
17
|
|
|
protected $configManager; |
18
|
|
|
|
19
|
|
|
/** @var \PHPUnit_Framework_MockObject_MockObject */ |
20
|
|
|
protected $activityContactProvider; |
21
|
|
|
|
22
|
|
|
/** @var UpdateActivityContactFields */ |
23
|
|
|
protected $processor; |
24
|
|
|
|
25
|
|
|
protected function setUp() |
26
|
|
|
{ |
27
|
|
|
parent::setUp(); |
28
|
|
|
|
29
|
|
|
$this->doctrineHelper = $this->getMockBuilder('Oro\Bundle\ApiBundle\Util\DoctrineHelper') |
30
|
|
|
->disableOriginalConstructor() |
31
|
|
|
->getMock(); |
32
|
|
|
$this->configManager = $this->getMockBuilder('Oro\Bundle\EntityConfigBundle\Config\ConfigManager') |
33
|
|
|
->disableOriginalConstructor() |
34
|
|
|
->getMock(); |
35
|
|
|
$this->activityContactProvider = $this |
36
|
|
|
->getMockBuilder('OroCRM\Bundle\ActivityContactBundle\Provider\ActivityContactProvider') |
37
|
|
|
->disableOriginalConstructor() |
38
|
|
|
->getMock(); |
39
|
|
|
|
40
|
|
|
$this->processor = new UpdateActivityContactFields( |
41
|
|
|
$this->doctrineHelper, |
42
|
|
|
$this->configManager, |
43
|
|
|
$this->activityContactProvider, |
44
|
|
|
['create', 'update'] |
|
|
|
|
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testProcessForNotCompletedConfig() |
49
|
|
|
{ |
50
|
|
|
$config = [ |
51
|
|
|
'exclusion_policy' => 'none', |
52
|
|
|
'fields' => [ |
53
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
54
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
55
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
56
|
|
|
ActivityScope::CONTACT_COUNT => null, |
57
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
58
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
59
|
|
|
] |
60
|
|
|
]; |
61
|
|
|
|
62
|
|
|
$this->configManager->expects($this->never()) |
63
|
|
|
->method('hasConfig'); |
64
|
|
|
|
65
|
|
|
$configObject = $this->createConfigObject($config); |
66
|
|
|
$this->context->setResult($configObject); |
67
|
|
|
$this->processor->process($this->context); |
68
|
|
|
|
69
|
|
|
$this->assertConfig( |
70
|
|
|
[ |
71
|
|
|
'fields' => [ |
72
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
73
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
74
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
75
|
|
|
ActivityScope::CONTACT_COUNT => null, |
76
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
77
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
78
|
|
|
] |
79
|
|
|
], |
80
|
|
|
$configObject |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function testProcessForNotManageableEntity() |
85
|
|
|
{ |
86
|
|
|
$config = [ |
87
|
|
|
'exclusion_policy' => 'all', |
88
|
|
|
'fields' => [ |
89
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
90
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
91
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
92
|
|
|
ActivityScope::CONTACT_COUNT => null, |
93
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
94
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
95
|
|
|
] |
96
|
|
|
]; |
97
|
|
|
|
98
|
|
|
$this->doctrineHelper->expects($this->once()) |
99
|
|
|
->method('isManageableEntityClass') |
100
|
|
|
->with(self::TEST_CLASS_NAME) |
101
|
|
|
->willReturn(false); |
102
|
|
|
|
103
|
|
|
$configObject = $this->createConfigObject($config); |
104
|
|
|
$this->context->setResult($configObject); |
105
|
|
|
$this->processor->process($this->context); |
106
|
|
|
|
107
|
|
|
$this->assertConfig( |
108
|
|
|
[ |
109
|
|
|
'exclusion_policy' => 'all', |
110
|
|
|
'fields' => [ |
111
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
112
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
113
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
114
|
|
|
ActivityScope::CONTACT_COUNT => null, |
115
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
116
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
117
|
|
|
] |
118
|
|
|
], |
119
|
|
|
$configObject |
120
|
|
|
); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function testProcessForNotConfigurableEntity() |
124
|
|
|
{ |
125
|
|
|
$config = [ |
126
|
|
|
'exclusion_policy' => 'all', |
127
|
|
|
'fields' => [ |
128
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
129
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
130
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
131
|
|
|
ActivityScope::CONTACT_COUNT => null, |
132
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
133
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
134
|
|
|
] |
135
|
|
|
]; |
136
|
|
|
|
137
|
|
|
$this->doctrineHelper->expects($this->once()) |
138
|
|
|
->method('isManageableEntityClass') |
139
|
|
|
->with(self::TEST_CLASS_NAME) |
140
|
|
|
->willReturn(true); |
141
|
|
|
|
142
|
|
|
$this->configManager->expects($this->once()) |
143
|
|
|
->method('hasConfig') |
144
|
|
|
->with(self::TEST_CLASS_NAME); |
145
|
|
|
$this->configManager->expects($this->never()) |
146
|
|
|
->method('getEntityConfig'); |
147
|
|
|
|
148
|
|
|
$configObject = $this->createConfigObject($config); |
149
|
|
|
$this->context->setResult($configObject); |
150
|
|
|
$this->processor->process($this->context); |
151
|
|
|
|
152
|
|
|
$this->assertConfig( |
153
|
|
|
[ |
154
|
|
|
'exclusion_policy' => 'all', |
155
|
|
|
'fields' => [ |
156
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
157
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
158
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
159
|
|
|
ActivityScope::CONTACT_COUNT => null, |
160
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
161
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
162
|
|
|
] |
163
|
|
|
], |
164
|
|
|
$configObject |
165
|
|
|
); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function testProcessForNotExtendableEntity() |
169
|
|
|
{ |
170
|
|
|
$config = [ |
171
|
|
|
'exclusion_policy' => 'all', |
172
|
|
|
'fields' => [ |
173
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
174
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
175
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
176
|
|
|
ActivityScope::CONTACT_COUNT => null, |
177
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
178
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
179
|
|
|
] |
180
|
|
|
]; |
181
|
|
|
|
182
|
|
|
$expendConfig = new Config(new EntityConfigId('extend', self::TEST_CLASS_NAME)); |
183
|
|
|
|
184
|
|
|
$this->doctrineHelper->expects($this->once()) |
185
|
|
|
->method('isManageableEntityClass') |
186
|
|
|
->with(self::TEST_CLASS_NAME) |
187
|
|
|
->willReturn(true); |
188
|
|
|
|
189
|
|
|
$this->configManager->expects($this->once()) |
190
|
|
|
->method('hasConfig') |
191
|
|
|
->with(self::TEST_CLASS_NAME) |
192
|
|
|
->willReturn(true); |
193
|
|
|
$this->configManager->expects($this->once()) |
194
|
|
|
->method('getEntityConfig') |
195
|
|
|
->with('extend', self::TEST_CLASS_NAME) |
196
|
|
|
->willReturn($expendConfig); |
197
|
|
|
|
198
|
|
|
$configObject = $this->createConfigObject($config); |
199
|
|
|
$this->context->setResult($configObject); |
200
|
|
|
$this->processor->process($this->context); |
201
|
|
|
|
202
|
|
|
$this->assertConfig( |
203
|
|
|
[ |
204
|
|
|
'exclusion_policy' => 'all', |
205
|
|
|
'fields' => [ |
206
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
207
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
208
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
209
|
|
|
ActivityScope::CONTACT_COUNT => null, |
210
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
211
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
212
|
|
|
] |
213
|
|
|
], |
214
|
|
|
$configObject |
215
|
|
|
); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
public function testProcessForEntityWithoutActivities() |
219
|
|
|
{ |
220
|
|
|
$config = [ |
221
|
|
|
'exclusion_policy' => 'all', |
222
|
|
|
'fields' => [ |
223
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
224
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
225
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
226
|
|
|
ActivityScope::CONTACT_COUNT => null, |
227
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
228
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
229
|
|
|
] |
230
|
|
|
]; |
231
|
|
|
|
232
|
|
|
$expendConfig = new Config(new EntityConfigId('extend', self::TEST_CLASS_NAME)); |
233
|
|
|
$expendConfig->set('is_extend', true); |
234
|
|
|
$activityConfig = new Config(new EntityConfigId('activity', self::TEST_CLASS_NAME)); |
235
|
|
|
|
236
|
|
|
$this->doctrineHelper->expects($this->once()) |
237
|
|
|
->method('isManageableEntityClass') |
238
|
|
|
->with(self::TEST_CLASS_NAME) |
239
|
|
|
->willReturn(true); |
240
|
|
|
|
241
|
|
|
$this->configManager->expects($this->once()) |
242
|
|
|
->method('hasConfig') |
243
|
|
|
->with(self::TEST_CLASS_NAME) |
244
|
|
|
->willReturn(true); |
245
|
|
|
$this->configManager->expects($this->exactly(2)) |
246
|
|
|
->method('getEntityConfig') |
247
|
|
|
->willReturnMap( |
248
|
|
|
[ |
249
|
|
|
['extend', self::TEST_CLASS_NAME, $expendConfig], |
250
|
|
|
['activity', self::TEST_CLASS_NAME, $activityConfig], |
251
|
|
|
] |
252
|
|
|
); |
253
|
|
|
|
254
|
|
|
$this->activityContactProvider->expects($this->never()) |
255
|
|
|
->method('getSupportedActivityClasses'); |
256
|
|
|
|
257
|
|
|
$configObject = $this->createConfigObject($config); |
258
|
|
|
$this->context->setResult($configObject); |
259
|
|
|
$this->processor->process($this->context); |
260
|
|
|
|
261
|
|
|
$this->assertConfig( |
262
|
|
|
[ |
263
|
|
|
'exclusion_policy' => 'all', |
264
|
|
|
'fields' => [ |
265
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
266
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
267
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
268
|
|
|
ActivityScope::CONTACT_COUNT => null, |
269
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
270
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
271
|
|
|
] |
272
|
|
|
], |
273
|
|
|
$configObject |
274
|
|
|
); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
public function testProcessForEntityWithoutSupportedActivities() |
278
|
|
|
{ |
279
|
|
|
$config = [ |
280
|
|
|
'exclusion_policy' => 'all', |
281
|
|
|
'fields' => [ |
282
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
283
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
284
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
285
|
|
|
ActivityScope::CONTACT_COUNT => null, |
286
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
287
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
288
|
|
|
] |
289
|
|
|
]; |
290
|
|
|
|
291
|
|
|
$expendConfig = new Config(new EntityConfigId('extend', self::TEST_CLASS_NAME)); |
292
|
|
|
$expendConfig->set('is_extend', true); |
293
|
|
|
$activityConfig = new Config(new EntityConfigId('activity', self::TEST_CLASS_NAME)); |
294
|
|
|
$activityConfig->set('activities', ['Test\Activity1']); |
295
|
|
|
|
296
|
|
|
$this->doctrineHelper->expects($this->once()) |
297
|
|
|
->method('isManageableEntityClass') |
298
|
|
|
->with(self::TEST_CLASS_NAME) |
299
|
|
|
->willReturn(true); |
300
|
|
|
|
301
|
|
|
$this->configManager->expects($this->once()) |
302
|
|
|
->method('hasConfig') |
303
|
|
|
->with(self::TEST_CLASS_NAME) |
304
|
|
|
->willReturn(true); |
305
|
|
|
$this->configManager->expects($this->exactly(2)) |
306
|
|
|
->method('getEntityConfig') |
307
|
|
|
->willReturnMap( |
308
|
|
|
[ |
309
|
|
|
['extend', self::TEST_CLASS_NAME, $expendConfig], |
310
|
|
|
['activity', self::TEST_CLASS_NAME, $activityConfig], |
311
|
|
|
] |
312
|
|
|
); |
313
|
|
|
|
314
|
|
|
$this->activityContactProvider->expects($this->once()) |
315
|
|
|
->method('getSupportedActivityClasses') |
316
|
|
|
->willReturn(['Test\Activity2']); |
317
|
|
|
|
318
|
|
|
$configObject = $this->createConfigObject($config); |
319
|
|
|
$this->context->setResult($configObject); |
320
|
|
|
$this->processor->process($this->context); |
321
|
|
|
|
322
|
|
|
$this->assertConfig( |
323
|
|
|
[ |
324
|
|
|
'exclusion_policy' => 'all', |
325
|
|
|
'fields' => [ |
326
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
327
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
328
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
329
|
|
|
ActivityScope::CONTACT_COUNT => null, |
330
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
331
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
332
|
|
|
] |
333
|
|
|
], |
334
|
|
|
$configObject |
335
|
|
|
); |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
public function testProcessForEntityWithSupportedActivities() |
339
|
|
|
{ |
340
|
|
|
$config = [ |
341
|
|
|
'exclusion_policy' => 'all', |
342
|
|
|
'fields' => [ |
343
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
344
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => null, |
345
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => null, |
346
|
|
|
ActivityScope::CONTACT_COUNT => null, |
347
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
348
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
349
|
|
|
] |
350
|
|
|
]; |
351
|
|
|
|
352
|
|
|
$expendConfig = new Config(new EntityConfigId('extend', self::TEST_CLASS_NAME)); |
353
|
|
|
$expendConfig->set('is_extend', true); |
354
|
|
|
$activityConfig = new Config(new EntityConfigId('activity', self::TEST_CLASS_NAME)); |
355
|
|
|
$activityConfig->set('activities', ['Test\Activity1', 'Test\Activity2']); |
356
|
|
|
|
357
|
|
|
$this->doctrineHelper->expects($this->once()) |
358
|
|
|
->method('isManageableEntityClass') |
359
|
|
|
->with(self::TEST_CLASS_NAME) |
360
|
|
|
->willReturn(true); |
361
|
|
|
|
362
|
|
|
$this->configManager->expects($this->once()) |
363
|
|
|
->method('hasConfig') |
364
|
|
|
->with(self::TEST_CLASS_NAME) |
365
|
|
|
->willReturn(true); |
366
|
|
|
$this->configManager->expects($this->exactly(2)) |
367
|
|
|
->method('getEntityConfig') |
368
|
|
|
->willReturnMap( |
369
|
|
|
[ |
370
|
|
|
['extend', self::TEST_CLASS_NAME, $expendConfig], |
371
|
|
|
['activity', self::TEST_CLASS_NAME, $activityConfig], |
372
|
|
|
] |
373
|
|
|
); |
374
|
|
|
|
375
|
|
|
$this->activityContactProvider->expects($this->once()) |
376
|
|
|
->method('getSupportedActivityClasses') |
377
|
|
|
->willReturn(['Test\Activity2']); |
378
|
|
|
|
379
|
|
|
$configObject = $this->createConfigObject($config); |
380
|
|
|
$this->context->setResult($configObject); |
381
|
|
|
$this->processor->process($this->context); |
382
|
|
|
|
383
|
|
|
$this->assertConfig( |
384
|
|
|
[ |
385
|
|
|
'exclusion_policy' => 'all', |
386
|
|
|
'fields' => [ |
387
|
|
|
'lastContactedDate' => ['property_path' => ActivityScope::LAST_CONTACT_DATE], |
388
|
|
|
'lastContactedDateIn' => ['property_path' => ActivityScope::LAST_CONTACT_DATE_IN], |
389
|
|
|
'lastContactedDateOut' => ['property_path' => ActivityScope::LAST_CONTACT_DATE_OUT], |
390
|
|
|
'timesContacted' => ['property_path' => ActivityScope::CONTACT_COUNT], |
391
|
|
|
'timesContactedIn' => ['property_path' => ActivityScope::CONTACT_COUNT_IN], |
392
|
|
|
'timesContactedOut' => ['property_path' => ActivityScope::CONTACT_COUNT_OUT], |
393
|
|
|
] |
394
|
|
|
], |
395
|
|
|
$configObject |
396
|
|
|
); |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
public function testProcessForUpdateAction() |
400
|
|
|
{ |
401
|
|
|
$config = [ |
402
|
|
|
'exclusion_policy' => 'all', |
403
|
|
|
'fields' => [ |
404
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
405
|
|
|
ActivityScope::LAST_CONTACT_DATE_IN => [ |
406
|
|
|
'exclude' => true |
407
|
|
|
], |
408
|
|
|
ActivityScope::LAST_CONTACT_DATE_OUT => [ |
409
|
|
|
'exclude' => false |
410
|
|
|
], |
411
|
|
|
ActivityScope::CONTACT_COUNT => null, |
412
|
|
|
ActivityScope::CONTACT_COUNT_IN => null, |
413
|
|
|
ActivityScope::CONTACT_COUNT_OUT => null, |
414
|
|
|
] |
415
|
|
|
]; |
416
|
|
|
|
417
|
|
|
$expendConfig = new Config(new EntityConfigId('extend', self::TEST_CLASS_NAME)); |
418
|
|
|
$expendConfig->set('is_extend', true); |
419
|
|
|
$activityConfig = new Config(new EntityConfigId('activity', self::TEST_CLASS_NAME)); |
420
|
|
|
$activityConfig->set('activities', ['Test\Activity1', 'Test\Activity2']); |
421
|
|
|
|
422
|
|
|
$this->doctrineHelper->expects($this->once()) |
423
|
|
|
->method('isManageableEntityClass') |
424
|
|
|
->with(self::TEST_CLASS_NAME) |
425
|
|
|
->willReturn(true); |
426
|
|
|
|
427
|
|
|
$this->configManager->expects($this->once()) |
428
|
|
|
->method('hasConfig') |
429
|
|
|
->with(self::TEST_CLASS_NAME) |
430
|
|
|
->willReturn(true); |
431
|
|
|
$this->configManager->expects($this->exactly(2)) |
432
|
|
|
->method('getEntityConfig') |
433
|
|
|
->willReturnMap( |
434
|
|
|
[ |
435
|
|
|
['extend', self::TEST_CLASS_NAME, $expendConfig], |
436
|
|
|
['activity', self::TEST_CLASS_NAME, $activityConfig], |
437
|
|
|
] |
438
|
|
|
); |
439
|
|
|
|
440
|
|
|
$this->activityContactProvider->expects($this->once()) |
441
|
|
|
->method('getSupportedActivityClasses') |
442
|
|
|
->willReturn(['Test\Activity2']); |
443
|
|
|
|
444
|
|
|
$configObject = $this->createConfigObject($config); |
445
|
|
|
$this->context->setResult($configObject); |
446
|
|
|
$this->context->setTargetAction('update'); |
447
|
|
|
$this->processor->process($this->context); |
448
|
|
|
|
449
|
|
|
$this->assertConfig( |
450
|
|
|
[ |
451
|
|
|
'exclusion_policy' => 'all', |
452
|
|
|
'fields' => [ |
453
|
|
|
'lastContactedDate' => [ |
454
|
|
|
'exclude' => true, |
455
|
|
|
'property_path' => ActivityScope::LAST_CONTACT_DATE |
456
|
|
|
], |
457
|
|
|
'lastContactedDateIn' => [ |
458
|
|
|
'exclude' => true, |
459
|
|
|
'property_path' => ActivityScope::LAST_CONTACT_DATE_IN |
460
|
|
|
], |
461
|
|
|
'lastContactedDateOut' => [ |
462
|
|
|
'property_path' => ActivityScope::LAST_CONTACT_DATE_OUT |
463
|
|
|
], |
464
|
|
|
'timesContacted' => [ |
465
|
|
|
'exclude' => true, |
466
|
|
|
'property_path' => ActivityScope::CONTACT_COUNT |
467
|
|
|
], |
468
|
|
|
'timesContactedIn' => [ |
469
|
|
|
'exclude' => true, |
470
|
|
|
'property_path' => ActivityScope::CONTACT_COUNT_IN |
471
|
|
|
], |
472
|
|
|
'timesContactedOut' => [ |
473
|
|
|
'exclude' => true, |
474
|
|
|
'property_path' => ActivityScope::CONTACT_COUNT_OUT |
475
|
|
|
], |
476
|
|
|
] |
477
|
|
|
], |
478
|
|
|
$configObject |
479
|
|
|
); |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
public function testProcessForEntityWithSupportedActivitiesAndHasConflicts() |
483
|
|
|
{ |
484
|
|
|
$config = [ |
485
|
|
|
'exclusion_policy' => 'all', |
486
|
|
|
'fields' => [ |
487
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
488
|
|
|
'lastContactedDate' => null, |
489
|
|
|
ActivityScope::CONTACT_COUNT => ['property_path' => 'field1'], |
490
|
|
|
] |
491
|
|
|
]; |
492
|
|
|
|
493
|
|
|
$expendConfig = new Config(new EntityConfigId('extend', self::TEST_CLASS_NAME)); |
494
|
|
|
$expendConfig->set('is_extend', true); |
495
|
|
|
$activityConfig = new Config(new EntityConfigId('activity', self::TEST_CLASS_NAME)); |
496
|
|
|
$activityConfig->set('activities', ['Test\Activity1', 'Test\Activity2']); |
497
|
|
|
|
498
|
|
|
$this->doctrineHelper->expects($this->once()) |
499
|
|
|
->method('isManageableEntityClass') |
500
|
|
|
->with(self::TEST_CLASS_NAME) |
501
|
|
|
->willReturn(true); |
502
|
|
|
|
503
|
|
|
$this->configManager->expects($this->once()) |
504
|
|
|
->method('hasConfig') |
505
|
|
|
->with(self::TEST_CLASS_NAME) |
506
|
|
|
->willReturn(true); |
507
|
|
|
$this->configManager->expects($this->exactly(2)) |
508
|
|
|
->method('getEntityConfig') |
509
|
|
|
->willReturnMap( |
510
|
|
|
[ |
511
|
|
|
['extend', self::TEST_CLASS_NAME, $expendConfig], |
512
|
|
|
['activity', self::TEST_CLASS_NAME, $activityConfig], |
513
|
|
|
] |
514
|
|
|
); |
515
|
|
|
|
516
|
|
|
$this->activityContactProvider->expects($this->once()) |
517
|
|
|
->method('getSupportedActivityClasses') |
518
|
|
|
->willReturn(['Test\Activity2']); |
519
|
|
|
|
520
|
|
|
$configObject = $this->createConfigObject($config); |
521
|
|
|
$this->context->setResult($configObject); |
522
|
|
|
$this->processor->process($this->context); |
523
|
|
|
|
524
|
|
|
$this->assertConfig( |
525
|
|
|
[ |
526
|
|
|
'exclusion_policy' => 'all', |
527
|
|
|
'fields' => [ |
528
|
|
|
ActivityScope::LAST_CONTACT_DATE => null, |
529
|
|
|
'lastContactedDate' => null, |
530
|
|
|
ActivityScope::CONTACT_COUNT => ['property_path' => 'field1'], |
531
|
|
|
] |
532
|
|
|
], |
533
|
|
|
$configObject |
534
|
|
|
); |
535
|
|
|
} |
536
|
|
|
} |
537
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: