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

This commit is contained in:
Pantheon Automation 2016-06-02 15:56:09 -07:00 committed by Greg Anderson
parent 9eae24d844
commit 28556d630e
1322 changed files with 6699 additions and 2064 deletions

View file

@ -0,0 +1,107 @@
<?php
namespace Drupal\Tests\file\Kernel;
use Drupal\file\Entity\File;
use Drupal\KernelTests\KernelTestBase;
use Drupal\user\Entity\User;
/**
* Tests for the File access control.
*
* @group file
*/
class AccessTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['file', 'system', 'user'];
/**
* An authenticated user.
*
* @var \Drupal\user\UserInterface
*/
protected $user1;
/**
* An authenticated user.
*
* @var \Drupal\user\UserInterface
*/
protected $user2;
/**
* The file object used in the test.
*
* @var \Drupal\file\FileInterface
*/
protected $file;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('file');
$this->installEntitySchema('user');
$this->installSchema('file', array('file_usage'));
$this->installSchema('system', 'sequences');
$this->user1 = User::create([
'name' => 'user1',
'status' => 1,
]);
$this->user1->save();
$this->user2 = User::create([
'name' => 'user2',
'status' => 1,
]);
$this->user2->save();
$this->file = File::create(array(
'uid' => $this->user1->id(),
'filename' => 'druplicon.txt',
'filemime' => 'text/plain',
));
}
/**
* Tests that only the file owner can delete or update a file.
*/
public function testOnlyOwnerCanDeleteUpdateFile() {
\Drupal::currentUser()->setAccount($this->user2);
$this->assertFalse($this->file->access('delete'));
$this->assertFalse($this->file->access('update'));
\Drupal::currentUser()->setAccount($this->user1);
$this->assertTrue($this->file->access('delete'));
$this->assertTrue($this->file->access('update'));
}
/**
* Tests that the status field is not editable.
*/
public function testStatusFieldIsNotEditable() {
\Drupal::currentUser()->setAccount($this->user1);
$this->assertFalse($this->file->get('status')->access('edit'));
}
/**
* Tests create access checks.
*/
public function testCreateAccess() {
// Anonymous users can create a file by default.
$this->assertFalse($this->file->access('create'));
// Authenticated users can create a file by default.
\Drupal::currentUser()->setAccount($this->user1);
$this->assertFalse($this->file->access('create'));
}
}

View file

@ -141,4 +141,5 @@ class CopyTest extends FileManagedUnitTestBase {
$this->assertFileUnchanged($source, File::load($source->id()));
$this->assertFileUnchanged($target, File::load($target->id()));
}
}

View file

@ -68,4 +68,5 @@ class DeleteTest extends FileManagedUnitTestBase {
$this->assertFalse(file_exists($file->getFileUri()), 'File has been deleted after its last usage was removed.');
$this->assertFalse(File::load($file->id()), 'File was removed from the database.');
}
}

View file

@ -14,7 +14,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateFileTest extends MigrateDrupal7TestBase {
static $modules = ['file'];
public static $modules = ['file'];
/**
* {@inheritdoc}

View file

@ -156,4 +156,5 @@ class MoveTest extends FileManagedUnitTestBase {
$this->assertFileUnchanged($source, File::load($source->id()));
$this->assertFileUnchanged($target, File::load($target->id()));
}
}

View file

@ -130,4 +130,5 @@ class SaveDataTest extends FileManagedUnitTestBase {
// Ensure that the existing file wasn't overwritten.
$this->assertFileUnchanged($existing, File::load($existing->id()));
}
}

View file

@ -82,4 +82,5 @@ class SaveTest extends FileManagedUnitTestBase {
$this->assertEqual(array($uppercase_file->id() => $uppercase_file->id()), $fids);
}
}

View file

@ -71,4 +71,5 @@ class SpaceUsedTest extends FileManagedUnitTestBase {
$this->assertEqual($file->spaceUsed(3, 0), 3);
$this->assertEqual($file->spaceUsed(3, FILE_STATUS_PERMANENT), 300);
}
}

View file

@ -202,4 +202,5 @@ class UsageTest extends FileManagedUnitTestBase {
$this->assertTrue(file_exists($perm_old->getFileUri()), 'Old permanent file was correctly ignored.');
$this->assertTrue(file_exists($perm_new->getFileUri()), 'New permanent file was correctly ignored.');
}
}

View file

@ -34,4 +34,5 @@ class ValidateTest extends FileManagedUnitTestBase {
$this->assertEqual(file_validate($file, $failing), array('Failed', 'Badly', 'Epic fail'), 'Validating returns errors.');
$this->assertFileHooksCalled(array('validate'));
}
}

View file

@ -51,7 +51,7 @@ class ValidatorTest extends FileManagedUnitTestBase {
}
/**
* This ensures a specific file is actually an image.
* This ensures a specific file is actually an image.
*/
function testFileValidateIsImage() {
$this->assertTrue(file_exists($this->image->getFileUri()), 'The image being tested exists.', 'File');
@ -64,8 +64,9 @@ class ValidatorTest extends FileManagedUnitTestBase {
}
/**
* This ensures the resolution of a specific file is within bounds.
* The image will be resized if it's too large.
* This ensures the resolution of a specific file is within bounds.
*
* The image will be resized if it's too large.
*/
function testFileValidateImageResolution() {
// Non-images.
@ -113,7 +114,7 @@ class ValidatorTest extends FileManagedUnitTestBase {
}
/**
* This will ensure the filename length is valid.
* This will ensure the filename length is valid.
*/
function testFileValidateNameLength() {
// Create a new file entity.
@ -152,4 +153,5 @@ class ValidatorTest extends FileManagedUnitTestBase {
$errors = file_validate_size($file, 1, 1);
$this->assertEqual(count($errors), 2, 'Errors for both the file and their limit.', 'File');
}
}