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:
parent
23ffed3665
commit
507b45a0ed
378 changed files with 11434 additions and 5542 deletions
|
@ -113,6 +113,19 @@ class FetchTest extends DatabaseTestBase {
|
|||
$this->assertIdentical(count($records), 1, 'There is only one record.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms that we can fetch all records into an array explicitly.
|
||||
*/
|
||||
public function testQueryFetchAllColumn() {
|
||||
$query = db_select('test');
|
||||
$query->addField('test', 'name');
|
||||
$query->orderBy('name');
|
||||
$query_result = $query->execute()->fetchAll(\PDO::FETCH_COLUMN);
|
||||
|
||||
$expected_result = ['George', 'John', 'Paul', 'Ringo'];
|
||||
$this->assertEqual($query_result, $expected_result, 'Returned the correct result.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms that we can fetch an entire column of a result set at once.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\KernelTests\Core\Datetime;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
|
||||
/**
|
||||
* Tests date formatting.
|
||||
*
|
||||
* @group Common
|
||||
*/
|
||||
class FormatDateTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['language', 'system'];
|
||||
|
||||
/**
|
||||
* Arbitrary langcode for a custom language.
|
||||
*/
|
||||
const LANGCODE = 'xx';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installConfig(['system']);
|
||||
|
||||
$this->setSetting('locale_custom_strings_' . self::LANGCODE, [
|
||||
'' => ['Sunday' => 'domingo'],
|
||||
'Long month name' => ['March' => 'marzo'],
|
||||
]);
|
||||
|
||||
$formats = $this->container->get('entity.manager')
|
||||
->getStorage('date_format')
|
||||
->loadMultiple(['long', 'medium', 'short']);
|
||||
$formats['long']->setPattern('l, j. F Y - G:i')->save();
|
||||
$formats['medium']->setPattern('j. F Y - G:i')->save();
|
||||
$formats['short']->setPattern('Y M j - g:ia')->save();
|
||||
|
||||
ConfigurableLanguage::createFromLangcode(static::LANGCODE)->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the format_date() function.
|
||||
*/
|
||||
public function testFormatDate() {
|
||||
/** @var \Drupal\Core\Datetime\DateFormatterInterface $formatter */
|
||||
$formatter = $this->container->get('date.formatter');
|
||||
|
||||
$timestamp = strtotime('2007-03-26T00:00:00+00:00');
|
||||
$this->assertSame('Sunday, 25-Mar-07 17:00:00 PDT', $formatter->format($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Test all parameters.');
|
||||
$this->assertSame('domingo, 25-Mar-07 17:00:00 PDT', $formatter->format($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'Test translated format.');
|
||||
$this->assertSame('l, 25-Mar-07 17:00:00 PDT', $formatter->format($timestamp, 'custom', '\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'Test an escaped format string.');
|
||||
$this->assertSame('\\domingo, 25-Mar-07 17:00:00 PDT', $formatter->format($timestamp, 'custom', '\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'Test format containing backslash character.');
|
||||
$this->assertSame('\\l, 25-Mar-07 17:00:00 PDT', $formatter->format($timestamp, 'custom', '\\\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'Test format containing backslash followed by escaped format string.');
|
||||
$this->assertSame('Monday, 26-Mar-07 01:00:00 BST', $formatter->format($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Test a different time zone.');
|
||||
|
||||
// Change the default language and timezone.
|
||||
$this->config('system.site')->set('default_langcode', static::LANGCODE)->save();
|
||||
date_default_timezone_set('America/Los_Angeles');
|
||||
|
||||
// Reset the language manager so new negotiations attempts will fall back on
|
||||
// on the new language.
|
||||
$this->container->get('language_manager')->reset();
|
||||
|
||||
$this->assertSame('Sunday, 25-Mar-07 17:00:00 PDT', $formatter->format($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Test a different language.');
|
||||
$this->assertSame('Monday, 26-Mar-07 01:00:00 BST', $formatter->format($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Test a different time zone.');
|
||||
$this->assertSame('domingo, 25-Mar-07 17:00:00 PDT', $formatter->format($timestamp, 'custom', 'l, d-M-y H:i:s T'), 'Test custom date format.');
|
||||
$this->assertSame('domingo, 25. marzo 2007 - 17:00', $formatter->format($timestamp, 'long'), 'Test long date format.');
|
||||
$this->assertSame('25. marzo 2007 - 17:00', $formatter->format($timestamp, 'medium'), 'Test medium date format.');
|
||||
$this->assertSame('2007 Mar 25 - 5:00pm', $formatter->format($timestamp, 'short'), 'Test short date format.');
|
||||
$this->assertSame('25. marzo 2007 - 17:00', $formatter->format($timestamp), 'Test default date format.');
|
||||
// Test HTML time element formats.
|
||||
$this->assertSame('2007-03-25T17:00:00-0700', $formatter->format($timestamp, 'html_datetime'), 'Test html_datetime date format.');
|
||||
$this->assertSame('2007-03-25', $formatter->format($timestamp, 'html_date'), 'Test html_date date format.');
|
||||
$this->assertSame('17:00:00', $formatter->format($timestamp, 'html_time'), 'Test html_time date format.');
|
||||
$this->assertSame('03-25', $formatter->format($timestamp, 'html_yearless_date'), 'Test html_yearless_date date format.');
|
||||
$this->assertSame('2007-W12', $formatter->format($timestamp, 'html_week'), 'Test html_week date format.');
|
||||
$this->assertSame('2007-03', $formatter->format($timestamp, 'html_month'), 'Test html_month date format.');
|
||||
$this->assertSame('2007', $formatter->format($timestamp, 'html_year'), 'Test html_year date format.');
|
||||
|
||||
// HTML is not escaped by the date formatter, it must be escaped later.
|
||||
$this->assertSame("<script>alert('2007');</script>", $formatter->format($timestamp, 'custom', '\<\s\c\r\i\p\t\>\a\l\e\r\t\(\'Y\'\)\;\<\/\s\c\r\i\p\t\>'), 'Script tags not removed from dates.');
|
||||
$this->assertSame('<em>2007</em>', $formatter->format($timestamp, 'custom', '\<\e\m\>Y\<\/\e\m\>'), 'Em tags are not removed from dates.');
|
||||
}
|
||||
|
||||
}
|
|
@ -161,4 +161,17 @@ class DirectoryTest extends FileTestBase {
|
|||
$this->assertEqual($config->get('path.temporary'), $tmp_directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests directory creation.
|
||||
*/
|
||||
public function testDirectoryCreation() {
|
||||
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
|
||||
$file_system = $this->container->get('file_system');
|
||||
|
||||
// mkdir() recursion should work with or without a trailing slash.
|
||||
$dir = $this->siteDirectory . '/files';
|
||||
$this->assertTrue($file_system->mkdir($dir . '/foo/bar', 0775, TRUE));
|
||||
$this->assertTrue($file_system->mkdir($dir . '/foo/baz/', 0775, TRUE));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue