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

Commit

Permalink
Test that a default graph is set when an entity is created.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrenssen committed Oct 8, 2019
1 parent af74fd6 commit b06bfe3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/src/Kernel/EntityCreationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Drupal\Tests\sparql_entity_storage\Kernel;

use Drupal\rdf_entity\RdfInterface;
use Drupal\sparql_entity_storage\Entity\SparqlGraph;
use Drupal\sparql_entity_storage\Exception\DuplicatedIdException;
use Drupal\sparql_test\Entity\SparqlTest;

Expand Down Expand Up @@ -49,4 +51,31 @@ public function testOverlappingIds(): void {
])->save();
}

/**
* Tests that the default graph is set on entity creation.
*
* @covers ::create
*/
public function testDefaultGraphSetOnCreate(): void {
// Check that the default graph is set when no graph is specified.
$entity = SparqlTest::create([
'type' => 'waffle',
'id' => 'http://example.com/kempense-galet',
'title' => 'Kempense galet',
]);

$this->assertEquals(SparqlGraph::DEFAULT, $entity->get('graph')->target_id);

// Check that it is possible to specify a custom graph.
/** @var \Drupal\rdf_entity\RdfInterface $entity */
$entity = SparqlTest::create([
'type' => 'waffle',
'id' => 'http://example.com/liege-waffle',
'title' => 'Liège waffle',
'graph' => 'custom_graph',
]);

$this->assertEquals('custom_graph', $entity->get('graph')->target_id);
}

}

0 comments on commit b06bfe3

Please sign in to comment.