You are here

protected function FocalPointFieldWidgetTest::setUp in Focal Point 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/FieldWidgets/FocalPointFieldWidgetTest.php, line 39

Class

FocalPointFieldWidgetTest
@coversDefaultClass \Drupal\focal_point\Plugin\Field\FieldWidget\FocalPointImageWidget

Namespace

Drupal\Tests\focal_point\Unit\FieldWidgets

Code

protected function setUp() {
  parent::setUp();

  // Create some mock objects.
  $entity_type_manager = $this
    ->prophesize(EntityTypeManager::class)
    ->reveal();
  $focal_point_manager = new FocalPointManager($entity_type_manager);

  // Create and set the mock container.
  $container = $this
    ->prophesize(ContainerInterface::class);
  $container
    ->get('entity_type.manager')
    ->willReturn($entity_type_manager);
  $container
    ->get('focal_point.manager')
    ->willReturn($focal_point_manager);
  \Drupal::setContainer($container
    ->reveal());

  // Setup an image element for testing.
  $this->testElement = [
    '#title' => 'some title',
    '#parents' => [
      'field_image',
    ],
  ];

  // Setup a mock form state object for testing.
  // @todo: Figure out why using prophesize for this mock causes an exception.
  $this->testFormState = $this
    ->getMockBuilder('\\Drupal\\Core\\Form\\FormStateInterface')
    ->disableOriginalConstructor()
    ->getMock();
}