only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/Context/ConfigContext.php +++ b/core/lib/Drupal/Core/Config/Context/ConfigContext.php @@ -12,6 +12,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Component\Uuid\UuidInterface; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Defines the base configuration context object. @@ -64,7 +65,7 @@ class ConfigContext implements ContextInterface { * @param \Drupal\Component\Uuid\UuidInterface * The UUID service. */ - public function __construct(EventDispatcher $event_dispatcher, UuidInterface $uuid) { + public function __construct(EventDispatcherInterface $event_dispatcher, UuidInterface $uuid) { $this->eventDispatcher = $event_dispatcher; $this->uuidService = $uuid; } only in patch2: unchanged: --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Config/ConfigImporterTest.php @@ -0,0 +1,193 @@ + 'Config importer', + 'description' => 'Tests the config importer.', + 'group' => 'Configuration' + ); + } + + protected function setUp() { + $this->storageComparer = $this->getMock('Drupal\Core\Config\StorageComparerInterface'); + $this->storageComparer->expects($this->any()) + ->method('getEmptyChangelist') + ->will($this->returnValue(array('create' => array(), 'delete' => array(), 'update' => array()))); + + $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->configFactory = $this->getMockBuilder('Drupal\Core\Config\ConfigFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->entityManager = $this->getMockBuilder('Drupal\Core\Entity\EntityManager') + ->disableOriginalConstructor() + ->getMock(); + $this->lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface'); + $this->uuid = $this->getMock('Drupal\Component\Uuid\UuidInterface'); + $this->localComparer = $this->getMock('Drupal\Core\Config\StorageComparerInterface'); + + $this->configImporter = new ConfigImporter($this->storageComparer, $this->dispatcher, $this->configFactory, $this->entityManager, $this->lock, $this->uuid, $this->localComparer); + } + + /** + * Tests import with conflicts. + * + * @see \Drupal\Core\Config\ConfigImporter::checkForConflicts() + * @see \Drupal\Core\Config\ConfigImporter::import() + * + * @expectedException \Drupal\Core\Config\ConfigImporterException + */ + public function testImportConflictCheckingWithConflicts() { + $this->storageComparer->expects($this->any()) + ->method('getChangelist') + ->will($this->returnValue(array('test_entity.example_config_a', 'test_entity.example_config_b'))); + + $this->localComparer->expects($this->any()) + ->method('getChangelist') + ->will($this->returnValue(array('test_entity.example_config_b', 'test_entity.example_config_c'))); + + $this->lock->expects($this->any()) + ->method('acquire') + ->will($this->returnValue(TRUE)); + + $this->configImporter->import(); + } + + /** + * Tests import conflict checking without conflicts. + * + * @see \Drupal\Core\Config\ConfigImporter::checkForConflicts() + * @see \Drupal\Core\Config\ConfigImporter::import() + * + * @expectedException \Drupal\Core\Config\ConfigImporterException + */ + public function testImportConflictCheckingWithOutConflicts() { + $this->storageComparer->expects($this->any()) + ->method('getChangelist') + ->will($this->returnValue(array('test_entity.example_config_a', 'test_entity.example_config_b'))); + + $this->localComparer->expects($this->any()) + ->method('getChangelist') + ->will($this->returnValue(array('test_entity.example_config_c', 'test_entity.example_config_d'))); + + $this->lock->expects($this->any()) + ->method('acquire') + ->will($this->returnValue(TRUE)); + + $storage = $this->getMock('Drupal\Core\Config\StorageInterface'); + $storage->expects($this->any()) + ->method('read') + ->will($this->returnValue(array('key' => 'value'))); + + // @TODO this doesn't work yet. + $this->storageComparer->expects($this->any()) + ->method('getTargetStorage') + ->will($this->returnValue($storage)); + + $this->dispatcher->expects($this->at(0)) + ->method('dispatch') + ->with('config.importer.validate', $this->isInstanceOf('Drupal\Core\Config\ConfigImporterEvent')); + + $this->dispatcher->expects($this->at(1)) + ->method('dispatch') + ->with('config.importer.delete', $this->isInstanceOf('Drupal\Core\Config\ConfigImporterEvent')); + + $this->dispatcher->expects($this->at(1)) + ->method('dispatch') + ->with('config.importer.delete', $this->isInstanceOf('Drupal\Core\Config\ConfigImporterEvent')); + + $this->dispatcher->expects($this->at(2)) + ->method('dispatch') + ->with('config.importer.create', $this->isInstanceOf('Drupal\Core\Config\ConfigImporterEvent')); + $this->dispatcher->expects($this->at(3)) + ->method('dispatch') + ->with('config.importer.update', $this->isInstanceOf('Drupal\Core\Config\ConfigImporterEvent')); + + // @TODO this doesn't work yet. +// $this->configImporter->import(); + } + +} + +} + +namespace { + if (!function_exists('config_get_entity_type_by_name')) { + function config_get_entity_type_by_name($name) { + list($entity_type) = explode('.', $name); + return $entity_type; + } + } +}