Skip to content
Snippets Groups Projects
Verified Commit 98093bef authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2864035 by alexpott, nlisgo, mpdonadio, vaplas, GoZ, naveenvalecha,...

Issue #2864035 by alexpott, nlisgo, mpdonadio, vaplas, GoZ, naveenvalecha, dawehner, Lendude: Convert web tests to browser tests for rdf module
parent 64640c24
No related branches found
No related tags found
No related merge requests found
Showing
with 48 additions and 62 deletions
......@@ -7,6 +7,7 @@
use Drupal\file\FileInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\file\Entity\File;
use Drupal\Tests\TestFileCreationTrait;
/**
* Provides methods specifically for testing File module's field handling.
......@@ -14,6 +15,9 @@
abstract class FileFieldTestBase extends BrowserTestBase {
use FileFieldCreationTrait;
use TestFileCreationTrait {
getTestFiles as drupalGetTestFiles;
}
/**
* Modules to enable.
......@@ -156,7 +160,7 @@ public function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_re
$edit[$name][] = $file_path;
}
}
$this->drupalPostForm("node/$nid/edit", $edit, t('Save and keep published'));
$this->drupalPostForm("node/$nid/edit", $edit, t('Save'));
return $nid;
}
......@@ -172,7 +176,7 @@ public function removeNodeFile($nid, $new_revision = TRUE) {
];
$this->drupalPostForm('node/' . $nid . '/edit', [], t('Remove'));
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
$this->drupalPostForm(NULL, $edit, t('Save'));
}
/**
......@@ -185,7 +189,7 @@ public function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE)
];
$this->drupalPostForm('node/' . $nid . '/edit', [], t('Remove'));
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
$this->drupalPostForm(NULL, $edit, t('Save'));
}
/**
......
<?php
namespace Drupal\rdf\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Confirm that the serialization of RDF namespaces in present in the HTML
* markup.
*
* @group rdf
*/
class GetNamespacesTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['rdf', 'rdf_test_namespaces'];
/**
* Tests RDF namespaces.
*/
public function testGetRdfNamespaces() {
// Fetches the front page and extracts RDFa 1.1 prefixes.
$this->drupalGet('');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'rdfs: http://www.w3.org/2000/01/rdf-schema#',
]);
$this->assertTrue(!empty($element), 'A prefix declared once is displayed.');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'foaf: http://xmlns.com/foaf/0.1/',
]);
$this->assertTrue(!empty($element), 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'foaf1: http://xmlns.com/foaf/0.1/',
]);
$this->assertTrue(!empty($element), 'Two prefixes can be assigned the same namespace.');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'dc: http://purl.org/dc/terms/',
]);
$this->assertTrue(!empty($element), 'When a prefix has conflicting namespaces, the first declared one is used.');
}
}
name: 'RDF test module'
type: module
description: 'Test functionality for the RDF module.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- rdf
<?php
namespace Drupal\rdf\Tests\Field;
namespace Drupal\rdf_test;
/**
* Contains methods for test data conversions.
......
<?php
namespace Drupal\rdf\Tests;
namespace Drupal\Tests\rdf\Functional;
use Drupal\comment\CommentInterface;
use Drupal\comment\CommentManagerInterface;
use Drupal\comment\Tests\CommentTestBase;
use Drupal\Tests\comment\Functional\CommentTestBase;
use Drupal\user\RoleInterface;
use Drupal\comment\Entity\Comment;
......
......@@ -2,7 +2,7 @@
namespace Drupal\Tests\rdf\Functional;
use Drupal\file\Tests\FileFieldTestBase;
use Drupal\Tests\file\Functional\FileFieldTestBase;
use Drupal\file\Entity\File;
/**
......
......@@ -22,6 +22,25 @@ class GetRdfNamespacesTest extends BrowserTestBase {
* Tests getting RDF namespaces.
*/
public function testGetRdfNamespaces() {
// Fetches the front page and extracts RDFa 1.1 prefixes.
$this->drupalGet('');
// We have to use the find() method on the driver directly because //html is
// prepended to all xpath queries otherwise.
$driver = $this->getSession()->getDriver();
$element = $driver->find('//html[contains(@prefix, "rdfs: http://www.w3.org/2000/01/rdf-schema#")]');
$this->assertCount(1, $element, 'A prefix declared once is displayed.');
$element = $driver->find('//html[contains(@prefix, "foaf: http://xmlns.com/foaf/0.1/")]');
$this->assertCount(1, $element, 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
$element = $driver->find('//html[contains(@prefix, "foaf1: http://xmlns.com/foaf/0.1/")]');
$this->assertCount(1, $element, 'Two prefixes can be assigned the same namespace.');
$element = $driver->find('//html[contains(@prefix, "dc: http://purl.org/dc/terms/")]');
$this->assertCount(1, $element, 'When a prefix has conflicting namespaces, the first declared one is used.');
// Get all RDF namespaces.
$ns = rdf_get_namespaces();
......
<?php
namespace Drupal\rdf\Tests;
namespace Drupal\Tests\rdf\Functional;
use Drupal\image\Entity\ImageStyle;
use Drupal\image\Tests\ImageFieldTestBase;
use Drupal\Tests\image\Functional\ImageFieldTestBase;
use Drupal\node\Entity\Node;
use Drupal\file\Entity\File;
use Drupal\Tests\TestFileCreationTrait;
/**
* Tests the RDFa markup of imagefields.
......@@ -14,6 +15,10 @@
*/
class ImageFieldAttributesTest extends ImageFieldTestBase {
use TestFileCreationTrait {
getTestFiles as drupalGetTestFiles;
}
/**
* Modules to enable.
*
......
......@@ -2,7 +2,7 @@
namespace Drupal\Tests\rdf\Functional;
use Drupal\node\Tests\NodeTestBase;
use Drupal\Tests\node\Functional\NodeTestBase;
/**
* Tests the RDFa markup of Nodes.
......
......@@ -19,7 +19,7 @@ class FieldRdfaDatatypeCallbackTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['text', 'filter'];
public static $modules = ['text', 'filter', 'rdf_test'];
protected function setUp() {
parent::setUp();
......@@ -33,7 +33,7 @@ protected function setUp() {
$mapping->setFieldMapping($this->fieldName, [
'properties' => ['schema:interactionCount'],
'datatype_callback' => [
'callable' => 'Drupal\rdf\Tests\Field\TestDataConverter::convertFoo',
'callable' => 'Drupal\rdf_test\TestDataConverter::convertFoo',
],
])->save();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment