Browse Source
* Naive vector clock implementation * RDF mapping and dummy/namespace predicate. * Derpin it up * Removing the derp to make branch appear on github * Tests * in => intpull/756/head
dannylamb
8 years ago
committed by
Nick Ruest
8 changed files with 142 additions and 29 deletions
@ -0,0 +1,48 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Drupal\Tests\islandora\Kernel; |
||||||
|
|
||||||
|
use Drupal\KernelTests\KernelTestBase; |
||||||
|
|
||||||
|
/** |
||||||
|
* Abstract base class for Islandora kernel tests. |
||||||
|
* |
||||||
|
*/ |
||||||
|
abstract class IslandoraKernelTestBase extends KernelTestBase { |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public static $modules = [ |
||||||
|
'system', |
||||||
|
'user', |
||||||
|
'field', |
||||||
|
'filter', |
||||||
|
'block', |
||||||
|
'node', |
||||||
|
'path', |
||||||
|
'text', |
||||||
|
'options', |
||||||
|
'inline_entity_form', |
||||||
|
'serialization', |
||||||
|
'rest', |
||||||
|
'rdf', |
||||||
|
'jsonld', |
||||||
|
'islandora' |
||||||
|
]; |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function setUp() { |
||||||
|
parent::setUp(); |
||||||
|
|
||||||
|
// Bootstrap minimal Drupal environment to run the tests. |
||||||
|
$this->installSchema('system', 'sequences'); |
||||||
|
$this->installEntitySchema('user'); |
||||||
|
$this->installConfig('filter'); |
||||||
|
$this->installEntitySchema('fedora_resource'); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,54 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Drupal\Tests\islandora\Kernel; |
||||||
|
|
||||||
|
use Drupal\islandora\Entity\FedoraResource; |
||||||
|
use Drupal\simpletest\UserCreationTrait; |
||||||
|
|
||||||
|
/** |
||||||
|
* Tests the basic behavior of a vector clock. |
||||||
|
* |
||||||
|
* @group islandora |
||||||
|
*/ |
||||||
|
class VectorClockTest extends IslandoraKernelTestBase { |
||||||
|
|
||||||
|
/** |
||||||
|
* Fedora resource entity. |
||||||
|
* |
||||||
|
* @var \Drupal\islandora\FedoraResourceInterface |
||||||
|
*/ |
||||||
|
protected $entity; |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function setUp() { |
||||||
|
parent::setUp(); |
||||||
|
|
||||||
|
// Create a test entity. |
||||||
|
$this->entity = FedoraResource::create([ |
||||||
|
"type" => "rdf_source", |
||||||
|
"uid" => 1, |
||||||
|
"name" => "Test Fixture", |
||||||
|
"langcode" => "und", |
||||||
|
"status" => 1, |
||||||
|
]); |
||||||
|
$this->entity->save(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Tests the basic behavior of the vector clock. |
||||||
|
*/ |
||||||
|
public function testVectorClock() { |
||||||
|
// Check the vclock is set to 0 when a new entity is created. |
||||||
|
$this->assertTrue($this->entity->getVclock() == 0, "Vector clock initialized to zero."); |
||||||
|
|
||||||
|
// Edit the entity. |
||||||
|
$this->entity->setName("Edited Test Fixture")->save(); |
||||||
|
|
||||||
|
// Check the vclock is incremented when the entity is updated. |
||||||
|
$this->assertTrue($this->entity->getVclock() == 1, "Vector clock incremented on update."); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue