Update to Drupal 8.1.2. For more information, see https://www.drupal.org/project/drupal/releases/8.1.2
This commit is contained in:
parent
9eae24d844
commit
28556d630e
1322 changed files with 6699 additions and 2064 deletions
|
@ -0,0 +1,53 @@
|
|||
langcode: en
|
||||
status: true
|
||||
id: test_area_order
|
||||
label: ''
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: views_test_data
|
||||
base_field: nid
|
||||
core: '8'
|
||||
display:
|
||||
default:
|
||||
display_options:
|
||||
defaults:
|
||||
fields: false
|
||||
pager: false
|
||||
sorts: false
|
||||
header:
|
||||
entity_block_2:
|
||||
field: entity_block
|
||||
id: entity_block
|
||||
table: views
|
||||
target: 'bartik_powered'
|
||||
view_mode: full
|
||||
plugin_id: entity
|
||||
entity_block_1:
|
||||
field: entity_block
|
||||
id: entity_block
|
||||
table: views
|
||||
target: 'bartik_branding'
|
||||
view_mode: full
|
||||
plugin_id: entity
|
||||
fields:
|
||||
id:
|
||||
field: id
|
||||
id: id
|
||||
relationship: none
|
||||
table: views_test_data
|
||||
plugin_id: numeric
|
||||
arguments:
|
||||
id:
|
||||
id: id
|
||||
table: views_test_data
|
||||
field: id
|
||||
plugin_id: numeric
|
||||
pager:
|
||||
options:
|
||||
offset: 0
|
||||
type: none
|
||||
display_plugin: default
|
||||
display_title: Master
|
||||
id: default
|
||||
position: 0
|
|
@ -23,6 +23,13 @@ display:
|
|||
plugin_id: field
|
||||
entity_type: entity_test
|
||||
entity_field: id
|
||||
field_test_multiple:
|
||||
id: field_test_multiple
|
||||
table: entity_test__field_test_multiple
|
||||
field: field_test_multiple
|
||||
plugin_id: field
|
||||
entity_type: entity_test
|
||||
entity_field: field_test_multiple
|
||||
field_test:
|
||||
id: field_test
|
||||
table: entity_test__field_test
|
||||
|
@ -30,6 +37,13 @@ display:
|
|||
plugin_id: field
|
||||
entity_type: entity_test
|
||||
entity_field: field_test
|
||||
user_id:
|
||||
id: user_id
|
||||
table: entity_test
|
||||
field: user_id
|
||||
plugin_id: field
|
||||
entity_type: entity_test
|
||||
entity_field: user_id
|
||||
style:
|
||||
type: html_list
|
||||
sorts:
|
||||
|
|
|
@ -37,4 +37,5 @@ class ViewsTestDataElementEmbedForm extends FormBase {
|
|||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\simpletest\ContentTypeCreationTrait;
|
||||
use Drupal\simpletest\NodeCreationTrait;
|
||||
|
||||
/**
|
||||
* Tests the basic AJAX functionality of Views exposed forms.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class ExposedFilterAJAXTest extends JavascriptTestBase {
|
||||
|
||||
use ContentTypeCreationTrait;
|
||||
use NodeCreationTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'views'];
|
||||
|
||||
/**
|
||||
* Tests if exposed filtering via AJAX works for the "Content" View.
|
||||
*/
|
||||
public function testExposedFiltering() {
|
||||
// Enable AJAX on the /admin/content View.
|
||||
\Drupal::configFactory()->getEditable('views.view.content')
|
||||
->set('display.default.display_options.use_ajax', TRUE)
|
||||
->save();
|
||||
|
||||
// Create a Content type and two test nodes.
|
||||
$this->createContentType(['type' => 'page']);
|
||||
$this->createNode(['title' => 'Page One']);
|
||||
$this->createNode(['title' => 'Page Two']);
|
||||
|
||||
// Create a user privileged enough to use exposed filters and view content.
|
||||
$user = $this->drupalCreateUser([
|
||||
'administer site configuration',
|
||||
'access content',
|
||||
'access content overview',
|
||||
]);
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Visit the View page.
|
||||
$this->drupalGet('admin/content');
|
||||
|
||||
$session = $this->getSession();
|
||||
|
||||
// Ensure that the Content we're testing for is present.
|
||||
$html = $session->getPage()->getHtml();
|
||||
$this->assertContains('Page One', $html);
|
||||
$this->assertContains('Page Two', $html);
|
||||
|
||||
// Search for "Page One".
|
||||
$this->submitForm(['title' => 'Page One'], t('Filter'));
|
||||
$this->waitForAjaxToFinish();
|
||||
|
||||
// Verify that only the "Page One" Node is present.
|
||||
$html = $session->getPage()->getHtml();
|
||||
$this->assertContains('Page One', $html);
|
||||
$this->assertNotContains('Page Two', $html);
|
||||
|
||||
// Search for "Page Two".
|
||||
$this->submitForm(['title' => 'Page Two'], t('Filter'));
|
||||
$this->waitForAjaxToFinish();
|
||||
|
||||
// Verify that only the "Page Two" Node is present.
|
||||
$html = $session->getPage()->getHtml();
|
||||
$this->assertContains('Page Two', $html);
|
||||
$this->assertNotContains('Page One', $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for jQuery to become active and animations to complete.
|
||||
*/
|
||||
protected function waitForAjaxToFinish() {
|
||||
$condition = "(0 === jQuery.active && 0 === jQuery(':animated').length)";
|
||||
$this->assertJsCondition($condition, 10000);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\block\Entity\Block;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the view area handler.
|
||||
*
|
||||
* @group views
|
||||
* @see \Drupal\views\Plugin\views\area\View
|
||||
*/
|
||||
class AreaOrderTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('user', 'block');
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_area_order');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpFixtures() {
|
||||
Block::create(
|
||||
[
|
||||
'id' => 'bartik_branding',
|
||||
'theme' => 'bartik',
|
||||
'plugin' => 'system_branding_block',
|
||||
'weight' => 1,
|
||||
]
|
||||
)->save();
|
||||
|
||||
Block::create(
|
||||
[
|
||||
'id' => 'bartik_powered',
|
||||
'theme' => 'bartik',
|
||||
'plugin' => 'system_powered_by_block',
|
||||
'weight' => 2,
|
||||
]
|
||||
)->save();
|
||||
|
||||
parent::setUpFixtures();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the order of the handlers.
|
||||
*/
|
||||
public function testAreaOrder() {
|
||||
$renderer = $this->container->get('renderer');
|
||||
$view = Views::getView('test_area_order');
|
||||
$renderable = $view->buildRenderable();
|
||||
$output = $this->render($renderable);
|
||||
|
||||
$position_powered = strpos($output, 'block-bartik-powered');
|
||||
$position_branding = strpos($output, 'block-bartik-branding');
|
||||
|
||||
$this->assertNotEquals(0, $position_powered, 'ID bartik-powered found.');
|
||||
$this->assertNotEquals(0, $position_branding, 'ID bartik-branding found');
|
||||
|
||||
// Make sure "powered" is before "branding", so it reflects the position
|
||||
// in the configuration, and not the weight of the blocks.
|
||||
$this->assertTrue($position_powered < $position_branding, 'Block bartik-powered is positioned before block bartik-branding');
|
||||
}
|
||||
|
||||
}
|
|
@ -315,4 +315,5 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
$expected = array();
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,7 +84,9 @@ class FieldCounterTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
|
||||
}
|
||||
|
||||
// @TODO: Write tests for pager.
|
||||
/**
|
||||
* @todo: Write tests for pager.
|
||||
*/
|
||||
function testPager() {
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use Drupal\field\Entity\FieldStorageConfig;
|
|||
use Drupal\user\Entity\User;
|
||||
use Drupal\views\Plugin\views\field\Field;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
|
@ -62,12 +63,15 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
// First setup the needed entity types before installing the views.
|
||||
parent::setUp(FALSE);
|
||||
|
||||
$this->installEntitySchema('entity_test');
|
||||
$this->installEntitySchema('user');
|
||||
$this->installEntitySchema('entity_test');
|
||||
$this->installEntitySchema('entity_test_rev');
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
|
||||
|
||||
// Bypass any field access.
|
||||
$this->adminUser = User::create(['name' => $this->randomString()]);
|
||||
$this->adminUser->save();
|
||||
|
@ -546,4 +550,60 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual('', $executable->getStyle()->getField(6, 'field_test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests \Drupal\views\Plugin\views\field\Field::getValue
|
||||
*/
|
||||
public function testGetValueMethod() {
|
||||
$bundle = 'test_bundle';
|
||||
entity_test_create_bundle($bundle);
|
||||
|
||||
$field_multiple = FieldConfig::create([
|
||||
'field_name' => 'field_test_multiple',
|
||||
'entity_type' => 'entity_test',
|
||||
'bundle' => 'test_bundle',
|
||||
]);
|
||||
$field_multiple->save();
|
||||
|
||||
foreach ($this->entities as $entity) {
|
||||
$entity->delete();
|
||||
}
|
||||
|
||||
$this->entities = [];
|
||||
$this->entities[] = $entity = EntityTest::create([
|
||||
'type' => 'entity_test',
|
||||
'name' => 'test name',
|
||||
'user_id' => $this->testUsers[0]->id(),
|
||||
]);
|
||||
$entity->save();
|
||||
$this->entities[] = $entity = EntityTest::create([
|
||||
'type' => 'entity_test',
|
||||
'name' => 'test name 2',
|
||||
'user_id' => $this->testUsers[0]->id(),
|
||||
]);
|
||||
$entity->save();
|
||||
|
||||
$this->entities[] = $entity = EntityTest::create([
|
||||
'type' => $bundle,
|
||||
'name' => 'test name 3',
|
||||
'user_id' => $this->testUsers[0]->id(),
|
||||
'field_test_multiple' => [1, 2, 3],
|
||||
]);
|
||||
$entity->save();
|
||||
|
||||
$executable = Views::getView('test_field_field_test');
|
||||
$executable->execute();
|
||||
|
||||
$field_normal = $executable->field['field_test'];
|
||||
$field_entity_reference = $executable->field['user_id'];
|
||||
$field_multi_cardinality = $executable->field['field_test_multiple'];
|
||||
|
||||
$this->assertEquals($this->entities[0]->field_test->value, $field_normal->getValue($executable->result[0]));
|
||||
$this->assertEquals($this->entities[0]->user_id->target_id, $field_entity_reference->getValue($executable->result[0]));
|
||||
$this->assertEquals($this->entities[1]->field_test->value, $field_normal->getValue($executable->result[1]));
|
||||
$this->assertEquals($this->entities[1]->user_id->target_id, $field_entity_reference->getValue($executable->result[1]));
|
||||
$this->assertEquals([], $field_multi_cardinality->getValue($executable->result[0]));
|
||||
$this->assertEquals([], $field_multi_cardinality->getValue($executable->result[1]));
|
||||
$this->assertEquals([1, 2, 3], $field_multi_cardinality->getValue($executable->result[2]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class ViewsBlockTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Tests that ViewsBlock::getMachineNameSuggestion() produces the right value.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\Block::getmachineNameSuggestion().
|
||||
* @see \Drupal\views\Plugin\Block::getmachineNameSuggestion()
|
||||
*/
|
||||
public function testMachineNameSuggestion() {
|
||||
$plugin_definition = array(
|
||||
|
|
|
@ -351,7 +351,13 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$reflection = new \ReflectionClass($view);
|
||||
$defaults = $reflection->getDefaultProperties();
|
||||
// The storage and user should remain.
|
||||
unset($defaults['storage'], $defaults['user'], $defaults['request'], $defaults['routeProvider']);
|
||||
unset(
|
||||
$defaults['storage'],
|
||||
$defaults['user'],
|
||||
$defaults['request'],
|
||||
$defaults['routeProvider'],
|
||||
$defaults['viewsData']
|
||||
);
|
||||
|
||||
foreach ($defaults as $property => $default) {
|
||||
$this->assertIdentical($this->getProtectedProperty($view, $property), $default);
|
||||
|
|
|
@ -120,7 +120,7 @@ class ViewsKernelTestBase extends KernelTestBase {
|
|||
$view->setDisplay();
|
||||
$view->preExecute($args);
|
||||
$view->execute();
|
||||
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']). '</pre>';
|
||||
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']) . '</pre>';
|
||||
if ($view->build_info['query'] instanceof SelectInterface) {
|
||||
$verbose_message .= '<pre>Arguments: ' . print_r($view->build_info['query']->getArguments(), TRUE) . '</pre>';
|
||||
}
|
||||
|
|
|
@ -70,4 +70,5 @@ class WizardPluginBaseKernelTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual($view->get('base_table'), 'views_test_data');
|
||||
$this->assertEqual($view->get('langcode'), 'it');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ use Drupal\Core\Field\Plugin\Field\FieldType\LanguageItem;
|
|||
use Drupal\Core\Field\Plugin\Field\FieldType\StringItem;
|
||||
use Drupal\Core\Field\Plugin\Field\FieldType\UriItem;
|
||||
use Drupal\Core\Field\Plugin\Field\FieldType\UuidItem;
|
||||
use Drupal\Core\TypedData\TypedDataManagerInterface;
|
||||
use Drupal\text\Plugin\Field\FieldType\TextLongItem;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\entity_test\Entity\EntityTestMul;
|
||||
|
@ -83,9 +84,7 @@ class EntityViewsDataTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
|
||||
$typed_data_manager = $this->getMockBuilder('Drupal\Core\TypedData\TypedDataManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typed_data_manager = $this->getMock(TypedDataManagerInterface::class);
|
||||
$typed_data_manager->expects($this->any())
|
||||
->method('createDataDefinition')
|
||||
->willReturn($this->getMock('Drupal\Core\TypedData\DataDefinitionInterface'));
|
||||
|
@ -962,6 +961,7 @@ class TestEntityViewsData extends EntityViewsData {
|
|||
public function setEntityType(EntityTypeInterface $entity_type) {
|
||||
$this->entityType = $entity_type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TestEntityType extends EntityType {
|
||||
|
|
|
@ -249,7 +249,9 @@ class PagerPluginBaseTest extends UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
// As StatementInterface extends \Traversable, which though always needs
|
||||
// an additional interface. The Statement class itself can't be mocked because
|
||||
// of its __wakeup function.
|
||||
/**
|
||||
* As StatementInterface extends \Traversable, which though always needs
|
||||
* an additional interface. The Statement class itself can't be mocked because
|
||||
* of its __wakeup function.
|
||||
*/
|
||||
interface TestStatementInterface extends StatementInterface, \Iterator {}
|
||||
|
|
|
@ -163,6 +163,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
$build = $this->plugin->render($result);
|
||||
$this->assertSame($expected_build, $build);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue