Newer
Older
Alex Pott
committed
<?php
/**
* @file
* Contains \Drupal\options\Tests\OptionsFieldUnitTestBase.
*/
namespace Drupal\options\Tests;
use Drupal\field\Tests\FieldUnitTestBase;
/**
* Base class for Options module integration tests.
Alex Pott
committed
*/
abstract class OptionsFieldUnitTestBase extends FieldUnitTestBase {
Alex Pott
committed
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('options');
/**
* The field name used in the test.
*
* @var string
*/
protected $fieldName = 'test_options';
/**
* The field storage definition used to created the field storage.
Alex Pott
committed
*
* @var array
*/
protected $fieldStorageDefinition;
Alex Pott
committed
/**
* The list field storage used in the test.
Alex Pott
committed
*
* @var \Drupal\field\Entity\FieldStorageConfig
Alex Pott
committed
*/
protected $fieldStorage;
Alex Pott
committed
/**
* The list field used in the test.
Alex Pott
committed
*
* @var \Drupal\field\Entity\FieldConfig
Alex Pott
committed
*/
protected $field;
Alex Pott
committed
/**
* {@inheritdoc}
*/
Alex Pott
committed
protected function setUp() {
Alex Pott
committed
parent::setUp();
Angie Byron
committed
$this->installSchema('system', array('router'));
$this->container->get('router.builder')->rebuild();
Alex Pott
committed
$this->fieldStorageDefinition = array(
Alex Pott
committed
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
Alex Pott
committed
'type' => 'list_integer',
'cardinality' => 1,
'settings' => array(
'allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three'),
),
);
$this->fieldStorage = entity_create('field_storage_config', $this->fieldStorageDefinition);
$this->fieldStorage->save();
Alex Pott
committed
$this->field = entity_create('field_config', array(
'field_storage' => $this->fieldStorage,
Alex Pott
committed
'bundle' => 'entity_test',
$this->field->save();
Alex Pott
committed
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($this->fieldName, array(
'type' => 'options_buttons',
))
->save();