Move into nested docroot
This commit is contained in:
parent
83a0d3a149
commit
c8b70abde9
13405 changed files with 0 additions and 0 deletions
42
web/core/modules/tour/tests/src/Kernel/TourPluginTest.php
Normal file
42
web/core/modules/tour/tests/src/Kernel/TourPluginTest.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\tour\Kernel;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests the functionality of tour plugins.
|
||||
*
|
||||
* @group tour
|
||||
*/
|
||||
class TourPluginTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('tour');
|
||||
|
||||
/**
|
||||
* Stores the tour plugin manager.
|
||||
*
|
||||
* @var \Drupal\tour\TipPluginManager
|
||||
*/
|
||||
protected $pluginManager;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installConfig(array('tour'));
|
||||
$this->pluginManager = $this->container->get('plugin.manager.tour.tip');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test tour plugins.
|
||||
*/
|
||||
public function testTourPlugins() {
|
||||
$this->assertIdentical(count($this->pluginManager->getDefinitions()), 1, 'Only tour plugins for the enabled modules were returned.');
|
||||
}
|
||||
|
||||
}
|
138
web/core/modules/tour/tests/src/Unit/Entity/TourTest.php
Normal file
138
web/core/modules/tour/tests/src/Unit/Entity/TourTest.php
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\tour\Unit\Entity;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\tour\Entity\Tour
|
||||
* @group tour
|
||||
*/
|
||||
class TourTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests \Drupal\tour\Entity\Tour::hasMatchingRoute().
|
||||
*
|
||||
* @param array $routes
|
||||
* Array of routes as per the Tour::routes property.
|
||||
* @param string $route_name
|
||||
* The route name to match.
|
||||
* @param array $route_params
|
||||
* Array of route params.
|
||||
* @param bool $result
|
||||
* Expected result.
|
||||
*
|
||||
* @covers ::hasMatchingRoute
|
||||
*
|
||||
* @dataProvider routeProvider
|
||||
*/
|
||||
public function testHasMatchingRoute($routes, $route_name, $route_params, $result) {
|
||||
$tour = $this->getMockBuilder('\Drupal\tour\Entity\Tour')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getRoutes'))
|
||||
->getMock();
|
||||
|
||||
$tour->expects($this->any())
|
||||
->method('getRoutes')
|
||||
->will($this->returnValue($routes));
|
||||
|
||||
$this->assertSame($result, $tour->hasMatchingRoute($route_name, $route_params));
|
||||
|
||||
$tour->resetKeyedRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides sample routes for testing.
|
||||
*/
|
||||
public function routeProvider() {
|
||||
return array(
|
||||
// Simple match.
|
||||
array(
|
||||
array(
|
||||
array('route_name' => 'some.route'),
|
||||
),
|
||||
'some.route',
|
||||
array(),
|
||||
TRUE,
|
||||
),
|
||||
// Simple non-match.
|
||||
array(
|
||||
array(
|
||||
array('route_name' => 'another.route'),
|
||||
),
|
||||
'some.route',
|
||||
array(),
|
||||
FALSE,
|
||||
),
|
||||
// Empty params.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
),
|
||||
'some.route',
|
||||
array(),
|
||||
FALSE,
|
||||
),
|
||||
// Match on params.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
),
|
||||
'some.route',
|
||||
array('foo' => 'bar'),
|
||||
TRUE,
|
||||
),
|
||||
// Non-matching params.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
),
|
||||
'some.route',
|
||||
array('bar' => 'foo'),
|
||||
FALSE,
|
||||
),
|
||||
// One matching, one not.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
array(
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('bar' => 'foo'),
|
||||
),
|
||||
),
|
||||
'some.route',
|
||||
array('bar' => 'foo'),
|
||||
TRUE,
|
||||
),
|
||||
// One matching, one not.
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'bar'),
|
||||
),
|
||||
array(
|
||||
'route_name' => 'some.route',
|
||||
'route_params' => array('foo' => 'baz'),
|
||||
),
|
||||
),
|
||||
'some.route',
|
||||
array('foo' => 'baz'),
|
||||
TRUE,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
label: Tour test italian
|
||||
tips:
|
||||
tour-test-1:
|
||||
label: La pioggia cade in spagna
|
||||
body: Per lo più in pianura.
|
|
@ -0,0 +1,15 @@
|
|||
id: tour-test-2
|
||||
module: tour_test
|
||||
label: 'Tour test english'
|
||||
langcode: en
|
||||
routes:
|
||||
- route_name: tour_test.2
|
||||
tips:
|
||||
tour-test-2:
|
||||
id: tour-test-2
|
||||
plugin: text
|
||||
label: 'The quick brown fox'
|
||||
body: 'Per lo più in pianura.'
|
||||
weight: 2
|
||||
attributes:
|
||||
data-id: tour-test-2
|
|
@ -0,0 +1,40 @@
|
|||
id: tour-test
|
||||
module: tour_test
|
||||
label: 'Tour test english'
|
||||
langcode: en
|
||||
routes:
|
||||
- route_name: tour_test.1
|
||||
- route_name: tour_test.3
|
||||
route_params:
|
||||
locale: foo
|
||||
tips:
|
||||
tour-test-1:
|
||||
id: tour-test-1
|
||||
plugin: text
|
||||
label: 'The first tip'
|
||||
body: 'Is <a href="[site:url]">[site:name]</a> always the best dressed?'
|
||||
weight: 1
|
||||
attributes:
|
||||
data-id: tour-test-1
|
||||
tour-test-action:
|
||||
id: tour-test-3
|
||||
plugin: text
|
||||
label: 'The action'
|
||||
body: 'The action button of awesome'
|
||||
weight: 2
|
||||
attributes:
|
||||
data-class: button-action
|
||||
tour-test-3:
|
||||
id: tour-test-3
|
||||
plugin: image
|
||||
label: 'The awesome image'
|
||||
url: 'http://local/image.png'
|
||||
weight: 1
|
||||
tour-test-6:
|
||||
id: tour-test-6
|
||||
plugin: text
|
||||
label: 'Im a list'
|
||||
body: '<p>Im all these things:</p><ul><li>Modal</li><li>Awesome</li></ul>'
|
||||
weight: 6
|
||||
attributes:
|
||||
data-id: tour-test-3
|
|
@ -0,0 +1,9 @@
|
|||
# Schema for the configuration files of the Tour Test module.
|
||||
|
||||
tour.tip.image:
|
||||
type: tour.tip
|
||||
label: 'Image tour tip'
|
||||
mapping:
|
||||
url:
|
||||
type: uri
|
||||
label: 'Image URL'
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tour_test\Controller;
|
||||
|
||||
/**
|
||||
* Controller routines for tour_test routes.
|
||||
*/
|
||||
class TourTestController {
|
||||
|
||||
/**
|
||||
* Outputs some content for testing tours.
|
||||
*
|
||||
* @param string $locale
|
||||
* (optional) Dummy locale variable for testing routing parameters. Defaults
|
||||
* to 'foo'.
|
||||
*
|
||||
* @return array
|
||||
* Array of markup.
|
||||
*/
|
||||
public function tourTest1($locale = 'foo') {
|
||||
return array(
|
||||
'tip-1' => array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'id' => 'tour-test-1',
|
||||
),
|
||||
'#children' => t('Where does the rain in Spain fail?'),
|
||||
),
|
||||
'tip-3' => array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'id' => 'tour-test-3',
|
||||
),
|
||||
'#children' => t('Tip created now?'),
|
||||
),
|
||||
'tip-4' => array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'id' => 'tour-test-4',
|
||||
),
|
||||
'#children' => t('Tip created later?'),
|
||||
),
|
||||
'tip-5' => array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array('tour-test-5'),
|
||||
),
|
||||
'#children' => t('Tip created later?'),
|
||||
),
|
||||
'code-tip-1' => array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'id' => 'tour-code-test-1',
|
||||
),
|
||||
'#children' => t('Tip created now?'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs some content for testing tours.
|
||||
*/
|
||||
public function tourTest2() {
|
||||
return array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'id' => 'tour-test-2',
|
||||
),
|
||||
'#children' => t('Pangram example'),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tour_test\Plugin\tour\tip;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\tour\TipPluginBase;
|
||||
|
||||
/**
|
||||
* Displays an image as a tip.
|
||||
*
|
||||
* @Tip(
|
||||
* id = "image",
|
||||
* title = @Translation("Image")
|
||||
* )
|
||||
*/
|
||||
class TipPluginImage extends TipPluginBase {
|
||||
|
||||
/**
|
||||
* The url which is used for the image in this Tip.
|
||||
*
|
||||
* @var string
|
||||
* A url used for the image.
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* The alt text which is used for the image in this Tip.
|
||||
*
|
||||
* @var string
|
||||
* A alt text used for the image.
|
||||
*/
|
||||
protected $alt;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOutput() {
|
||||
$prefix = '<h2 class="tour-tip-label" id="tour-tip-' . $this->get('ariaId') . '-label">' . Html::escape($this->get('label')) . '</h2>';
|
||||
$prefix .= '<p class="tour-tip-image" id="tour-tip-' . $this->get('ariaId') . '-contents">';
|
||||
return [
|
||||
'#prefix' => $prefix,
|
||||
'#theme' => 'image',
|
||||
'#uri' => $this->get('url'),
|
||||
'#alt' => $this->get('alt'),
|
||||
'#suffix' => '</p>',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
8
web/core/modules/tour/tests/tour_test/tour_test.info.yml
Normal file
8
web/core/modules/tour/tests/tour_test/tour_test.info.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
name: Tour module tests
|
||||
type: module
|
||||
description: Tests module for tour module.
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- tour
|
|
@ -0,0 +1,5 @@
|
|||
tour_test_action:
|
||||
route_name: tour_test.1_action
|
||||
title: 'Tour test action'
|
||||
appears_on:
|
||||
- tour_test.1
|
37
web/core/modules/tour/tests/tour_test/tour_test.module
Normal file
37
web/core/modules/tour/tests/tour_test/tour_test.module
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides tests for tour module
|
||||
*/
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_load() for tour.
|
||||
*/
|
||||
function tour_test_tour_load($entities) {
|
||||
if (isset($entities['tour-entity-create-test-en'])) {
|
||||
$entities['tour-entity-create-test-en']->loaded = 'Load hooks work';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_presave() for tour.
|
||||
*/
|
||||
function tour_test_tour_presave($entity) {
|
||||
if ($entity->id() == 'tour-entity-create-test-en') {
|
||||
$entity->set('label', $entity->label() . ' alter');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_tour_tips_alter().
|
||||
*/
|
||||
function tour_test_tour_tips_alter(array &$tour_tips, EntityInterface $entity) {
|
||||
foreach ($tour_tips as $tour_tip) {
|
||||
if ($tour_tip->get('id') == 'tour-code-test-1') {
|
||||
$tour_tip->set('body', 'Altered by hook_tour_tips_alter');
|
||||
}
|
||||
}
|
||||
}
|
31
web/core/modules/tour/tests/tour_test/tour_test.routing.yml
Normal file
31
web/core/modules/tour/tests/tour_test/tour_test.routing.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
tour_test.1:
|
||||
path: '/tour-test-1'
|
||||
defaults:
|
||||
_controller: '\Drupal\tour_test\Controller\TourTestController::tourTest1'
|
||||
options:
|
||||
_admin_route: TRUE
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
tour_test.1_action:
|
||||
path: '/tour-test-1/action'
|
||||
defaults:
|
||||
_controller: '\Drupal\tour_test\Controller\TourTestController::tourTest1'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
tour_test.2:
|
||||
path: '/tour-test-2/subpath'
|
||||
defaults:
|
||||
_controller: '\Drupal\tour_test\Controller\TourTestController::tourTest2'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
tour_test.3:
|
||||
path: '/tour-test-3/{locale}'
|
||||
defaults:
|
||||
locale: 'foo'
|
||||
_controller: '\Drupal\tour_test\Controller\TourTestController::tourTest1'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
Reference in a new issue