update drupal

This commit is contained in:
Tessier
2020-10-15 11:59:37 +02:00
parent ebb5db14b5
commit d8b9162932
558 changed files with 5954 additions and 4475 deletions
@@ -105,7 +105,7 @@ class ViewsExposedForm extends FormBase {
// Grouped exposed filters have their own forms.
// Instead of render the standard exposed form, a new Select or
// Radio form field is rendered with the available groups.
// When an user choose an option the selected value is split
// When an user chooses an option the selected value is split
// into the operator and value that the item represents.
if ($handler->isAGroup()) {
$handler->groupForm($form, $form_state);
@@ -43,8 +43,6 @@ class BooleanOperator extends FilterPluginBase {
// exposed filter options
protected $alwaysMultiple = TRUE;
// Don't display empty space where the operator would be.
public $no_operator = TRUE;
// Whether to accept NULL as a false value or not
public $accept_null = FALSE;
@@ -452,7 +452,7 @@ class InOperator extends FilterPluginBase {
}
}
elseif (!empty($this->value) && ($this->operator == 'in' || $this->operator == 'not in')) {
$errors[] = $this->t('The value @value is not an array for @operator on filter: @filter', ['@value' => var_export($this->value), '@operator' => $this->operator, '@filter' => $this->adminLabel(TRUE)]);
$errors[] = $this->t('The value @value is not an array for @operator on filter: @filter', ['@value' => var_export($this->value, TRUE), '@operator' => $this->operator, '@filter' => $this->adminLabel(TRUE)]);
}
return $errors;
}
@@ -19,7 +19,7 @@ use Symfony\Component\Routing\Route;
* help = @Translation("Provides a test access plugin that reports when cacheable metadata is being calculated.")
* )
*/
class CachableMetadataCalculationTest extends AccessPluginBase implements CacheableDependencyInterface {
class CacheableMetadataCalculationTest extends AccessPluginBase implements CacheableDependencyInterface {
/**
* The state service.
@@ -29,7 +29,7 @@ class CachableMetadataCalculationTest extends AccessPluginBase implements Cachea
protected $state;
/**
* Constructs a CachableMetadataCalculationTest access plugin.
* Constructs a CacheableMetadataCalculationTest access plugin.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
@@ -58,7 +58,7 @@ class ExposedFormTest extends ViewTestBase {
// Test the submit button value defaults to 'Apply'.
$this->drupalGet('test_exposed_form_buttons');
$this->assertSession()->statusCodeEquals(200);
$this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', t('Apply'));
$this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', 'Apply');
// Rename the label of the submit button.
$view = Views::getView('test_exposed_form_buttons');
@@ -84,7 +84,7 @@ class ExposedFormTest extends ViewTestBase {
// Make sure the submit button label shows 'Apply'.
$this->drupalGet('test_exposed_form_buttons');
$this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', t('Apply'));
$this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', 'Apply');
}
/**
@@ -264,7 +264,7 @@ class ExposedFormTest extends ViewTestBase {
$this->drupalGet('test_exposed_form_buttons');
$this->assertSession()->statusCodeEquals(200);
$this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', t('Apply'));
$this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', 'Apply');
// Ensure that no results are displayed.
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
@@ -9,7 +9,7 @@ use Drupal\KernelTests\KernelTestBase;
*
* @group views
*/
class CachableMetadataCalculationTest extends KernelTestBase {
class CacheableMetadataCalculationTest extends KernelTestBase {
/**
* The ID of the view used in the test.
@@ -72,21 +72,21 @@ class CachableMetadataCalculationTest extends KernelTestBase {
// metadata to be recalculated.
$this->enableModules([self::TEST_MODULE]);
$this->installConfig([self::TEST_MODULE]);
$this->assertCachebleMetadataHasBeenCalculated(FALSE);
$this->assertCacheableMetadataHasBeenCalculated(FALSE);
// When a view is saved normally we have to recalculate the cacheability
// metadata, since it is possible changes have been made to the view that
// affect cacheability.
$view = $this->entityTypeManager->getStorage('view')->load(self::TEST_VIEW_ID);
$view->save();
$this->assertCachebleMetadataHasBeenCalculated(TRUE);
$this->assertCacheableMetadataHasBeenCalculated(TRUE);
$this->resetState();
// When a view is being saved due to config being synchronized, the
// cacheability metadata doesn't change so it should not be recalculated.
$view->setSyncing(TRUE);
$view->save();
$this->assertCachebleMetadataHasBeenCalculated(FALSE);
$this->assertCacheableMetadataHasBeenCalculated(FALSE);
}
/**
@@ -96,7 +96,7 @@ class CachableMetadataCalculationTest extends KernelTestBase {
* TRUE if it is expected that the cacheability metadata has been
* calculated. FALSE otherwise.
*/
protected function assertCachebleMetadataHasBeenCalculated($expected_result) {
protected function assertCacheableMetadataHasBeenCalculated($expected_result) {
$this->state->resetCache();
$this->assertEquals($expected_result, $this->state->get('views_test_cacheable_metadata_has_been_accessed'));
}
@@ -40,15 +40,30 @@ class RelationshipJoinInTest extends RelationshipJoinTestBase {
// Update the first two Beatles to be authored by Kristiaan.
$account_k = $this->createUser([], 'Kristiaan');
$connection = Database::getConnection();
$connection->query("UPDATE {views_test_data} SET uid = :uid WHERE id IN (1,2)", [':uid' => $account_k->id()]);
$connection->update('views_test_data')
->fields([
'uid' => $account_k->id(),
])
->condition('id', [1, 2], 'IN')
->execute();
// Update the other two Beatles to be authored by Django.
$account_d = $this->createUser([], 'Django');
$connection->query("UPDATE {views_test_data} SET uid = :uid WHERE id IN (3,4)", [':uid' => $account_d->id()]);
$connection->update('views_test_data')
->fields([
'uid' => $account_d->id(),
])
->condition('id', [3, 4], 'IN')
->execute();
// Update Meredith to be authored by Silvie.
$account_s = $this->createUser([], 'Silvie');
$connection->query("UPDATE {views_test_data} SET uid = :uid WHERE id = 5", [':uid' => $account_s->id()]);
$connection->update('views_test_data')
->fields([
'uid' => $account_s->id(),
])
->condition('id', 5)
->execute();
$view = Views::getView('test_view');
$view->setDisplay();
@@ -38,8 +38,18 @@ class RelationshipTest extends RelationshipJoinTestBase {
public function testRelationshipQuery() {
$connection = Database::getConnection();
// Set the first entry to have the admin as author.
$connection->query("UPDATE {views_test_data} SET uid = 1 WHERE id = 1");
$connection->query("UPDATE {views_test_data} SET uid = 2 WHERE id <> 1");
$connection->update('views_test_data')
->fields([
'uid' => 1,
])
->condition('id', 1)
->execute();
$connection->update('views_test_data')
->fields([
'uid' => 2,
])
->condition('id', 1, '<>')
->execute();
$view = Views::getView('test_view');
$view->setDisplay();
@@ -136,11 +146,26 @@ class RelationshipTest extends RelationshipJoinTestBase {
public function testRelationshipRender() {
$connection = Database::getConnection();
$author1 = $this->createUser();
$connection->query("UPDATE {views_test_data} SET uid = :uid WHERE id = 1", [':uid' => $author1->id()]);
$connection->update('views_test_data')
->fields([
'uid' => $author1->id(),
])
->condition('id', 1)
->execute();
$author2 = $this->createUser();
$connection->query("UPDATE {views_test_data} SET uid = :uid WHERE id = 2", [':uid' => $author2->id()]);
$connection->update('views_test_data')
->fields([
'uid' => $author2->id(),
])
->condition('id', 2)
->execute();
// Set uid to non-existing author uid for row 3.
$connection->query("UPDATE {views_test_data} SET uid = :uid WHERE id = 3", [':uid' => $author2->id() + 123]);
$connection->update('views_test_data')
->fields([
'uid' => $author2->id() + 123,
])
->condition('id', 3)
->execute();
$view = Views::getView('test_view');
// Add a relationship for authors.
@@ -89,11 +89,9 @@ class RenderCacheIntegrationTest extends ViewsKernelTestBase {
* Whether to check Views' result & output caches.
*/
protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) {
$this->pass('Checking cache tags for field-based view.');
$view = Views::getview('entity_test_fields');
// Empty result (no entities yet).
$this->pass('Test without entities');
$base_tags = ['config:views.view.entity_test_fields', 'entity_test_list'];
$this->assertViewsCacheTags($view, $base_tags, $do_assert_views_caches, $base_tags);
$this->assertViewsCacheTagsFromStaticRenderArray($view, $base_tags, $do_assert_views_caches);
@@ -103,7 +101,6 @@ class RenderCacheIntegrationTest extends ViewsKernelTestBase {
$entities[] = $entity = EntityTest::create();
$entity->save();
$this->pass('Test with entities');
$tags_with_entity = Cache::mergeTags($base_tags, $entities[0]->getCacheTags());
$this->assertViewsCacheTags($view, $tags_with_entity, $do_assert_views_caches, $tags_with_entity);
$this->assertViewsCacheTagsFromStaticRenderArray($view, $tags_with_entity, $do_assert_views_caches);
@@ -114,9 +111,8 @@ class RenderCacheIntegrationTest extends ViewsKernelTestBase {
$entity->save();
}
// Test pager.
// Page 1.
$this->pass('Test pager');
$this->pass('Page 1');
\Drupal::request()->query->set('page', 0);
$tags_page_1 = Cache::mergeTags($base_tags, $entities[1]->getCacheTags());
$tags_page_1 = Cache::mergeTags($tags_page_1, $entities[2]->getCacheTags());
@@ -127,7 +123,6 @@ class RenderCacheIntegrationTest extends ViewsKernelTestBase {
$this->assertViewsCacheTagsFromStaticRenderArray($view, $tags_page_1, $do_assert_views_caches);
$view->destroy();
// Page 2.
$this->pass('Page 2');
$view->setCurrentPage(1);
\Drupal::request()->query->set('page', 1);
$tags_page_2 = Cache::mergeTags($base_tags, $entities[0]->getCacheTags());
@@ -135,8 +130,7 @@ class RenderCacheIntegrationTest extends ViewsKernelTestBase {
$view->destroy();
// Ensure that invalidation works on both pages.
$this->pass('Page invalidations');
$this->pass('Page 2');
// Page 2.
$view->setCurrentPage(1);
\Drupal::request()->query->set('page', 1);
$entities[0]->name->value = $random_name = $this->randomMachineName();
@@ -148,7 +142,7 @@ class RenderCacheIntegrationTest extends ViewsKernelTestBase {
$this->assertStringContainsString($random_name, (string) $build['#markup']);
$view->destroy();
$this->pass('Page 1');
// Page 1.
$view->setCurrentPage(0);
\Drupal::request()->query->set('page', 0);
$entities[1]->name->value = $random_name = $this->randomMachineName();
@@ -159,8 +153,6 @@ class RenderCacheIntegrationTest extends ViewsKernelTestBase {
$view->destroy();
// Setup arguments to ensure that render caching also varies by them.
$this->pass('Test arguments');
// Custom assert for a single result row.
$single_entity_assertions = function (array $build, EntityInterface $entity) {
$this->setRawContent($build['#markup']);
@@ -239,7 +231,6 @@ class RenderCacheIntegrationTest extends ViewsKernelTestBase {
* Tests cache tags on output & result cache items for an entity-based view.
*/
protected function assertCacheTagsForEntityBasedView($do_assert_views_caches) {
$this->pass('Checking cache tags for entity-based view.');
$view = Views::getview('entity_test_row');
// Empty result (no entities yet).
@@ -97,11 +97,10 @@ class ViewsConfigUpdaterTest extends ViewsKernelTestBase {
foreach ($view_ids as $view_id) {
$test_view = $this->loadTestView($view_id);
$this->configUpdater->updateAll($test_view);
$this->assertTrue($this->configUpdater->updateAll($test_view), "View $view_id should be updated.");
}
// @todo Improve this in https://www.drupal.org/node/3121008.
$this->pass('Views processed');
}
}
@@ -0,0 +1,39 @@
<?php
namespace Drupal\Tests\views\Unit\Plugin\filter;
use Drupal\Tests\UnitTestCase;
use Drupal\views\Plugin\views\filter\InOperator;
/**
* @coversDefaultClass \Drupal\views\Plugin\views\filter\InOperator
* @group views
*/
class InOperatorTest extends UnitTestCase {
/**
* @covers ::validate
*/
public function testValidate() {
$definition = [
'title' => 'Is InOperator Test',
'group' => 'Test',
'options callback' => '\Drupal\Tests\views\Unit\Plugin\filter\InOperatorTest::validate_options_callback',
];
$filter = new InOperator([], 'in_operator', $definition);
$filter->value = 'string';
$filter->operator = 'in';
$translation_stub = $this->getStringTranslationStub();
$filter->setStringTranslation($translation_stub);
$errors = $filter->validate();
$this->assertSame('The value &#039;string&#039; is not an array for in on filter: ' . $filter->adminLabel(TRUE), (string) $errors[0]);
}
/**
* @return array
*/
public static function validate_options_callback() {
return ['Yes', 'No'];
}
}