Update360Test.php in Lightning Core 8.5
File
tests/src/Kernel/Update/Update360Test.php
View source
<?php
namespace Drupal\Tests\lightning_core\Kernel\Update;
use Drupal\field\Entity\FieldConfig;
use Drupal\KernelTests\KernelTestBase;
use Drupal\lightning_core\Update\Update360;
class Update360Test extends KernelTestBase {
protected static $modules = [
'field',
'lightning_core',
'system',
'user',
];
protected function setUp() : void {
parent::setUp();
$this
->installConfig('user');
$this
->installEntitySchema('user');
}
public function testUpdate() : void {
$this
->assertFalse($this->container
->get('module_handler')
->moduleExists('image'));
$this
->assertNull(FieldConfig::loadByName('user', 'user', 'user_picture'));
$this
->assertTrue($this
->getCompactDisplay()
->isNew());
Update360::create($this->container)
->enableUserPictures();
$this->container = $this->container
->get('kernel')
->getContainer();
$this
->assertTrue($this->container
->get('module_handler')
->moduleExists('image'));
$this
->assertInstanceOf(FieldConfig::class, FieldConfig::loadByName('user', 'user', 'user_picture'));
$display = $this
->getCompactDisplay();
$this
->assertFalse($display
->isNew());
$this
->assertIsArray($display
->getComponent('name'));
$this
->assertIsArray($display
->getComponent('user_picture'));
}
private function getCompactDisplay() {
return $this->container
->get('kernel')
->getContainer()
->get('entity_display.repository')
->getViewDisplay('user', 'user', 'compact');
}
}
Classes
Name |
Description |
Update360Test |
Tests optional updates targeting Lightning Core 3.6.0. |