PreviewSettingsUpdateTest.php in Gatsby Live Preview & Incremental Builds 8
File
tests/src/Functional/PreviewSettingsUpdateTest.php
View source
<?php
namespace Drupal\Tests\gatsby\Functional;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\node\Entity\NodeType;
class PreviewSettingsUpdateTest extends UpdatePathTestBase {
protected $defaultTheme = 'stark';
protected $profile = 'minimal';
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../update/fixtures/minimal-9-2-update-3160476.php.gz',
];
}
public function testUpdatePath() {
$gatsby_settings = \Drupal::config('gatsby.settings');
$preview_settings = $gatsby_settings
->get('preview');
$target_settings = $gatsby_settings
->get('target');
$iframe_settings = $gatsby_settings
->get('iframe');
$this
->assertEquals([
'article' => 1,
'page' => 1,
], $preview_settings);
$this
->assertEquals([
'article' => 1,
'page' => 0,
], $iframe_settings);
$this
->assertEquals([
'article' => 'window',
'page' => 'sidebar',
], $target_settings);
$this
->assertEquals('https://example.com', $gatsby_settings
->get('server_url'));
$this
->assertEmpty($gatsby_settings
->get('preview_callback_url'));
$this
->runUpdates();
$gatsby_settings = \Drupal::config('gatsby.settings');
$this
->assertEmpty($gatsby_settings
->get('preview'));
$this
->assertEmpty($gatsby_settings
->get('target'));
$this
->assertEmpty($gatsby_settings
->get('iframe'));
$page = NodeType::load('page');
$this
->assertTrue($page
->getThirdPartySetting('gatsby', 'preview'));
$this
->assertEquals('sidebar', $page
->getThirdPartySetting('gatsby', 'target'));
$this
->assertFalse($page
->getThirdPartySetting('gatsby', 'iframe'));
$article = NodeType::load('article');
$this
->assertTrue($article
->getThirdPartySetting('gatsby', 'preview'));
$this
->assertEquals('window', $article
->getThirdPartySetting('gatsby', 'target'));
$this
->assertTrue($article
->getThirdPartySetting('gatsby', 'iframe'));
$this
->assertEquals('https://example.com/__refresh', $gatsby_settings
->get('preview_callback_url'));
}
}