Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\tour\Functional;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\system\Tests\Cache\PageCacheTagsTestBase;
|
||||
use Drupal\tour\Entity\Tour;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
||||
/**
|
||||
* Tests the Tour entity's cache tags.
|
||||
*
|
||||
* @group tour
|
||||
*/
|
||||
class TourCacheTagsTest extends PageCacheTagsTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['tour', 'tour_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Give anonymous users permission to view nodes, so that we can verify the
|
||||
// cache tags of cached versions of node pages.
|
||||
Role::load(RoleInterface::ANONYMOUS_ID)->grantPermission('access tour')
|
||||
->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests cache tags presence and invalidation of the Tour entity.
|
||||
*
|
||||
* Tests the following cache tags:
|
||||
* - 'tour:<tour ID>'
|
||||
*/
|
||||
public function testRenderedTour() {
|
||||
$url = Url::fromRoute('tour_test.1');
|
||||
|
||||
// Prime the page cache.
|
||||
$this->verifyPageCache($url, 'MISS');
|
||||
|
||||
// Verify a cache hit, but also the presence of the correct cache tags.
|
||||
$expected_tags = [
|
||||
'config:tour.tour.tour-test',
|
||||
'config:user.role.anonymous',
|
||||
'http_response',
|
||||
'rendered',
|
||||
];
|
||||
$this->verifyPageCache($url, 'HIT', $expected_tags);
|
||||
|
||||
// Verify that after modifying the tour, there is a cache miss.
|
||||
$this->pass('Test modification of tour.', 'Debug');
|
||||
Tour::load('tour-test')->save();
|
||||
$this->verifyPageCache($url, 'MISS');
|
||||
|
||||
// Verify a cache hit.
|
||||
$this->verifyPageCache($url, 'HIT', $expected_tags);
|
||||
|
||||
// Verify that after deleting the tour, there is a cache miss.
|
||||
$this->pass('Test deletion of tour.', 'Debug');
|
||||
Tour::load('tour-test')->delete();
|
||||
$this->verifyPageCache($url, 'MISS');
|
||||
|
||||
// Verify a cache hit.
|
||||
$expected_tags = [
|
||||
'config:user.role.anonymous',
|
||||
'http_response',
|
||||
'rendered',
|
||||
];
|
||||
$this->verifyPageCache($url, 'HIT', $expected_tags);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@ class TourPluginTest extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('tour');
|
||||
public static $modules = ['tour'];
|
||||
|
||||
/**
|
||||
* Stores the tour plugin manager.
|
||||
|
@ -28,7 +28,7 @@ class TourPluginTest extends KernelTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installConfig(array('tour'));
|
||||
$this->installConfig(['tour']);
|
||||
$this->pluginManager = $this->container->get('plugin.manager.tour.tip');
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class TourTest extends UnitTestCase {
|
|||
public function testHasMatchingRoute($routes, $route_name, $route_params, $result) {
|
||||
$tour = $this->getMockBuilder('\Drupal\tour\Entity\Tour')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getRoutes'))
|
||||
->setMethods(['getRoutes'])
|
||||
->getMock();
|
||||
|
||||
$tour->expects($this->any())
|
||||
|
@ -45,94 +45,94 @@ class TourTest extends UnitTestCase {
|
|||
* Provides sample routes for testing.
|
||||
*/
|
||||
public function routeProvider() {
|
||||
return array(
|
||||
return [
|
||||
// Simple match.
|
||||
array(
|
||||
array(
|
||||
array('route_name' => 'some.route'),
|
||||
),
|
||||
[
|
||||
[
|
||||
['route_name' => 'some.route'],
|
||||
],
|
||||
'some.route',
|
||||
array(),
|
||||
[],
|
||||
TRUE,
|
||||
),
|
||||
],
|
||||
// Simple non-match.
|
||||
array(
|
||||
array(
|
||||
array('route_name' => 'another.route'),
|
||||
),
|
||||
[
|
||||
[
|
||||
['route_name' => 'another.route'],
|
||||
],
|
||||
'some.route',
|
||||
array(),
|
||||
[],
|
||||
FALSE,
|
||||
),
|
||||
],
|
||||
// Empty params.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
[
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
),
|
||||
'route_params' => ['foo' => 'bar'],
|
||||
],
|
||||
],
|
||||
'some.route',
|
||||
array(),
|
||||
[],
|
||||
FALSE,
|
||||
),
|
||||
],
|
||||
// Match on params.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
[
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
),
|
||||
'route_params' => ['foo' => 'bar'],
|
||||
],
|
||||
],
|
||||
'some.route',
|
||||
array('foo' => 'bar'),
|
||||
['foo' => 'bar'],
|
||||
TRUE,
|
||||
),
|
||||
],
|
||||
// Non-matching params.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
[
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
),
|
||||
'route_params' => ['foo' => 'bar'],
|
||||
],
|
||||
],
|
||||
'some.route',
|
||||
array('bar' => 'foo'),
|
||||
['bar' => 'foo'],
|
||||
FALSE,
|
||||
),
|
||||
],
|
||||
// One matching, one not.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
[
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
array(
|
||||
'route_params' => ['foo' => 'bar'],
|
||||
],
|
||||
[
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('bar' => 'foo'),
|
||||
),
|
||||
),
|
||||
'route_params' => ['bar' => 'foo'],
|
||||
],
|
||||
],
|
||||
'some.route',
|
||||
array('bar' => 'foo'),
|
||||
['bar' => 'foo'],
|
||||
TRUE,
|
||||
),
|
||||
],
|
||||
// One matching, one not.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
[
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
array(
|
||||
'route_params' => ['foo' => 'bar'],
|
||||
],
|
||||
[
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'baz'),
|
||||
),
|
||||
),
|
||||
'route_params' => ['foo' => 'baz'],
|
||||
],
|
||||
],
|
||||
'some.route',
|
||||
array('foo' => 'baz'),
|
||||
['foo' => 'baz'],
|
||||
TRUE,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,56 +18,56 @@ class TourTestController {
|
|||
* Array of markup.
|
||||
*/
|
||||
public function tourTest1($locale = 'foo') {
|
||||
return array(
|
||||
'tip-1' => array(
|
||||
return [
|
||||
'tip-1' => [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'tour-test-1',
|
||||
),
|
||||
],
|
||||
'#children' => t('Where does the rain in Spain fail?'),
|
||||
),
|
||||
'tip-3' => array(
|
||||
],
|
||||
'tip-3' => [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'tour-test-3',
|
||||
),
|
||||
],
|
||||
'#children' => t('Tip created now?'),
|
||||
),
|
||||
'tip-4' => array(
|
||||
],
|
||||
'tip-4' => [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'tour-test-4',
|
||||
),
|
||||
],
|
||||
'#children' => t('Tip created later?'),
|
||||
),
|
||||
'tip-5' => array(
|
||||
],
|
||||
'tip-5' => [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array('tour-test-5'),
|
||||
),
|
||||
'#attributes' => [
|
||||
'class' => ['tour-test-5'],
|
||||
],
|
||||
'#children' => t('Tip created later?'),
|
||||
),
|
||||
'code-tip-1' => array(
|
||||
],
|
||||
'code-tip-1' => [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'tour-code-test-1',
|
||||
),
|
||||
],
|
||||
'#children' => t('Tip created now?'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs some content for testing tours.
|
||||
*/
|
||||
public function tourTest2() {
|
||||
return array(
|
||||
return [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'tour-test-2',
|
||||
),
|
||||
],
|
||||
'#children' => t('Pangram example'),
|
||||
);
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue