Completed
Pull Request — master (#157)
by
unknown
01:50
created

StringTest::testStringMultiple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Drupal\Tests\Driver\Kernel\Drupal8\Field;
4
5
use Drupal\Tests\Driver\Kernel\Drupal8\Field\DriverFieldKernelTestBase;
6
use Drupal\entity_test\Entity\EntityTestBundle;
7
8
/**
9
 * Tests the driver's handling of string fields.
10
 *
11
 * @group driver
12
 */
13
class StringTest extends DriverFieldKernelTestBase
14
{
15
16
  /**
17
   * Machine name of the field type being tested.
18
   *
19
   * @string
20
   */
21
    protected $fieldType = 'string';
22
23
  /**
24
   * Test that an entity can be created with a single value in a string field.
25
   */
26
    public function testStringSingle()
27
    {
28
        $field = [$this->randomString()];
29
        $this->assertCreatedWithField($field);
30
    }
31
32
  /**
33
   * Test that an entity can be created with multiple values in a string field.
34
   */
35
    public function testStringMultiple()
36
    {
37
        $field = [$this->randomString(),$this->randomString()];
38
        $this->assertCreatedWithField($field);
39
    }
40
41
  /**
42
   * Test that an entity can be created with a single value in a string field.
43
   */
44
    public function testStringOnBundleField()
45
    {
46
        $this->installEntitySchema('entity_test_with_bundle');
47
        EntityTestBundle::create([
48
        'id' => 'test_bundle',
49
        'label' => 'Test label',
50
        'description' => 'Test description',
51
        ])->save();
52
        $field = [$this->randomString()];
53
        $entity = $this->createTestEntity($field, 'entity_test_with_bundle', 'test_bundle');
54
        $this->assertValidField($entity);
55
        $this->assertFieldValues($entity, $field);
56
    }
57
}
58