adminUser = $this->drupalCreateUser([
'administer font entities',
]);
$this->drupalLogin($this->adminUser);
}
/**
* Tests @font-your-face install and admin page shows up.
*/
public function testFontYourFaceSections() {
// Font settings page.
$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->assertRaw(t('Import from websafe_fonts_test'));
}
/**
* Tests importing fonts from websafe_fonts_test.
*/
public function testImportWebSafeFonts() {
// Assert no fonts exist to start.
$this->drupalGet(Url::fromRoute('entity.font.collection'));
$this->assertNoText('Arial');
$this->drupalPostForm(Url::fromRoute('font.settings'), [], t('Import from websafe_fonts_test'));
$this->assertResponse(200);
$this->assertText(t('Finished importing fonts.'));
// Assert all fonts were imported.
$this->drupalGet(Url::fromRoute('entity.font.collection'));
$this->assertText('Arial');
$this->assertText('Verdana');
$this->assertText('Courier New');
$this->assertText('Georgia');
// Assert fonts load on font collection page.
$this->assertRaw('');
$this->assertRaw('');
$this->assertRaw('');
$this->assertRaw('');
// ENsure font is not loaded on front page because font is not enabled.
$this->drupalGet('');
$this->assertNoRaw('');
}
/**
* Tests enabling and seeing fonts load.
*/
public function testEnableWebSafeFonts() {
// Assert no fonts load to start.
$this->drupalGet('/node');
$this->assertNoRaw('');
$this->drupalPostForm(Url::fromRoute('font.settings'), ['load_all_enabled_fonts' => 1], t('Import from websafe_fonts_test'));
$this->drupalGet(url::fromRoute('entity.font.activate', ['font' => 1, 'js' => 'nojs']));
$this->assertText('Font Arial successfully enabled');
// Flush the caches. Not an issue in prod but seems to be in simpletest. Will keep an eye on it.
$this->resetAll();
$this->drupalGet('/node');
$this->assertRaw('');
}
}