Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Missing test: Update RdfKernelTestBase and the dependant tests #1

Open
wants to merge 2 commits into
base: 8.x-1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/rdf_taxonomy/tests/src/Kernel/SparqlTaxonomyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Drupal\rdf_entity\Entity\Rdf;
use Drupal\taxonomy\Entity\Term;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;
use Drupal\Tests\rdf_entity\Kernel\RdfKernelTestBase;

/**
* Tests Entity Query functionality of the Sparql backend.
Expand All @@ -13,7 +13,7 @@
*
* @group Entity
*/
class SparqlTaxonomyTest extends JoinupKernelTestBase {
class SparqlTaxonomyTest extends RdfKernelTestBase {

/**
* Modules to enable.
Expand Down
3 changes: 1 addition & 2 deletions tests/src/Kernel/RdfEncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
namespace Drupal\Tests\rdf_entity\Kernel;

use Drupal\rdf_entity\Entity\Rdf;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;

/**
* Tests the support of saving various encoded stings in the triple store.
*
* @group rdf_entity
*/
class RdfEncodingTest extends JoinupKernelTestBase {
class RdfEncodingTest extends RdfKernelTestBase {

/**
* Test that naughty strings can safely be saved to the database.
Expand Down
3 changes: 1 addition & 2 deletions tests/src/Kernel/RdfEntityCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

use Drupal\Core\Cache\Cache;
use Drupal\rdf_entity\Entity\Rdf;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;

/**
* Tests RDF entity caching.
*
* @group rdf_entity
*/
class RdfEntityCacheTest extends JoinupKernelTestBase {
class RdfEntityCacheTest extends RdfKernelTestBase {

/**
* Tests RDF entity cache tags.
Expand Down
3 changes: 1 addition & 2 deletions tests/src/Kernel/RdfEntityCreationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Drupal\rdf_entity\Entity\Rdf;
use Drupal\rdf_entity\Exception\DuplicatedIdException;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;

/**
* Provides unit testing for the 'rdf_entity' entity.
Expand All @@ -13,7 +12,7 @@
*
* @group rdf_entity
*/
class RdfEntityCreationTest extends JoinupKernelTestBase {
class RdfEntityCreationTest extends RdfKernelTestBase {

/**
* Tests overlapping IDs.
Expand Down
2 changes: 0 additions & 2 deletions tests/src/Kernel/RdfEntityLanguageTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ abstract class RdfEntityLanguageTestBase extends RdfKernelTestBase {
protected function setUp() {
parent::setUp();

$this->installEntitySchema('user');
$this->installConfig(['rdf_entity_test']);
$this->languageManager = $this->container->get('language_manager');
$this->installConfig(['language']);
// Enable translations for the rdf entity.
Expand Down
44 changes: 42 additions & 2 deletions tests/src/Kernel/RdfKernelTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@
/**
* A base class for the rdf tests.
*
* Sets up the SPARQL database connection.
* Mainly, assures the connection to the triple store database.
*
* IMPORTANT! You should not use real RDF entity bundles for testing because the
* test is using the same backend storage as the main site and you can end up
* with changes to the main site content. Create your own RDF entity bundles for
* testing purposes, like the one provided in the rdf_entity_test.module. That
* module uses a dedicated testing graphs, (http://example.com/dummy/published
* and http://example.com/dummy/draft). This base class enables, at startup, the
* rdf_entity_test.module and takes care of deleting testing data. For other
* custom testing data that you are adding for testing, you should take care of
* cleaning it after the test. You can extend the tearDown() method for this
* purpose.
*/
abstract class RdfKernelTestBase extends EntityKernelTestBase {

Expand All @@ -20,8 +31,9 @@ abstract class RdfKernelTestBase extends EntityKernelTestBase {
* @var string[]
*/
public static $modules = [
'ds',
'comment',
'datetime',
'rdf_entity_test',
];

/**
Expand All @@ -35,6 +47,34 @@ protected function setUp() {
$this->installModule('rdf_draft');
$this->installConfig(['rdf_entity', 'rdf_draft']);
$this->installEntitySchema('rdf_entity');
$this->installEntitySchema('user');
$this->installConfig(['rdf_entity_test']);
}

/**
* {@inheritdoc}
*/
public function tearDown() {
// Delete all data produced by testing module.
foreach (['dummy', 'with_owner', 'multifield'] as $bundle) {
foreach (['published', 'draft'] as $graph) {
$query = <<<EndOfQuery
DELETE {
GRAPH <http://example.com/$bundle/$graph> {
?entity ?field ?value
}
}
WHERE {
GRAPH <http://example.com/$bundle/$graph> {
?entity ?field ?value
}
}
EndOfQuery;
$this->sparql->query($query);
}
}

parent::tearDown();
}

}
3 changes: 1 addition & 2 deletions tests/src/Kernel/RdfOwnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
namespace Drupal\Tests\rdf_entity\Kernel;

use Drupal\rdf_entity\Entity\Rdf;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;

/**
* Tests rdf_entity owner functionality.
*
* @group rdf_entity
*/
class RdfOwnerTest extends JoinupKernelTestBase {
class RdfOwnerTest extends RdfKernelTestBase {

/**
* Tests rdf_entity owner functionality.
Expand Down
3 changes: 1 addition & 2 deletions tests/src/Kernel/RdfQueryExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
namespace Drupal\Tests\rdf_entity\Kernel;

use Drupal\rdf_entity\Exception\SparqlQueryException;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;

/**
* Test that a proper exception is thrown when a query fails.
*
* @group rdf_entity
*/
class RdfQueryExceptionTest extends JoinupKernelTestBase {
class RdfQueryExceptionTest extends RdfKernelTestBase {

/**
* Exception with query in message thrown for selects.
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/SparqlEntityInsertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
use Drupal\Component\Utility\Random;
use Drupal\rdf_entity\Entity\Rdf;
use Drupal\rdf_entity\RdfInterface;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;
use Drupal\Tests\rdf_entity\Kernel\RdfKernelTestBase;

/**
* Tests Entity Query functionality of the Sparql backend.
*
* @group Entity
*/
class SparqlEntityInsertTest extends JoinupKernelTestBase {
class SparqlEntityInsertTest extends RdfKernelTestBase {

/**
* Modules to enable.
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/SparqlEntityQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\rdf_entity\Tests;

use Drupal\rdf_entity\Entity\Rdf;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;
use Drupal\Tests\rdf_entity\Kernel\RdfKernelTestBase;

/**
* Tests Entity Query functionality of the Sparql backend.
Expand All @@ -12,7 +12,7 @@
*
* @group Entity
*/
class SparqlEntityQueryTest extends JoinupKernelTestBase {
class SparqlEntityQueryTest extends RdfKernelTestBase {

/**
* Modules to enable.
Expand Down