BlazyAdminExtendedUnitTest.php in Blazy 8
File
tests/src/Unit/Form/BlazyAdminExtendedUnitTest.php
View source
<?php
namespace Drupal\Tests\blazy\Unit\Form;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\UnitTestCase;
use Drupal\Tests\blazy\Traits\BlazyUnitTestTrait;
use Drupal\Tests\blazy\Traits\BlazyManagerUnitTestTrait;
use Drupal\blazy\Dejavu\BlazyAdminExtended;
class BlazyAdminExtendedUnitTest extends UnitTestCase {
use BlazyUnitTestTrait;
use BlazyManagerUnitTestTrait;
protected $stringTranslation;
protected function setUp() {
parent::setUp();
$this
->setUpUnitServices();
$this
->setUpUnitContainer();
$this->stringTranslation = $this
->createMock('Drupal\\Core\\StringTranslation\\TranslationInterface');
$this->entityDisplayRepository = $this
->createMock('Drupal\\Core\\Entity\\EntityDisplayRepositoryInterface');
$this->typedConfig = $this
->createMock('Drupal\\Core\\Config\\TypedConfigManagerInterface');
$this->dateFormatter = $this
->getMockBuilder('Drupal\\Core\\Datetime\\DateFormatter')
->disableOriginalConstructor()
->getMock();
$container = new ContainerBuilder();
$container
->set('entity_display.repository', $this->entityDisplayRepository);
$container
->set('config.typed', $this->typedConfig);
$container
->set('string_translation', $this
->getStringTranslationStub());
$container
->set('date.formatter', $this->dateFormatter);
\Drupal::setContainer($container);
$this->blazyAdminExtended = new BlazyAdminExtended($this->entityDisplayRepository, $this->typedConfig, $this->blazyManager);
}
public function providerTestBuildSettingsForm() {
return [
[
FALSE,
FALSE,
],
[
TRUE,
TRUE,
],
[
TRUE,
FALSE,
],
[
FALSE,
TRUE,
],
];
}
public function testBuildSettingsForm($id, $vanilla) {
$form = [];
$definition = $this
->getDefaulEntityFormatterDefinition() + $this
->getDefaultFormatterDefinition();
$definition['settings'] += $this
->getDefaultFields(TRUE);
$definition['id'] = $id;
$definition['vanilla'] = $vanilla;
$definition['_views'] = TRUE;
$this->blazyAdminExtended
->openingForm($form, $definition);
$this
->assertEquals($vanilla, !empty($form['vanilla']));
$this->blazyAdminExtended
->fieldableForm($form, $definition);
$this
->assertEquals($id, !empty($form['id']));
$this->blazyAdminExtended
->closingForm($form, $definition);
$this
->assertArrayHasKey('closing', $form);
}
}
namespace Drupal\blazy\Form;
if (!function_exists('responsive_image_get_image_dimensions')) {
function responsive_image_get_image_dimensions() {
}
}