You are here

public function FreelinkingTest::testFreelinkingPlugins in Freelinking 7.3

Same name and namespace in other branches
  1. 6.3 freelinking.test \FreelinkingTest::testFreelinkingPlugins()

Tests all plugins except *file* (there is no file to test against) and *search* (works locally but not in the repo).

File

./freelinking.test, line 85
Unit tests for the freelinking Module.

Class

FreelinkingTest
@file Unit tests for the freelinking Module.

Code

public function testFreelinkingPlugins() {
  variable_set('freelinking_nodetitle_linkcontenttype', array(
    'page' => 'page',
  ));

  // Create node that will contain a sample of each plugin
  $edit = array();
  $edit['title'] = t('Testing all freelinking plugins');
  $edit['body[und][0][value]'] = '<ul>' . '  <li>Default plugin (nodetitle):  [[First page]]</li>' . '  <li>Nodetitle:      [[nodetitle:Second page]]</li>' . '  <li>Nid:            [[nid:2]]</li>' . '  <li>User:           [[u:' . $this->privileged_user->uid . ']]</li>' . '  <li>Search:         [[search:test]]</li>' . '  <li>Drupalproject:  [[drupalproject:freelinking]]</li>' . '  <li>Drupalorg:      [[drupalorg:2178561]]</li>' . '  <li>Google:         [[google:drupal]]</li>' . '  <li>Wikipedia:      [[wikipedia:Main_Page]]</li>' . '  <li>Wikiquote:      [[wikiquote:Main Page]]</li>' . '  <li>Wiktionary:     [[wiktionary:Main Page]]</li>' . '  <li>Wikinews:       [[wikinews:Main Page]]</li>' . '  <li>Wikisource:     [[wikisource:Main Page]]</li>' . '  <li>Wikibooks:      [[wikibooks:Main Page]]</li>' . '</ul>' . '<p>Testing compatibility with other modules</p>' . '<ul>' . '  <li>Respects [[drupalproject:media]] tags, such as:' . '  [[{"type":"media","view_mode":"media_large","fid":"286","attributes":{"alt":"","class":"media-image","typeof":"foaf:Image"}}]]</li>' . '</ul>';
  $this
    ->drupalPost('node/add/page', $edit, t('Save'));

  // Look at the links that are generated.

  //$pagecontent = $this->drupalGetContent();

  //debug($pagecontent);
  $this
    ->assertText(t('Basic page @title has been created.', array(
    '@title' => $edit['title'],
  )));

  // Verify each freelink plugin
  $this
    ->assertLink(t('First page'), 0, t('Generate default plugin (nodetitle) freelink.'));
  $this
    ->assertLink(t('Second page'), 0, t('Generate Nodetitle freelink.'));
  $this
    ->assertLink(t('Second page'), 0, t('Generate Nid freelink.'));
  $this
    ->assertLink($this->privileged_user->name, 0, t('Generate User freelink.'));

  //$this->assertLinkByHref('/search/node/test', 0, t('Generate Search freelink.'));
  $this
    ->assertLinkByHref('https://www.drupal.org/project/freelinking', 0, t('Generate Drupalproject freelink.'));
  $this
    ->assertLinkByHref('https://www.drupal.org/node/2178561', 0, t('Generate Drupalorg freelink.'));
  $this
    ->assertLinkByHref('http://www.google.com/search?q=drupal&hl=en', 0, t('Generate Google freelink.'));
  $this
    ->assertLinkByHref('http://en.wikipedia.org/wiki/Main_Page', 0, t('Generate Wikipedia freelink.'));
  $this
    ->assertLinkByHref('http://en.wikisource.org/wiki/Main_Page', 0, t('Generate Wikisource freelink.'));
  $this
    ->assertLinkByHref('http://en.wiktionary.org/wiki/Main_Page', 0, t('Generate Wiktionary freelink.'));
  $this
    ->assertLinkByHref('http://en.wikiquote.org/wiki/Main_Page', 0, t('Generate Wikiquote freelink.'));
  $this
    ->assertLinkByHref('http://en.wikibooks.org/wiki/Main_Page', 0, t('Generate Wikibooks freelink.'));
  $this
    ->assertLinkByHref('http://en.wikinews.org/wiki/Main_Page', 0, t('Generate Wikinews freelink.'));
  $this
    ->pass(t('Verifying compatibility with other modules...'));
  if (module_exists('media')) {
    $this
      ->assertNoPattern(t('/Plugin .* Not Found/'), t('Media tag was not parsed by freelinking module.'));
  }
  else {
    $this
      ->pass(t('Media module is not installed: ignoring.'));
  }
}