EntityBrowserUpdateHookTest.php in Entity Browser 8.2
File
tests/src/Functional/EntityBrowserUpdateHookTest.php
View source
<?php
namespace Drupal\Tests\entity_browser\Functional;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class EntityBrowserUpdateHookTest extends UpdatePathTestBase {
protected $defaultTheme = 'stark';
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz',
__DIR__ . '/../../fixtures/update/entity_browser.update-hook-test.php',
];
}
protected function setUp() {
parent::setUp();
$entity_browser_type = $this->container
->get('entity_type.manager')
->getDefinition('entity_browser');
$this->container
->get('entity.last_installed_schema.repository')
->setLastInstalledDefinition($entity_browser_type);
}
protected function doSelectionTest() {
parent::doSelectionTest();
$this
->assertSession()
->responseContains('8001 - Updates submit text for existing Entity browsers.');
$this
->assertSession()
->responseContains('8002 - Migrates duplicated Views entity_browser_select fields.');
}
public function testSubmitTextUpdate() {
$this
->runUpdates();
$browser = $this->container
->get('config.factory')
->get('entity_browser.browser.test_update');
$this
->assertNull($browser
->get('submit_text'), 'Old submit text is gone');
$this
->assertEquals('All animals are created equal', $browser
->get('widgets.a4ad947c-9669-497c-9988-24351955a02f.settings.submit_text'), 'New submit text appears on the widget.');
}
public function testViewsFieldUpdate() {
$this
->runUpdates();
$view = $this->container
->get('config.factory')
->get('views.view.test_deprecated_field');
$this
->assertEquals('node', $view
->get('display.default.display_options.fields.entity_browser_select.table'), 'Data table in "entity_browser_select" replaced with data field.');
}
}