FontYourFaceSubmoduleInstallTest.php in @font-your-face 8.3
File
tests/src/Functional/FontYourFaceSubmoduleInstallTest.php
View source
<?php
namespace Drupal\Tests\fontyourface\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class FontYourFaceSubmoduleInstallTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'views',
'fontyourface',
'websafe_fonts_test',
];
protected $adminUser;
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'administer font entities',
]);
$this
->drupalLogin($this->adminUser);
}
public function testFontYourFaceSections() {
$this
->drupalGet(Url::fromRoute('font.settings'));
$this
->assertText(t('Settings form for @font-your-face. Support modules can use this form for settings or to import fonts.'));
$this
->assertSession()
->responseContains(t('Import from websafe_fonts_test'));
}
public function testImportWebSafeFonts() {
$this
->drupalGet(Url::fromRoute('entity.font.collection'));
$this
->assertNoText('Arial');
$this
->drupalGet(Url::fromRoute('font.settings'));
$this
->submitForm([], 'Import from websafe_fonts_test');
$this
->assertResponse(200);
$this
->assertText(t('Finished importing fonts.'));
$this
->drupalGet(Url::fromRoute('entity.font.collection'));
$this
->assertText('Arial');
$this
->assertText('Verdana');
$this
->assertText('Courier New');
$this
->assertText('Georgia');
$this
->assertSession()
->responseContains('<meta name="Websafe Font" content="Arial" />');
$this
->assertSession()
->responseContains('<meta name="Websafe Font" content="Courier New" />');
$this
->assertSession()
->responseContains('<meta name="Websafe Font" content="Georgia" />');
$this
->assertSession()
->responseContains('<meta name="Websafe Font" content="Verdana" />');
$this
->drupalGet('<front>');
$this
->assertNoRaw('<meta name="Websafe Font" content="Arial" />');
}
public function testEnableWebSafeFonts() {
$this
->drupalGet('/node');
$this
->assertNoRaw('<meta name="Websafe Font" content="Arial" />');
$this
->drupalGet(Url::fromRoute('font.settings'));
$this
->submitForm([
'load_all_enabled_fonts' => 1,
], 'Import from websafe_fonts_test');
$this
->drupalGet(url::fromRoute('entity.font.activate', [
'font' => 1,
'js' => 'nojs',
]));
$this
->assertText('Font Arial successfully enabled');
$this
->resetAll();
$this
->drupalGet('/node');
$this
->assertSession()
->responseContains('<meta name="Websafe Font" content="Arial" />');
}
}