EntityExportTest.php in Bibliography & Citation 2.0.x
File
modules/bibcite_export/tests/src/Functional/EntityExportTest.php
View source
<?php
namespace Drupal\Tests\bibcite_export\Functional;
use Drupal\Tests\BrowserTestBase;
use Symfony\Component\Yaml\Yaml;
class EntityExportTest extends BrowserTestBase {
public static $modules = [
'bibcite_export_test',
];
protected $defaultTheme = 'stable';
protected $user;
public function setUp() {
parent::setUp();
$this->user = $this
->drupalCreateUser([
'view bibcite_reference',
'access bibcite export',
'administer bibcite',
]);
}
public function testExportUrl($id, $format, $expected_result) {
$this
->drupalLogin($this->user);
$text = $this
->drupalGet(sprintf('bibcite/export/%s/bibcite_reference/%s', $format, $id));
$this
->assertEquals(trim($expected_result), trim($text));
}
public function testExportLinks($id, $format, $expected_result) {
$this
->drupalLogin($this->user);
$this
->drupalGet(sprintf('bibcite/reference/%s', $id));
$page = $this
->getSession()
->getPage();
$link = $page
->findLink('BibTeX');
$link
->click();
$content = $page
->getContent();
$this
->assertEquals(trim($expected_result), trim($content));
}
public function testExportAll($id, $format) {
$this
->drupalLogin($this->user);
$this
->drupalGet('admin/content/bibcite/reference/export');
$page = $this
->getSession()
->getPage();
$page
->selectFieldOption('edit-format', $format);
$page
->pressButton('edit-submit');
$this
->assertSession()
->statusCodeEquals(200);
}
public function exportDataProvider() {
$yaml_text = file_get_contents(__DIR__ . '/data/testExportUrl.data.yml');
return Yaml::parse($yaml_text);
}
}