Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176

This commit is contained in:
Pantheon Automation 2015-08-17 17:00:26 -07:00 committed by Greg Anderson
commit 9921556621
13277 changed files with 1459781 additions and 0 deletions

View file

@ -0,0 +1,8 @@
name: 'RDF module conflicting namespaces test'
type: module
description: 'Test conflicting namespace declaration.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- rdf

View file

@ -0,0 +1,15 @@
<?php
/**
* @file
* Test the namespace registration functionality.
*/
/**
* Implements hook_rdf_namespaces().
*/
function rdf_conflicting_namespaces_rdf_namespaces() {
return array(
'dc' => 'http://purl.org/conflicting/namespace',
);
}

View file

@ -0,0 +1,8 @@
name: 'RDF module namespaces test'
type: module
description: 'Test namespace declaration.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- rdf

View file

@ -0,0 +1,16 @@
<?php
/**
* @file
* Test the namespace registration functionality.
*/
/**
* Implements hook_rdf_namespaces().
*/
function rdf_test_namespaces_rdf_namespaces() {
return array(
'foaf' => 'http://xmlns.com/foaf/0.1/',
'foaf1' => 'http://xmlns.com/foaf/0.1/',
);
}

View file

@ -0,0 +1,149 @@
<?php
/**
* @file
* Contains \Drupal\Tests\rdf\Unit\RdfMappingConfigEntityUnitTest.
*/
namespace Drupal\Tests\rdf\Unit;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\UnitTestCase;
use Drupal\rdf\Entity\RdfMapping;
/**
* @coversDefaultClass \Drupal\rdf\Entity\RdfMapping
* @group rdf
*/
class RdfMappingConfigEntityUnitTest extends UnitTestCase {
/**
* The entity type used for testing.
*
* @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $entityType;
/**
* The entity manager used for testing.
*
* @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $entityManager;
/**
* The ID of the type of the entity under test.
*
* @var string
*/
protected $entityTypeId;
/**
* The UUID generator used for testing.
*
* @var \Drupal\Component\Uuid\UuidInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $uuid;
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any())
->method('getProvider')
->will($this->returnValue('entity'));
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('uuid', $this->uuid);
\Drupal::setContainer($container);
}
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependencies() {
$target_entity_type_id = $this->randomMachineName(16);
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any())
->method('getProvider')
->will($this->returnValue('test_module'));
$values = array('targetEntityType' => $target_entity_type_id);
$target_entity_type->expects($this->any())
->method('getBundleEntityType')
->will($this->returnValue('bundle'));
$this->entityManager->expects($this->at(0))
->method('getDefinition')
->with($target_entity_type_id)
->will($this->returnValue($target_entity_type));
$this->entityManager->expects($this->at(1))
->method('getDefinition')
->with($this->entityTypeId)
->will($this->returnValue($this->entityType));
$entity = new RdfMapping($values, $this->entityTypeId);
$dependencies = $entity->calculateDependencies();
$this->assertArrayNotHasKey('config', $dependencies);
$this->assertContains('test_module', $dependencies['module']);
}
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependenciesWithEntityBundle() {
$target_entity_type_id = $this->randomMachineName(16);
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any())
->method('getProvider')
->will($this->returnValue('test_module'));
$bundle_id = $this->randomMachineName(10);
$values = array('targetEntityType' => $target_entity_type_id , 'bundle' => $bundle_id);
$bundle_entity_type_id = $this->randomMachineName(17);
$bundle_entity = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityInterface');
$bundle_entity
->expects($this->once())
->method('getConfigDependencyName')
->will($this->returnValue('test_module.type.' . $bundle_id));
$target_entity_type->expects($this->any())
->method('getBundleEntityType')
->will($this->returnValue($bundle_entity_type_id));
$this->entityManager->expects($this->at(0))
->method('getDefinition')
->with($target_entity_type_id)
->will($this->returnValue($target_entity_type));
$this->entityManager->expects($this->at(1))
->method('getDefinition')
->with($this->entityTypeId)
->will($this->returnValue($this->entityType));
$storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once())
->method('load')
->with($bundle_id)
->will($this->returnValue($bundle_entity));
$this->entityManager->expects($this->once())
->method('getStorage')
->with($bundle_entity_type_id)
->will($this->returnValue($storage));
$entity = new RdfMapping($values, $this->entityTypeId);
$dependencies = $entity->calculateDependencies();
$this->assertContains('test_module.type.' . $bundle_id, $dependencies['config']);
$this->assertContains('test_module', $dependencies['module']);
}
}