Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668

This commit is contained in:
Pantheon Automation 2015-10-21 21:44:50 -07:00 committed by Greg Anderson
parent f32e58e4b1
commit 8e18df8c36
3062 changed files with 15044 additions and 172506 deletions

View file

@ -7,9 +7,7 @@
namespace Drupal\KernelTests\Component\Utility;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Site\Settings;
use Drupal\Core\Url;
use Drupal\KernelTests\KernelTestBase;

View file

@ -7,11 +7,9 @@
namespace Drupal\KernelTests\Config;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Site\Settings;
use Drupal\KernelTests\AssertConfigTrait;
use Drupal\KernelTests\KernelTestBase;

View file

@ -0,0 +1,148 @@
<?php
/**
* @file
* Contains \Drupal\KernelTests\Core\Entity\RouteProviderTest.
*/
namespace Drupal\KernelTests\Core\Entity;
use Drupal\entity_test\Entity\EntityTestAdminRoutes;
use Drupal\entity_test\Entity\EntityTestMul;
use Drupal\KernelTests\KernelTestBase;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
* Tests route providers for entity types.
*
* @group Entity
*/
class RouteProviderTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['entity_test', 'user', 'system'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test_mul');
$this->installEntitySchema('entity_test_admin_routes');
$this->installSchema('system', 'router');
$router_builder = \Drupal::service('router.builder');
$router_builder->rebuild();
/** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */
$router_builder = \Drupal::service('router.builder');
$router_builder->rebuild();
/** @var \Drupal\user\RoleInterface $role */
$role = Role::create([
'id' => RoleInterface::ANONYMOUS_ID
]);
$role
->grantPermission('administer entity_test content')
->grantPermission('view test entity');
$role->save();
}
protected function httpKernelHandle($url) {
$request = Request::create($url);
/** @var \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel */
$http_kernel = \Drupal::service('http_kernel');
return $http_kernel->handle($request, HttpKernelInterface::SUB_REQUEST)->getContent();
}
/**
* @covers \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getRoutes
*/
public function testHtmlRoutes() {
/** @var \Drupal\Core\Routing\RouteProviderInterface $route_provider */
$route_provider = \Drupal::service('router.route_provider');
$route = $route_provider->getRouteByName('entity.entity_test_mul.canonical');
$this->assertEquals('entity_test_mul.full', $route->getDefault('_entity_view'));
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityController::title', $route->getDefault('_title_callback'));
$this->assertEquals('entity_test_mul.view', $route->getRequirement('_entity_access'));
$this->assertFalse($route->hasOption('_admin_route'));
$route = $route_provider->getRouteByName('entity.entity_test_mul.edit_form');
$this->assertEquals('entity_test_mul.default', $route->getDefault('_entity_form'));
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityController::editTitle', $route->getDefault('_title_callback'));
$this->assertEquals('entity_test_mul.update', $route->getRequirement('_entity_access'));
$this->assertFalse($route->hasOption('_admin_route'));
$route = $route_provider->getRouteByName('entity.entity_test_mul.delete_form');
$this->assertEquals('entity_test_mul.delete', $route->getDefault('_entity_form'));
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityController::deleteTitle', $route->getDefault('_title_callback'));
$this->assertEquals('entity_test_mul.delete', $route->getRequirement('_entity_access'));
$this->assertFalse($route->hasOption('_admin_route'));
$entity = EntityTestMul::create([
'name' => 'Test title',
]);
$entity->save();
$this->setRawContent($this->httpKernelHandle($entity->url()));
$this->assertTitle('Test title | ');
$this->setRawContent($this->httpKernelHandle($entity->url('edit-form')));
$this->assertTitle('Edit Test title | ');
$this->setRawContent($this->httpKernelHandle($entity->url('delete-form')));
$this->assertTitle('Are you sure you want to delete the test entity - data table Test title? | ');
}
/**
* @covers \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider::getEditFormRoute
* @covers \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider::getDeleteFormRoute
*/
public function testAdminHtmlRoutes() {
/** @var \Drupal\Core\Routing\RouteProviderInterface $route_provider */
$route_provider = \Drupal::service('router.route_provider');
$route = $route_provider->getRouteByName('entity.entity_test_admin_routes.canonical');
$this->assertEquals('entity_test_admin_routes.full', $route->getDefault('_entity_view'));
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityController::title', $route->getDefault('_title_callback'));
$this->assertEquals('entity_test_admin_routes.view', $route->getRequirement('_entity_access'));
$this->assertFalse($route->hasOption('_admin_route'));
$route = $route_provider->getRouteByName('entity.entity_test_admin_routes.edit_form');
$this->assertEquals('entity_test_admin_routes.default', $route->getDefault('_entity_form'));
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityController::editTitle', $route->getDefault('_title_callback'));
$this->assertEquals('entity_test_admin_routes.update', $route->getRequirement('_entity_access'));
$this->assertTrue($route->hasOption('_admin_route'));
$this->assertTrue($route->getOption('_admin_route'));
$route = $route_provider->getRouteByName('entity.entity_test_admin_routes.delete_form');
$this->assertEquals('entity_test_admin_routes.delete', $route->getDefault('_entity_form'));
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityController::deleteTitle', $route->getDefault('_title_callback'));
$this->assertEquals('entity_test_admin_routes.delete', $route->getRequirement('_entity_access'));
$this->assertTrue($route->hasOption('_admin_route'));
$this->assertTrue($route->getOption('_admin_route'));
$entity = EntityTestAdminRoutes::create([
'name' => 'Test title',
]);
$entity->save();
$this->setRawContent($this->httpKernelHandle($entity->url()));
$this->assertTitle('Test title | ');
$this->setRawContent($this->httpKernelHandle($entity->url('edit-form')));
$this->assertTitle('Edit Test title | ');
$this->setRawContent($this->httpKernelHandle($entity->url('delete-form')));
$this->assertTitle('Are you sure you want to delete the test entity - admin routes Test title? | ');
}
}

