|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\Tests\paragraphs_editor\Traits; |
|
4
|
|
|
|
|
5
|
|
|
use Drupal\paragraphs_editor\EditorFieldValue\FieldValueManagerInterface; |
|
6
|
|
|
use Drupal\paragraphs_editor\EditorFieldValue\FieldValueWrapperInterface; |
|
7
|
|
|
use Prophecy\Argument; |
|
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
trait MockFieldValueManagerTrait { |
|
10
|
|
|
|
|
11
|
51 |
|
protected function fieldValueManagerDefaults() { |
|
12
|
|
|
return [ |
|
13
|
51 |
|
'paragraphs_fields' => [ |
|
14
|
|
|
'field_tabs', |
|
15
|
|
|
'field_content', |
|
16
|
|
|
], |
|
17
|
|
|
'paragraphs_editor_fields' => [ |
|
18
|
|
|
'field_content', |
|
19
|
|
|
], |
|
20
|
|
|
'wrapper_options' => [ |
|
21
|
|
|
], |
|
22
|
|
|
]; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
51 |
|
protected function createFieldValueManager(array $options = [], $return_prophecy = FALSE) { |
|
26
|
51 |
|
$options += $this->fieldValueManagerDefaults(); |
|
27
|
51 |
|
$prophecy = $this->prophesize(FieldValueManagerInterface::CLASS); |
|
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
$prophecy->getReferencedEntities(Argument::any())->will(function ($args, $prophecy) { |
|
30
|
2 |
|
return $args[0]->referencedEntities(); |
|
31
|
51 |
|
}); |
|
32
|
|
|
|
|
33
|
|
|
$prophecy->isParagraphsField(Argument::any())->will(function($args, $prophecy) use ($options) { |
|
34
|
1 |
|
return in_array($args[0]->getName(), $options['paragraphs_fields']); |
|
35
|
51 |
|
}); |
|
36
|
|
|
|
|
37
|
|
|
$prophecy->isParagraphsEditorField(Argument::any())->will(function($args, $prophecy) use ($options) { |
|
38
|
3 |
|
return in_array($args[0]->getName(), $options['paragraphs_editor_fields']); |
|
39
|
51 |
|
}); |
|
40
|
|
|
|
|
41
|
51 |
|
$prophecy_factory = $this; |
|
42
|
|
|
$prophecy->wrapItems(Argument::cetera())->will(function($args, $prophecy) use ($prophecy_factory, $options) { |
|
43
|
2 |
|
$uuid = $args[0]->getEntity()->uuid(); |
|
44
|
2 |
|
$field_id = $args[0]->getFieldDefinition()->id(); |
|
45
|
2 |
|
return $prophecy_factory->createFieldValueWrapper($options['wrapper_options'][$uuid][$field_id]); |
|
46
|
51 |
|
}); |
|
47
|
|
|
|
|
48
|
|
|
$prophecy->getElement(Argument::cetera())->will(function($args) use($options) { |
|
49
|
|
|
if (!empty($options[$args[0]])) { |
|
50
|
|
|
return $options[$args[0]]; |
|
51
|
|
|
} |
|
52
|
51 |
|
}); |
|
53
|
|
|
|
|
54
|
|
|
$prophecy->getElement(Argument::cetera())->will(function($args) use($options) { |
|
55
|
5 |
|
if (!empty($options['elements'][$args[0]])) { |
|
56
|
3 |
|
return $options['elements'][$args[0]]; |
|
57
|
|
|
} |
|
58
|
|
|
else { |
|
59
|
|
|
return [ |
|
60
|
2 |
|
'tag' => $args[0], |
|
61
|
|
|
'attributes' => [], |
|
62
|
2 |
|
'selector' => '.' . $args[0], |
|
63
|
2 |
|
'flag' => '_flag_' . $args[0], |
|
64
|
|
|
]; |
|
65
|
|
|
} |
|
66
|
51 |
|
}); |
|
67
|
|
|
|
|
68
|
|
|
$prophecy->getAttributeName(Argument::cetera())->will(function($args) use($options) { |
|
69
|
29 |
|
return 'data-' . trim($args[1], '<>'); |
|
70
|
51 |
|
}); |
|
71
|
|
|
|
|
72
|
|
|
$prophecy->getSelector(Argument::cetera())->will(function($args) use($options) { |
|
73
|
48 |
|
if (!empty($options['elements'][$args[0]]['selector'])) { |
|
74
|
48 |
|
return $options['elements'][$args[0]]['selector']; |
|
75
|
|
|
} |
|
76
|
|
|
else { |
|
77
|
|
|
return '.' . trim($args[0], '<>'); |
|
78
|
|
|
} |
|
79
|
51 |
|
}); |
|
80
|
|
|
|
|
81
|
51 |
|
return $return_prophecy ? $prophecy : $prophecy->reveal(); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
8 |
|
protected function createFieldValueWrapper(array $options = [], $return_prophecy = FALSE) { |
|
85
|
|
|
$options += [ |
|
86
|
8 |
|
'markup' => '', |
|
87
|
|
|
'format' => 'default_format', |
|
88
|
|
|
]; |
|
89
|
8 |
|
$prophecy = $this->prophesize(FieldValueWrapperInterface::CLASS); |
|
|
|
|
|
|
90
|
8 |
|
$prophecy->getFormat()->willReturn($options['format']); |
|
91
|
8 |
|
$prophecy->getMarkup()->willReturn($options['markup']); |
|
92
|
8 |
|
$prophecy->setReferencedEntities(Argument::cetera())->will(function ($args) use($options, $prophecy) { |
|
93
|
2 |
|
$prophecy->getReferencedEntities()->willReturn($args); |
|
94
|
8 |
|
}); |
|
95
|
8 |
|
return $return_prophecy ? $prophecy : $prophecy->reveal(); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths