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

This commit is contained in:
Pantheon Automation 2016-09-07 13:26:21 -07:00 committed by Greg Anderson
parent f9f23cdf38
commit 09b113657a
125 changed files with 2307 additions and 385 deletions

View file

@ -0,0 +1,93 @@
<?php
namespace Drupal\KernelTests\Core\Config\Storage;
use Drupal\config\StorageReplaceDataWrapper;
use Drupal\Core\Config\StorageInterface;
/**
* Tests StorageReplaceDataWrapper operations.
*
* @group config
*/
class StorageReplaceDataWrapperTest extends ConfigStorageTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->storage = new StorageReplaceDataWrapper($this->container->get('config.storage'));
// ::listAll() verifications require other configuration data to exist.
$this->storage->write('system.performance', array());
$this->storage->replaceData('system.performance', array('foo' => 'bar'));
}
/**
* {@inheritdoc}
*/
protected function read($name) {
return $this->storage->read($name);
}
/**
* {@inheritdoc}
*/
protected function insert($name, $data) {
$this->storage->write($name, $data);
}
/**
* {@inheritdoc}
*/
protected function update($name, $data) {
$this->storage->write($name, $data);
}
/**
* {@inheritdoc}
*/
protected function delete($name) {
$this->storage->delete($name);
}
/**
* {@inheritdoc}
*/
public function testInvalidStorage() {
// No-op as this test does not make sense.
}
/**
* Tests if new collections created correctly.
*
* @param string $collection
* The collection name.
*
* @dataProvider providerCollections
*/
public function testCreateCollection($collection) {
$initial_collection_name = $this->storage->getCollectionName();
// Create new storage with given collection and check it is set correctly.
$new_storage = $this->storage->createCollection($collection);
$this->assertSame($collection, $new_storage->getCollectionName());
// Check collection not changed in the current storage instance.
$this->assertSame($initial_collection_name, $this->storage->getCollectionName());
}
/**
* Data provider for testing different collections.
*
* @return array
* Returns an array of collection names.
*/
public function providerCollections() {
return [
[StorageInterface::DEFAULT_COLLECTION],
['foo.bar'],
];
}
}

View file

@ -62,9 +62,9 @@ class StableTemplateOverrideTest extends KernelTestBase {
// Enable all core modules.
$all_modules = system_rebuild_module_data();
$all_modules = array_filter($all_modules, function ($module) {
// Filter contrib, hidden, already enabled modules and modules in the
// Testing package.
if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
// Filter contrib, hidden, experimental, already enabled modules, and
// modules in the Testing package.
if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing' || $module->info['package'] == 'Core (Experimental)') {
return FALSE;
}
return TRUE;

View file

@ -1575,7 +1575,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
* Retrieves the plain-text content from the current page.
*/
protected function getTextContent() {
return $this->getSession()->getPage()->getContent();
return $this->getSession()->getPage()->getText();
}
/**

View file

@ -2,6 +2,7 @@
namespace Drupal\Tests\Core\Datetime;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\FormattedDateDiff;
use Drupal\Core\DependencyInjection\ContainerBuilder;
@ -392,6 +393,38 @@ class DateTest extends UnitTestCase {
return $data;
}
/**
* Tests FormattedDateDiff.
*
* @covers \Drupal\Core\Datetime\FormattedDateDiff::toRenderable
* @covers \Drupal\Core\Datetime\FormattedDateDiff::getString
* @covers \Drupal\Core\Datetime\FormattedDateDiff::getCacheMaxAge
*/
public function testFormattedDateDiff() {
$string = '10 minutes';
$max_age = 60;
$object = new FormattedDateDiff($string, $max_age);
// Test conversion to a render array.
$expected = [
'#markup' => $string,
'#cache' => [
'max-age' => $max_age,
],
];
$this->assertArrayEquals($expected, $object->toRenderable());
// Test retrieving the formatted time difference string.
$this->assertEquals($string, $object->getString());
// Test applying cacheability data to an existing build.
$build = [];
CacheableMetadata::createFromObject($object)->applyTo($build);
$this->assertEquals($max_age, $build['#cache']['max-age']);
// Test the BC layer.
$this->assertSame($object->getCacheMaxAge(), $object->getMaxAge());
}
/**
* Creates a UNIX timestamp given a date and time string in the format
* year-month-day hour:minute:seconds (e.g. 2013-12-11 10:09:08).

View file

@ -198,8 +198,8 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase {
/**
* Returns a stub translation manager that just returns the passed string.
*
* @return \PHPUnit_Framework_MockObject_MockBuilder
* A MockBuilder of \Drupal\Core\StringTranslation\TranslationInterface
* @return \PHPUnit_Framework_MockObject_MockObject|\Drupal\Core\StringTranslation\TranslationInterface
* A mock translation object.
*/
public function getStringTranslationStub() {
$translation = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');

View file

@ -13,3 +13,36 @@
./vendor/bin/phpunit -c core --testsuite functional
./vendor/bin/phpunit -c core --testsuite functional-javascript
```
Note: functional tests have to be invoked with a user in the same group as the
web server user. You can either configure Apache (or nginx) to run as your own
system user or run tests as a privileged user instead.
To develop locally, a straigtforward - but also less secure - approach is to run
tests as your own system user. To achieve that, change the default Apache user
to run as your system user. Typically, you'd need to modify
`/etc/apache2/envvars` on Linux or `/etc/apache2/httpd.conf` on Mac.
Example for Linux:
```
export APACHE_RUN_USER=<your-user>
export APACHE_RUN_GROUP=<your-group>
```
Example for Mac:
```
User <your-user>
Group <your-group>
```
If the default user is e.g. `www-data`, the above functional tests will have to
be invoked with sudo instead:
```
export SIMPLETEST_DB='mysql://root@localhost/dev_d8'
export SIMPLETEST_BASE_URL='http://d8.dev'
sudo -u www-data ./vendor/bin/phpunit -c core --testsuite functional
sudo -u www-data ./vendor/bin/phpunit -c core --testsuite functional-javascript
```

View file

@ -51,6 +51,7 @@ function drupal_phpunit_contrib_extension_directory_roots($root = NULL) {
$root . '/core/profiles',
$root . '/modules',
$root . '/profiles',
$root . '/themes',
);
$sites_path = $root . '/sites';
// Note this also checks sites/../modules and sites/../profiles.
@ -61,6 +62,7 @@ function drupal_phpunit_contrib_extension_directory_roots($root = NULL) {
$path = "$sites_path/$site";
$paths[] = is_dir("$path/modules") ? realpath("$path/modules") : NULL;
$paths[] = is_dir("$path/profiles") ? realpath("$path/profiles") : NULL;
$paths[] = is_dir("$path/themes") ? realpath("$path/themes") : NULL;
}
return array_filter($paths);
}