public function NodeTypePreviewImageFormTest::testGetFormWithDefaultStyle in Acquia Content Hub 8
Tests the getForm() method, already with default style.
@covers ::getForm
File
- tests/
src/ Unit/ Form/ NodeTypePreviewImageFormTest.php, line 121
Class
- NodeTypePreviewImageFormTest
- PHPUnit test for the NodeTypePreviewImageForm class.
Namespace
Drupal\Tests\acquia_contenthub\Unit\FormCode
public function testGetFormWithDefaultStyle() {
$preview_image_form = new NodeTypePreviewImageForm($this->contenthubEntityManager, $this->entityTypeManager, $this->entityFieldManager);
$preview_image_form
->setStringTranslation($this
->getStringTranslationStub());
$field_definitions = [
'field_description' => $this
->getFieldDefinition('description'),
'field_image' => $this
->getFieldDefinition('image'),
];
$this->entityFieldManager
->expects($this
->once())
->method('getFieldDefinitions')
->with('node', 'article')
->willReturn($field_definitions);
$image_style_options_return_value = [
'medium' => 'Medium',
NodeTypePreviewImageForm::PREVIEW_IMAGE_DEFAULT_KEY => 'Preview Image',
];
acquia_polyfill_controller_set_return('image_style_options', $image_style_options_return_value);
$form = $preview_image_form
->getForm('article');
$this
->assertEquals(2, count($form['style']['#options']));
$this
->assertEquals($image_style_options_return_value, $form['style']['#options']);
}