View file

@ -8,7 +8,6 @@
namespace Drupal\Tests\Component\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Exception\LogicException;
/**
* @coversDefaultClass \Drupal\Component\DependencyInjection\PhpArrayContainer

View file

@ -10,8 +10,6 @@ namespace Drupal\Tests\Component\EventDispatcher;
use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\Tests\AbstractEventDispatcherTest;
use Symfony\Component\EventDispatcher\Tests\CallableClass;
use Symfony\Component\EventDispatcher\Tests\TestEventListener;

View file

@ -489,7 +489,7 @@ class XssTest extends UnitTestCase {
}
/**
* Check that strings in HTML attributes are are correctly processed.
* Check that strings in HTML attributes are correctly processed.
*
* @covers ::attributes
* @dataProvider providerTestAttributes

View file

@ -9,7 +9,6 @@ namespace Drupal\Tests\Core\Access;
use Drupal\Core\Access\AccessCheckInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Access\CheckProvider;
use Drupal\Core\Cache\Context\CacheContextsManager;
use Drupal\Core\Routing\RouteMatch;

View file

@ -11,7 +11,6 @@ use Drupal\Core\Site\Settings;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Access\CsrfTokenGenerator;
use Drupal\Component\Utility\Crypt;
use Symfony\Component\HttpFoundation\Request;
/**
* Tests the CsrfTokenGenerator class.

View file

@ -9,7 +9,6 @@ namespace Drupal\Tests\Core\Ajax;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\EventSubscriber\AjaxResponseSubscriber;
use Drupal\Core\Render\Element\Ajax;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;

View file

@ -7,10 +7,8 @@
namespace Drupal\Tests\Core\Cache;
use Drupal\Component\Assertion\Inspector;
use Drupal\Core\Cache\Cache;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* @coversDefaultClass \Drupal\Core\Cache\Cache

View file

@ -8,7 +8,6 @@
namespace Drupal\Tests\Core\Condition;
use Drupal\Component\Plugin\Exception\ContextException;
use Drupal\Core\Condition\ConditionAccessResolverTrait;
use Drupal\Tests\UnitTestCase;
/**

View file

@ -11,7 +11,6 @@ use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Render\Markup;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Config\Config;
use Drupal\Component\Utility\SafeMarkup;
/**
* Tests the Config.

View file

@ -8,7 +8,6 @@
namespace Drupal\Tests\Core\Database;
use Drupal\Tests\Core\Database\Stub\StubConnection;
use Drupal\Tests\Core\Database\Stub\StubPDO;
use Drupal\Tests\UnitTestCase;
/**

View file

@ -7,7 +7,6 @@
namespace Drupal\Tests\Core\Database\Driver\pgsql;
use Drupal\Core\Database\Driver\pgsql\Connection;
use Drupal\Tests\Core\Database\Stub\StubPDO;
use Drupal\Tests\UnitTestCase;
/**

View file

@ -7,7 +7,6 @@
namespace Drupal\Tests\Core\DependencyInjection\Compiler;
use Drupal\Core\Database\Driver\sqlite\Connection;
use Drupal\Core\DependencyInjection\Compiler\BackendCompilerPass;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\Alias;

View file

@ -11,7 +11,6 @@ namespace Drupal\Tests\Core\DependencyInjection\Compiler;
use Drupal\Core\DependencyInjection\Compiler\ProxyServicesPass;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\Reference;
/**
* @coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\ProxyServicesPass

View file

@ -98,7 +98,7 @@ class StackedKernelPassTest extends UnitTestCase {
* Creates a middleware definition.
*
* @param bool $tag
* Whether ot not to set the http_middleware tag.
* Whether or not to set the http_middleware tag.
* @param int $priority
* The priority to be used for the tag.
*

View file

@ -11,9 +11,7 @@ use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\Cache;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\Entity;
use Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException;
use Drupal\Core\Language\Language;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\entity_test\Entity\EntityTestMul;
use Drupal\Tests\UnitTestCase;

View file

@ -6,8 +6,8 @@
*/
namespace Drupal\Tests\Core\Entity\Sql;
use Drupal\Core\Entity\Sql\DefaultTableMapping;
use Drupal\Core\Entity\Sql\SqlContentEntityStorageException;
use Drupal\Tests\UnitTestCase;
/**

View file

@ -11,10 +11,7 @@ use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

View file

@ -7,11 +7,9 @@
namespace Drupal\Tests\Core\Entity\TypedData;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\Plugin\DataType\EntityAdapter;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Language\Language;

View file

@ -7,7 +7,6 @@
namespace Drupal\Tests\Core\Form\EventSubscriber;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber;
use Drupal\Core\Form\Exception\BrokenPostRequestException;
@ -18,7 +17,6 @@ use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;

View file

@ -7,7 +7,6 @@
namespace Drupal\Tests\Core\Form;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Form\FormCache;
use Drupal\Core\Form\FormState;
use Drupal\Tests\UnitTestCase;

View file

@ -12,11 +12,9 @@ use Drupal\Core\Form\FormBuilder;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
/**
* Provides a base class for testing form functionality.

View file

@ -8,9 +8,7 @@
namespace Drupal\Tests\Core\Logger;
use Drupal\Core\Logger\LoggerChannelFactory;
use Drupal\Core\Session\AccountInterface;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
/**
* @coversDefaultClass \Drupal\Core\Logger\LoggerChannelFactory

View file

@ -10,7 +10,6 @@ namespace Drupal\Tests\Core\Menu;
use Drupal\Core\Menu\ContextualLinkDefault;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
/**

View file

@ -10,7 +10,6 @@ namespace Drupal\Tests\Core\Menu;
use Drupal\Core\Menu\LocalActionDefault;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
/**

View file

@ -14,7 +14,6 @@ use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessResultForbidden;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Menu\LocalActionManager;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Routing\RouteProviderInterface;

View file

@ -7,7 +7,6 @@
namespace Drupal\Tests\Core\Menu;
use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator;
use Drupal\Core\Plugin\Discovery\YamlDiscovery;
use Drupal\Tests\UnitTestCase;

View file

@ -21,7 +21,6 @@ use Prophecy\Argument;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Zend\Stdlib\ArrayObject;
/**
* @coversDefaultClass \Drupal\Core\Menu\LocalTaskManager

View file

@ -339,14 +339,10 @@ class AliasManagerTest extends UnitTestCase {
// Call it twice to test the static cache.
$this->assertEquals($alias, $this->aliasManager->getAliasByPath($path));
// This needs to write out the cache.
$expected_new_cache = array(
$cached_language->getId() => array($path),
$language->getId() => array($path),
);
$this->cache->expects($this->once())
->method('set')
->with($this->cacheKey, $expected_new_cache, (int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24));
// There is already a cache entry, so this should not write out to the
// cache.
$this->cache->expects($this->never())
->method('set');
$this->aliasManager->writeCache();
}
@ -441,13 +437,10 @@ class AliasManagerTest extends UnitTestCase {
// Call it twice to test the static cache.
$this->assertEquals($path, $this->aliasManager->getAliasByPath($path));
// This needs to write out the cache.
$expected_new_cache = array(
$language->getId() => array($cached_path, $path),
);
$this->cache->expects($this->once())
->method('set')
->with($this->cacheKey, $expected_new_cache, (int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24));
// There is already a cache entry, so this should not write out to the
// cache.
$this->cache->expects($this->never())
->method('set');
$this->aliasManager->writeCache();
}
@ -533,13 +526,10 @@ class AliasManagerTest extends UnitTestCase {
// Call it twice to test the static cache.
$this->assertEquals($new_alias, $this->aliasManager->getAliasByPath($path));
// This needs to write out the cache.
$expected_new_cache = array(
$language->getId() => array($cached_path, $path, $cached_no_alias_path),
);
$this->cache->expects($this->once())
->method('set')
->with($this->cacheKey, $expected_new_cache, (int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24));
// There is already a cache entry, so this should not write out to the
// cache.
$this->cache->expects($this->never())
->method('set');
$this->aliasManager->writeCache();
}

View file

@ -8,7 +8,6 @@
namespace Drupal\Tests\Core\Plugin\Discovery;
use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
use Drupal\Component\Plugin\Exception\InvalidDeriverException;
use Drupal\Tests\UnitTestCase;
/**

View file

@ -8,7 +8,6 @@
namespace Drupal\Tests\Core\Render;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Tests\UnitTestCase;

View file

@ -11,7 +11,6 @@ use Drupal\Core\Form\FormState;
use Drupal\Core\Link;
use Drupal\Core\Render\Element\Tableselect;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\StringTranslation\TranslationWrapper;
use Drupal\Core\Url;
use Drupal\Tests\UnitTestCase;

View file

@ -10,7 +10,6 @@ namespace Drupal\Tests\Core\Render;
use Drupal\Core\Cache\MemoryBackend;
use Drupal\Core\KeyValueStore\KeyValueMemoryFactory;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Renderer;
use Drupal\Core\State\State;
use Drupal\Core\Cache\Cache;

View file

@ -11,7 +11,6 @@ use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessResultInterface;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Markup;
use Drupal\Core\Template\Attribute;
@ -97,7 +96,7 @@ class RendererTest extends RendererTestBase {
'#plain_text' => '<em>foo</em>',
'#markup' => 'bar',
], '&lt;em&gt;foo&lt;/em&gt;'];
// Safe strings in #plain_text are are still escaped.
// Safe strings in #plain_text are still escaped.
$data[] = [[
'#plain_text' => Markup::create('<em>foo</em>'),
], '&lt;em&gt;foo&lt;/em&gt;'];

View file

@ -8,7 +8,6 @@
namespace Drupal\Tests\Core\Routing;
use Drupal\Core\Routing\ContentTypeHeaderMatcher;
use Drupal\Tests\Core\Routing\RoutingFixtures;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;

View file

@ -8,8 +8,6 @@
namespace Drupal\Tests\Core\Routing;
use Drupal\Core\Routing\CurrentRouteMatch;
use Drupal\Core\Routing\RouteMatch;
use Drupal\Tests\UnitTestCase;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;

View file

@ -8,7 +8,6 @@
namespace Drupal\Tests\Core\Routing;
use Drupal\Core\Routing\RouteMatch;
use Drupal\Tests\UnitTestCase;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;

View file

@ -9,9 +9,6 @@ namespace Drupal\Tests\Core\Routing;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Tests\UnitTestCase;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
/**

View file

@ -7,10 +7,14 @@
namespace Drupal\Tests\Core\Routing;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\CacheableRedirectResponse;
use Drupal\Core\Cache\CacheableResponseInterface;
use Drupal\Core\Routing\RequestContext;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* @coversDefaultClass \Drupal\Core\Routing\TrustedRedirectResponse
@ -54,4 +58,32 @@ class TrustedRedirectResponseTest extends UnitTestCase {
$this->assertEquals('http://good-external-url.com/example', $redirect_response->getTargetUrl());
}
/**
* @covers ::createFromRedirectResponse
* @dataProvider providerCreateFromRedirectResponse
*/
public function testCreateFromRedirectResponse($redirect_response) {
$trusted_redirect_response = TrustedRedirectResponse::createFromRedirectResponse($redirect_response);
// The trusted redirect response is always a CacheableResponseInterface instance.
$this->assertTrue($trusted_redirect_response instanceof CacheableResponseInterface);
// But it is only actually cacheable (non-zero max-age) if the redirect
// response passed to TrustedRedirectResponse::createFromRedirectResponse()
// is itself cacheable.
$expected_cacheability = ($redirect_response instanceof CacheableResponseInterface) ? $redirect_response->getCacheableMetadata() : (new CacheableMetadata())->setCacheMaxAge(0);
$this->assertEquals($expected_cacheability, $trusted_redirect_response->getCacheableMetadata());
}
/**
* @return array
*/
public function providerCreateFromRedirectResponse() {
return [
'cacheable-with-tags' => [(new CacheableRedirectResponse('/example'))->addCacheableDependency((new CacheableMetadata())->addCacheTags(['foo']))],
'cacheable-with-max-age-0' => [(new CacheableRedirectResponse('/example'))->addCacheableDependency((new CacheableMetadata())->setCacheMaxAge(0))],
'uncacheable' => [new RedirectResponse('/example')],
];
}
}

