|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\Tests\Driver\Kernel\Drupal8\Field; |
|
4
|
|
|
|
|
5
|
|
|
use Drupal\Tests\Driver\Kernel\Drupal8\Field\DriverFieldKernelTestBase; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Tests the driver's handling of text_with_summary fields. |
|
9
|
|
|
* |
|
10
|
|
|
* @group driver |
|
11
|
|
|
*/ |
|
12
|
|
|
class TextWithSummaryTest extends DriverFieldKernelTestBase |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Machine name of the field type being tested. |
|
17
|
|
|
* |
|
18
|
|
|
* @string |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $fieldType = 'text_with_summary'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Test single value with summary and main text. |
|
24
|
|
|
*/ |
|
25
|
|
|
public function testSummarySingle() |
|
26
|
|
|
{ |
|
27
|
|
|
$field = [[ |
|
28
|
|
|
'value' => $this->randomString(), |
|
29
|
|
|
'summary' => $this->randomString(), |
|
30
|
|
|
]]; |
|
31
|
|
|
$this->assertCreatedWithField($field); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Test multiple value with summary and main text. |
|
36
|
|
|
*/ |
|
37
|
|
View Code Duplication |
public function testSummaryMultiple() |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
$field = [ |
|
40
|
|
|
[ |
|
41
|
|
|
'value' => $this->randomString(), |
|
42
|
|
|
'summary' => $this->randomString(), |
|
43
|
|
|
], |
|
44
|
|
|
[ |
|
45
|
|
|
'value' => $this->randomString(), |
|
46
|
|
|
'summary' => $this->randomString(), |
|
47
|
|
|
], |
|
48
|
|
|
]; |
|
49
|
|
|
$this->assertCreatedWithField($field); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Test single value with no summary. |
|
54
|
|
|
*/ |
|
55
|
|
|
public function testNoSummarySingle() |
|
56
|
|
|
{ |
|
57
|
|
|
$field = [[ |
|
58
|
|
|
'value' => $this->randomString(), |
|
59
|
|
|
]]; |
|
60
|
|
|
$this->assertCreatedWithField($field); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Test multiple value with and without summary. |
|
65
|
|
|
*/ |
|
66
|
|
View Code Duplication |
public function testMixedMultiple() |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
|
$field = [ |
|
69
|
|
|
[ |
|
70
|
|
|
'value' => $this->randomString(), |
|
71
|
|
|
], |
|
72
|
|
|
[ |
|
73
|
|
|
'value' => $this->randomString(), |
|
74
|
|
|
'summary' => $this->randomString(), |
|
75
|
|
|
], |
|
76
|
|
|
]; |
|
77
|
|
|
$this->assertCreatedWithField($field); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.