Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -43,7 +43,7 @@ class FileModuleTestForm extends FormBase {
|
|||
|
||||
$form['nested']['file'] = array(
|
||||
'#type' => 'managed_file',
|
||||
'#title' => $this->t('Managed file'),
|
||||
'#title' => $this->t('Managed <em>@type</em>', ['@type' => 'file & butter']),
|
||||
'#upload_location' => 'public://test',
|
||||
'#progress_message' => $this->t('Please wait...'),
|
||||
'#extended' => (bool) $extended,
|
||||
|
|
|
@ -19,9 +19,9 @@ class FileTestAccessControlHandler extends FileAccessControlHandler implements F
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
\Drupal::state()->set('file_access_formatter_check', TRUE);
|
||||
return parent::checkAccess($entity, $operation, $langcode, $account);
|
||||
return parent::checkAccess($entity, $operation, $account);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\file\Unit\Plugin\migrate\process\d6\FileUriTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\file\Unit\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\file\Plugin\migrate\process\d6\FileUri;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\MigrateMessage;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\Tests\migrate\Unit\MigrateTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\file\Plugin\migrate\process\d6\FileUri
|
||||
* @group file
|
||||
*/
|
||||
class FileUriTest extends MigrateTestCase {
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
];
|
||||
|
||||
public function testPublic() {
|
||||
$value = [
|
||||
'sites/default/files/foo.jpg',
|
||||
'sites/default/files',
|
||||
'/tmp',
|
||||
TRUE,
|
||||
];
|
||||
$this->assertEquals('public://foo.jpg', $this->doTransform($value));
|
||||
}
|
||||
|
||||
public function testPublicUnknownBasePath() {
|
||||
$value = [
|
||||
'/path/to/public/files/foo.jpg',
|
||||
'sites/default/files',
|
||||
'/tmp',
|
||||
TRUE,
|
||||
];
|
||||
$this->assertEquals('public://path/to/public/files/foo.jpg', $this->doTransform($value));
|
||||
}
|
||||
|
||||
public function testPrivate() {
|
||||
$value = [
|
||||
'sites/default/files/baz.gif',
|
||||
'sites/default/files',
|
||||
'/tmp',
|
||||
FALSE,
|
||||
];
|
||||
$this->assertEquals('private://baz.gif', $this->doTransform($value));
|
||||
}
|
||||
|
||||
public function testPrivateUnknownBasePath() {
|
||||
$value = [
|
||||
'/path/to/private/files/baz.gif',
|
||||
'sites/default/files',
|
||||
'/tmp',
|
||||
FALSE,
|
||||
];
|
||||
$this->assertEquals('private://path/to/private/files/baz.gif', $this->doTransform($value));
|
||||
}
|
||||
|
||||
public function testTemporary() {
|
||||
$value = [
|
||||
'/tmp/bar.png',
|
||||
'sites/default/files',
|
||||
'/tmp',
|
||||
TRUE,
|
||||
];
|
||||
$this->assertEquals('temporary://bar.png', $this->doTransform($value));
|
||||
}
|
||||
|
||||
protected function doTransform(array $value) {
|
||||
$executable = new MigrateExecutable($this->getMigration(), new MigrateMessage());
|
||||
$row = new Row([], []);
|
||||
|
||||
return (new FileUri([], 'file_uri', []))
|
||||
->transform($value, $executable, $row, 'foobaz');
|
||||
}
|
||||
|
||||
}
|
|
@ -18,9 +18,7 @@ class FileTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
const PLUGIN_CLASS = 'Drupal\file\Plugin\migrate\source\d6\File';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_file',
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\file\Unit\Plugin\migrate\source\d6\UploadInstanceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\file\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\file\Plugin\migrate\source\d6\UploadInstance;
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests d6_upload_instance source plugin.
|
||||
*
|
||||
* @group file
|
||||
*/
|
||||
class UploadInstanceTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = UploadInstance::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_upload_instance',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'node_type' => 'article',
|
||||
'max_filesize' => '16MB',
|
||||
'file_extensions' => 'txt pdf',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['node_type'] = array(
|
||||
array(
|
||||
'type' => 'article',
|
||||
),
|
||||
array(
|
||||
'type' => 'company',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['variable'] = array(
|
||||
array(
|
||||
'name' => 'upload_article',
|
||||
'value' => serialize(TRUE),
|
||||
),
|
||||
array(
|
||||
'name' => 'upload_company',
|
||||
'value' => serialize(FALSE),
|
||||
),
|
||||
array(
|
||||
'name' => 'upload_uploadsize_default',
|
||||
'value' => serialize(16),
|
||||
),
|
||||
array(
|
||||
'name' => 'upload_extensions_default',
|
||||
'value' => serialize('txt pdf'),
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\file\Unit\Plugin\migrate\source\d6\UploadTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\file\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\file\Plugin\migrate\source\d6\Upload;
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests d6_upload source plugin.
|
||||
*
|
||||
* @group file
|
||||
*/
|
||||
class UploadTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = Upload::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_upload',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'upload' => array(
|
||||
array(
|
||||
'fid' => '1',
|
||||
'description' => 'file 1-1-1',
|
||||
'list' => '0',
|
||||
),
|
||||
),
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'type' => 'story',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['upload'] = array(
|
||||
array(
|
||||
'fid' => '1',
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'description' => 'file 1-1-1',
|
||||
'list' => '0',
|
||||
'weight' => '-1',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['node'] = array(
|
||||
array(
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'type' => 'story',
|
||||
'language' => '',
|
||||
'title' => 'Test title',
|
||||
'uid' => '1',
|
||||
'status' => '1',
|
||||
'created' => '1388271197',
|
||||
'changed' => '1420861423',
|
||||
'comment' => '0',
|
||||
'promote' => '0',
|
||||
'moderate' => '0',
|
||||
'sticky' => '0',
|
||||
'tnid' => '0',
|
||||
'translate' => '0',
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\Tests\file\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Core\Database\Query\ConditionInterface;
|
||||
use Drupal\file\Plugin\migrate\source\d7\File;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
@ -20,12 +21,19 @@ class FileTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
const PLUGIN_CLASS = 'Drupal\Tests\file\Unit\Plugin\migrate\source\d7\TestFile';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd7_file',
|
||||
// Used by testFilteringByScheme().
|
||||
'scheme' => array(
|
||||
'public',
|
||||
'private',
|
||||
),
|
||||
),
|
||||
'destination' => array(
|
||||
'plugin' => 'entity:file',
|
||||
'source_base_path' => '/path/to/files',
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -84,6 +92,25 @@ class FileTest extends MigrateSqlSourceTestCase {
|
|||
$row->getSourceProperty('filepath'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that it's possible to filter files by scheme.
|
||||
*/
|
||||
public function testFilteringByScheme() {
|
||||
$query_conditions = $this->source->query()->conditions();
|
||||
$scheme_condition = end($query_conditions);
|
||||
|
||||
$this->assertInstanceOf(ConditionInterface::class, $scheme_condition['field']);
|
||||
$conditions = $scheme_condition['field']->conditions();
|
||||
|
||||
$this->assertSame('uri', $conditions[0]['field']);
|
||||
$this->assertSame('LIKE', $conditions[0]['operator']);
|
||||
$this->assertSame('public://%', $conditions[0]['value']);
|
||||
|
||||
$this->assertSame('uri', $conditions[1]['field']);
|
||||
$this->assertSame('LIKE', $conditions[1]['operator']);
|
||||
$this->assertSame('private://%', $conditions[1]['value']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in a new issue