View file

@ -9,11 +9,7 @@ namespace Drupal\Tests\Core\Session;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\user\RoleInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Scope;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\user\RoleInterface;
/**
* @coversDefaultClass \Drupal\Core\Session\AnonymousUserSession

View file

@ -12,7 +12,6 @@ use Drupal\Core\Session\PermissionsHashGenerator;
use Drupal\Core\Site\Settings;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\Core\Session\PermissionsHashGenerator
* @group Session

View file

@ -8,7 +8,6 @@
namespace Drupal\Tests\Core\Session;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Session\SessionConfiguration;
use Symfony\Component\HttpFoundation\Request;
/**

View file

@ -66,13 +66,11 @@ class ReverseProxyMiddlewareTest extends UnitTestCase {
return array(
array(
array(
'reverse_proxy_header' => 'HTTP_X_FORWARDED_FOR',
'reverse_proxy_addresses' => array(),
),
),
array(
array(
'reverse_proxy_header' => 'X_FORWARDED_HOST',
'reverse_proxy_header' => 'X_FORWARDED_FOR_CUSTOMIZED',
'reverse_proxy_proto_header' => 'X_FORWARDED_PROTO_CUSTOMIZED',
'reverse_proxy_host_header' => 'X_FORWARDED_HOST_CUSTOMIZED',
'reverse_proxy_port_header' => 'X_FORWARDED_PORT_CUSTOMIZED',
'reverse_proxy_forwarded_header' => 'FORWARDED_CUSTOMIZED',
'reverse_proxy_addresses' => array('127.0.0.2', '127.0.0.3'),
),
),
@ -95,6 +93,10 @@ class ReverseProxyMiddlewareTest extends UnitTestCase {
$middleware->handle($request);
$this->assertSame($settings->get('reverse_proxy_header'), $request->getTrustedHeaderName($request::HEADER_CLIENT_IP));
$this->assertSame($settings->get('reverse_proxy_proto_header'), $request->getTrustedHeaderName($request::HEADER_CLIENT_PROTO));
$this->assertSame($settings->get('reverse_proxy_host_header'), $request->getTrustedHeaderName($request::HEADER_CLIENT_HOST));
$this->assertSame($settings->get('reverse_proxy_port_header'), $request->getTrustedHeaderName($request::HEADER_CLIENT_PORT));
$this->assertSame($settings->get('reverse_proxy_forwarded_header'), $request->getTrustedHeaderName($request::HEADER_FORWARDED));
$this->assertSame($settings->get('reverse_proxy_addresses'), $request->getTrustedProxies());
}
}

View file

@ -10,8 +10,6 @@ namespace Drupal\Tests\Core\Theme;
use Drupal\Core\Routing\RouteMatch;
use Drupal\Core\Theme\ThemeNegotiator;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Route;
/**

View file

@ -9,7 +9,6 @@ namespace Drupal\Tests;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Utility\Random;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\StringTranslation\TranslatableMarkup;