Update to Drupal 8.2.2. For more information, see https://www.drupal.org/project/drupal/releases/8.2.2

This commit is contained in:
Pantheon Automation 2016-11-02 11:43:31 -07:00 committed by Greg Anderson
parent 23ffed3665
commit 507b45a0ed
378 changed files with 11434 additions and 5542 deletions

View file

@ -528,10 +528,11 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
* The file path.
*/
public static function filePreDeleteCallback($path) {
$success = @chmod($path, 0700);
if (!$success) {
trigger_error("Can not make $path writable whilst cleaning up test directory. The webserver and phpunit are probably not being run by the same user.");
}
// When the webserver runs with the same system user as phpunit, we can
// make read-only files writable again. If not, chmod will fail while the
// file deletion still works if file permissions have been configured
// correctly. Thus, we ignore any problems while running chmod.
@chmod($path, 0700);
}
/**

View file

@ -86,7 +86,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$path = substr($path, strlen($this->root) + 1);
$this->libraryDiscoveryParser->setPaths('module', 'example_module', $path);
$libraries = $this->libraryDiscoveryParser->buildByExtension('example_module', 'example');
$libraries = $this->libraryDiscoveryParser->buildByExtension('example_module');
$library = $libraries['example'];
$this->assertCount(0, $library['js']);

View file

@ -0,0 +1,85 @@
<?php
namespace Drupal\Tests\Core\Cache\Context;
use Drupal\Core\Cache\Context\SessionCacheContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* @coversDefaultClass \Drupal\Core\Cache\Context\SessionCacheContext
* @group Cache
*/
class SessionCacheContextTest extends \PHPUnit_Framework_TestCase {
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* The session object.
*
* @var \Symfony\Component\HttpFoundation\Session\SessionInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $session;
/**
* The session cache context.
*
* @var \Drupal\Core\Cache\Context\SessionCacheContext
*/
protected $cacheContext;
public function setUp() {
$request = new Request();
$this->requestStack = new RequestStack();
$this->requestStack->push($request);
$this->session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface');
$request->setSession($this->session);
$this->cacheContext = new SessionCacheContext($this->requestStack);
}
/**
* @covers ::getContext
*/
public function testSameContextForSameSession() {
$session_id = 'aSebeZ52bbM6SvADurQP89SFnEpxY6j8';
$this->session->expects($this->exactly(2))
->method('getId')
->will($this->returnValue($session_id));
$context1 = $this->cacheContext->getContext();
$context2 = $this->cacheContext->getContext();
$this->assertSame($context1, $context2);
$this->assertSame(FALSE, strpos($context1, $session_id), 'Session ID not contained in cache context');
}
/**
* @covers ::getContext
*/
public function testDifferentContextForDifferentSession() {
$session1_id = 'pjH_8aSoofyCDQiuVYXJcbfyr-CPtkUY';
$this->session->expects($this->at(0))
->method('getId')
->will($this->returnValue($session1_id));
$session2_id = 'aSebeZ52bbM6SvADurQP89SFnEpxY6j8';
$this->session->expects($this->at(1))
->method('getId')
->will($this->returnValue($session2_id));
$context1 = $this->cacheContext->getContext();
$context2 = $this->cacheContext->getContext();
$this->assertNotEquals($context1, $context2);
$this->assertSame(FALSE, strpos($context1, $session1_id), 'Session ID not contained in cache context');
$this->assertSame(FALSE, strpos($context2, $session2_id), 'Session ID not contained in cache context');
}
}

View file

@ -416,6 +416,27 @@ class EntityResolverManagerTest extends UnitTestCase {
$this->assertEquals($expect, $parameters);
}
/**
* Tests setRouteOptions() with an _entity_form route for an add form.
*
* @covers ::setRouteOptions
* @covers ::getControllerClass
* @covers ::getEntityTypes
* @covers ::setParametersFromReflection
* @covers ::setParametersFromEntityInformation
*/
public function testSetRouteOptionsWithEntityAddFormRoute() {
$this->setupEntityTypes();
$route = new Route('/example/add', array(
'_entity_form' => 'entity_test.add',
));
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
$this->assertEquals($defaults, $route->getDefaults());
$this->assertFalse($route->hasOption('parameters'));
}
/**
* Creates the entity manager mock returning entity type objects.
*/

View file

@ -43,6 +43,11 @@ class PathRootsSubscriberTest extends UnitTestCase {
* @covers ::onRouteFinished
*/
public function testSubscribing() {
// Ensure that onRouteFinished can be called without throwing notices
// when no path roots got set.
$this->pathRootsSubscriber->onRouteFinished();
$route_collection = new RouteCollection();
$route_collection->add('test_route1', new Route('/test/bar'));
$route_collection->add('test_route2', new Route('/test/baz'));

View file

@ -568,6 +568,29 @@ class FormBuilderTest extends FormTestBase {
$this->formBuilder->buildForm($form_arg, $form_state);
}
/**
* @covers ::buildForm
*/
public function testGetPostAjaxRequest() {
$request = new Request([FormBuilderInterface::AJAX_FORM_REQUEST => TRUE], ['form_id' => 'different_form_id']);
$request->setMethod('POST');
$this->requestStack->push($request);
$form_state = (new FormState())
->setUserInput([FormBuilderInterface::AJAX_FORM_REQUEST => TRUE])
->setMethod('get')
->setAlwaysProcess()
->disableRedirect()
->set('ajax', TRUE);
$form_id = '\Drupal\Tests\Core\Form\TestForm';
$expected_form = (new TestForm())->buildForm([], $form_state);
$form = $this->formBuilder->buildForm($form_id, $form_state);
$this->assertFormElement($expected_form, $form, 'test');
$this->assertSame('test-form', $form['#id']);
}
/**
* @covers ::buildForm
*

View file

@ -4,12 +4,16 @@ namespace Drupal\Tests\Core\Routing;
use Drupal\Core\Routing\ContentTypeHeaderMatcher;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
/**
* Confirm that the content types partial matcher is functioning properly.
*
* @group Routing
*
* @coversDefaultClass \Drupal\Core\Routing\ContentTypeHeaderMatcher
*/
class ContentTypeHeaderMatcherTest extends UnitTestCase {
@ -88,8 +92,7 @@ class ContentTypeHeaderMatcherTest extends UnitTestCase {
/**
* Confirms that the matcher throws an exception for no-route.
*
* @expectedException \Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException
* @expectedExceptionMessage No route found that matches "Content-Type: application/hal+json"
* @covers ::filter
*/
public function testNoRouteFound() {
$matcher = new ContentTypeHeaderMatcher();
@ -97,8 +100,24 @@ class ContentTypeHeaderMatcherTest extends UnitTestCase {
$routes = $this->fixtures->contentRouteCollection();
$request = Request::create('path/two', 'POST');
$request->headers->set('Content-type', 'application/hal+json');
$this->setExpectedException(UnsupportedMediaTypeHttpException::class, 'No route found that matches "Content-Type: application/hal+json"');
$matcher->filter($routes, $request);
}
/**
* Confirms that the matcher throws an exception for missing request header.
*
* @covers ::filter
*/
public function testContentTypeRequestHeaderMissing() {
$matcher = new ContentTypeHeaderMatcher();
$routes = $this->fixtures->contentRouteCollection();
$request = Request::create('path/two', 'POST');
// Delete all request headers that Request::create() sets by default.
$request->headers = new ParameterBag();
$this->setExpectedException(UnsupportedMediaTypeHttpException::class, 'No "Content-Type" request header specified');
$matcher->filter($routes, $request);
$this->fail('No exception was thrown.');
}
}