upgrades core to 8.4.2

This commit is contained in:
Bachir Soussi Chiadmi
2017-11-14 16:09:54 +01:00
parent bd60eff9b3
commit c2b4e25be4
3504 changed files with 140306 additions and 38684 deletions
@@ -5,8 +5,8 @@ description: 'Support module for the Quick Edit module tests.'
package: Testing
# version: VERSION
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -2,19 +2,9 @@
namespace Drupal\quickedit_test;
use Drupal\Core\Entity\EntityInterface;
use Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface;
/**
* Access check for editing entity fields.
* @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0.
*/
class MockEditEntityFieldAccessCheck implements EditEntityFieldAccessCheckInterface {
/**
* {@inheritdoc}
*/
public function accessEditEntityField(EntityInterface $entity, $field_name) {
return TRUE;
}
class MockEditEntityFieldAccessCheck extends MockQuickEditEntityFieldAccessCheck {
}
@@ -0,0 +1,20 @@
<?php
namespace Drupal\quickedit_test;
use Drupal\Core\Entity\EntityInterface;
use Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface;
/**
* Access check for in-place editing entity fields.
*/
class MockQuickEditEntityFieldAccessCheck implements QuickEditEntityFieldAccessCheckInterface {
/**
* {@inheritdoc}
*/
public function accessEditEntityField(EntityInterface $entity, $field_name) {
return TRUE;
}
}
@@ -5,7 +5,7 @@ namespace Drupal\Tests\quickedit\Kernel;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\quickedit\EditorSelector;
use Drupal\quickedit\MetadataGenerator;
use Drupal\quickedit_test\MockEditEntityFieldAccessCheck;
use Drupal\quickedit_test\MockQuickEditEntityFieldAccessCheck;
use Drupal\filter\Entity\FilterFormat;
/**
@@ -44,7 +44,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
/**
* The access checker object to be used by the metadata generator object.
*
* @var \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface
* @var \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface
*/
protected $accessChecker;
@@ -52,7 +52,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
parent::setUp();
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
$this->accessChecker = new MockEditEntityFieldAccessCheck();
$this->accessChecker = new MockQuickEditEntityFieldAccessCheck();
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
}
@@ -172,7 +172,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
'format' => 'full_html'
],
];
$this->assertEqual($expected, $metadata); //, 'The correct metadata (including custom metadata) is generated.');
$this->assertEqual($expected, $metadata, 'The correct metadata (including custom metadata) is generated.');
}
}
@@ -0,0 +1,149 @@
<?php
namespace Drupal\Tests\quickedit\Unit\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\Context\CacheContextsManager;
use Drupal\Core\DependencyInjection\Container;
use Drupal\quickedit\Access\QuickEditEntityFieldAccessCheck;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Language\LanguageInterface;
/**
* @coversDefaultClass \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheck
* @group Access
* @group quickedit
*/
class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
/**
* The tested access checker.
*
* @var \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheck
*/
protected $editAccessCheck;
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->editAccessCheck = new QuickEditEntityFieldAccessCheck();
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class);
$cache_contexts_manager->assertValidTokens()->willReturn(TRUE);
$cache_contexts_manager->reveal();
$container = new Container();
$container->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($container);
}
/**
* Provides test data for testAccess().
*
* @see \Drupal\Tests\edit\Unit\quickedit\Access\QuickEditEntityFieldAccessCheckTest::testAccess()
*/
public function providerTestAccess() {
$data = [];
$data[] = [TRUE, TRUE, AccessResult::allowed()];
$data[] = [FALSE, TRUE, AccessResult::neutral()];
$data[] = [TRUE, FALSE, AccessResult::neutral()];
$data[] = [FALSE, FALSE, AccessResult::neutral()];
return $data;
}
/**
* Tests the method for checking access to routes.
*
* @param bool $entity_is_editable
* Whether the subject entity is editable.
* @param bool $field_storage_is_accessible
* Whether the user has access to the field storage entity.
* @param \Drupal\Core\Access\AccessResult $expected_result
* The expected result of the access call.
*
* @dataProvider providerTestAccess
*/
public function testAccess($entity_is_editable, $field_storage_is_accessible, AccessResult $expected_result) {
$entity = $this->createMockEntity();
$entity->expects($this->any())
->method('access')
->willReturn(AccessResult::allowedIf($entity_is_editable)->cachePerPermissions());
$field_storage = $this->getMock('Drupal\field\FieldStorageConfigInterface');
$field_storage->expects($this->any())
->method('access')
->willReturn(AccessResult::allowedIf($field_storage_is_accessible));
$expected_result->cachePerPermissions();
$field_name = 'valid';
$entity_with_field = clone $entity;
$entity_with_field->expects($this->any())
->method('get')
->with($field_name)
->will($this->returnValue($field_storage));
$entity_with_field->expects($this->once())
->method('hasTranslation')
->with(LanguageInterface::LANGCODE_NOT_SPECIFIED)
->will($this->returnValue(TRUE));
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
$access = $this->editAccessCheck->access($entity_with_field, $field_name, LanguageInterface::LANGCODE_NOT_SPECIFIED, $account);
$this->assertEquals($expected_result, $access);
}
/**
* Tests checking access to routes that result in AccessResult::isForbidden().
*
* @dataProvider providerTestAccessForbidden
*/
public function testAccessForbidden($field_name, $langcode) {
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
$entity = $this->createMockEntity();
$this->assertEquals(AccessResult::forbidden(), $this->editAccessCheck->access($entity, $field_name, $langcode, $account));
}
/**
* Provides test data for testAccessForbidden.
*/
public function providerTestAccessForbidden() {
$data = [];
// Tests the access method without a field_name.
$data[] = [NULL, LanguageInterface::LANGCODE_NOT_SPECIFIED];
// Tests the access method with a non-existent field.
$data[] = ['not_valid', LanguageInterface::LANGCODE_NOT_SPECIFIED];
// Tests the access method without a langcode.
$data[] = ['valid', NULL];
// Tests the access method with an invalid langcode.
$data[] = ['valid', 'xx-lolspeak'];
return $data;
}
/**
* Returns a mock entity.
*
* @return \Drupal\Core\Entity\EntityInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected function createMockEntity() {
$entity = $this->getMockBuilder('Drupal\entity_test\Entity\EntityTest')
->disableOriginalConstructor()
->getMock();
$entity->expects($this->any())
->method('hasTranslation')
->will($this->returnValueMap([
[LanguageInterface::LANGCODE_NOT_SPECIFIED, TRUE],
['xx-lolspeak', FALSE],
]));
$entity->expects($this->any())
->method('hasField')
->will($this->returnValueMap([
['valid', TRUE],
['not_valid', FALSE],
]));
return $entity;
}
}