3 namespace Drupal\Tests\fontyourface\Functional;
6 use Drupal\simpletest\WebTestBase;
9 * Tests that font displays show css.
13 class FontYourFaceFontDisplayTest extends WebTestBase {
20 public static $modules = ['views', 'fontyourface', 'websafe_fonts_test'];
23 * A test user with permission to access the @font-your-face sections.
25 * @var \Drupal\user\UserInterface
32 protected function setUp() {
34 // Create and log in an administrative user.
35 $this->adminUser = $this->drupalCreateUser([
36 'administer font entities',
38 $this->drupalLogin($this->adminUser);
40 // Set up default themes.
41 \Drupal::service('theme_handler')->install(['bartik', 'seven']);
42 $this->config('system.theme')
43 ->set('default', 'bartik')
44 ->set('admin', 'seven')
48 $this->drupalPostForm(Url::fromRoute('font.settings'), ['load_all_enabled_fonts' => FALSE], t('Save configuration'));
49 $this->drupalPostForm(Url::fromRoute('font.settings'), [], t('Import from websafe_fonts_test'));
53 * Tests font not displayed even when Arial is loaded.
55 public function testFontNotDisplayed() {
56 $this->drupalGet(url::fromRoute('entity.font.activate', ['font' => 1, 'js' => 'nojs']));
58 // Assert no fonts load to start.
59 $this->drupalGet('/node');
60 $this->assertNoRaw('<meta name="Websafe Font" content="Arial" />');
64 * Tests font displayed once added in FontDisplay.
66 public function testFontDisplayedViaFontDisplayRule() {
67 $this->drupalGet(url::fromRoute('entity.font.activate', ['font' => 1, 'js' => 'nojs']));
72 'font_url' => 'https://en.wikipedia.org/wiki/Arial',
74 'preset_selectors' => '.fontyourface h1, .fontyourface h2, .fontyourface h3, .fontyourface h4, .fontyourface h5, .fontyourface h6',
75 'selectors' => '.fontyourface h1, .fontyourface h2, .fontyourface h3, .fontyourface h4, .fontyourface h5, .fontyourface h6',
78 $this->drupalPostForm(Url::fromRoute('entity.font_display.add_form'), $edit, 'Save');
79 $this->drupalGet(Url::fromRoute('entity.font_display.collection'));
82 // Assert Arial loads in general bartik section.
83 $this->drupalGet('/node');
84 $this->assertRaw('<meta name="Websafe Font" content="Arial" />');
85 $this->assertRaw("fontyourface/font_display/headers.css");