View source
<?php
namespace Drupal\Tests\fontyourface\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class FontYourFaceFontDisplayTest 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);
\Drupal::service('theme_handler')
->install([
'bartik',
'seven',
]);
$this
->config('system.theme')
->set('default', 'bartik')
->set('admin', 'seven')
->save();
$this
->drupalGet(Url::fromRoute('font.settings'));
$this
->submitForm([
'load_all_enabled_fonts' => FALSE,
], 'Save configuration');
$this
->drupalGet(Url::fromRoute('font.settings'));
$this
->submitForm([], 'Import from websafe_fonts_test');
}
public function testFontNotDisplayed() {
$this
->drupalGet(url::fromRoute('entity.font.activate', [
'font' => 1,
'js' => 'nojs',
]));
$this
->resetAll();
$this
->drupalGet('/node');
$this
->assertNoRaw('<meta name="Websafe Font" content="Arial" />');
}
public function testFontDisplayedViaFontDisplayRule() {
$this
->drupalGet(url::fromRoute('entity.font.activate', [
'font' => 1,
'js' => 'nojs',
]));
$edit = [
'label' => 'Headers',
'id' => 'headers',
'font_url' => 'https://en.wikipedia.org/wiki/Arial',
'fallback' => '',
'preset_selectors' => '.fontyourface h1, .fontyourface h2, .fontyourface h3, .fontyourface h4, .fontyourface h5, .fontyourface h6',
'selectors' => '.fontyourface h1, .fontyourface h2, .fontyourface h3, .fontyourface h4, .fontyourface h5, .fontyourface h6',
'theme' => 'bartik',
];
$this
->drupalGet(Url::fromRoute('entity.font_display.add_form'));
$this
->submitForm($edit, 'Save');
$this
->drupalGet(Url::fromRoute('entity.font_display.collection'));
$this
->resetAll();
$this
->drupalGet('/node');
$this
->assertSession()
->responseContains('<meta name="Websafe Font" content="Arial" />');
$this
->assertSession()
->responseContains("fontyourface/font_display/headers.css");
}
}