diff --git a/core/modules/file/css/file.admin.css b/core/modules/file/css/file.admin.css index 585ea62..d3d9a5f 100644 --- a/core/modules/file/css/file.admin.css +++ b/core/modules/file/css/file.admin.css @@ -1,4 +1,3 @@ - /** * @file * Admin stylesheet for file module. diff --git a/core/modules/file/file.api.php b/core/modules/file/file.api.php index 23a0291..c58d2bb 100644 --- a/core/modules/file/file.api.php +++ b/core/modules/file/file.api.php @@ -18,7 +18,8 @@ * * @param \Drupal\file\FileInterface $file * The file entity being validated. - * @return + * + * @return array * An array of error messages. If there are no problems with the file return * an empty array. * diff --git a/core/modules/file/src/FileUsage/FileUsageInterface.php b/core/modules/file/src/FileUsage/FileUsageInterface.php index 63600b5..85faf0d 100644 --- a/core/modules/file/src/FileUsage/FileUsageInterface.php +++ b/core/modules/file/src/FileUsage/FileUsageInterface.php @@ -69,7 +69,6 @@ public function delete(FileInterface $file, $module, $type = NULL, $id = NULL, $ * A nested array with usage data. The first level is keyed by module name, * the second by object type and the third by the object id. The value of * the third level contains the usage count. - * */ public function listUsage(FileInterface $file); } diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php index 9f80a6f..6b8cceb 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php @@ -19,7 +19,8 @@ * @FieldType( * id = "file", * label = @Translation("File"), - * description = @Translation("This field stores the ID of a file as an integer value."), + * description = @Translation("This field stores the ID of a file + * as an integer value."), * default_widget = "file_generic", * default_formatter = "file_default", * list_class = "\Drupal\file\Plugin\Field\FieldType\FileFieldItemList" @@ -200,11 +201,11 @@ public function instanceSettingsForm(array $form, FormStateInterface $form_state } /** - * Form API callback + * Form API callback. * * Removes slashes from the beginning and end of the destination value and - * ensures that the file directory path is not included at the beginning of the - * value. + * ensures that the file directory path is not included at the beginning of + * the value. * * This function is assigned as an #element_validate callback in * instanceSettingsForm(). @@ -223,7 +224,8 @@ public static function validateDirectory($element, FormStateInterface $form_stat * * This doubles as a convenience clean-up function and a validation routine. * Commas are allowed by the end-user, but ultimately the value will be stored - * as a space-separated list for compatibility with file_validate_extensions(). + * as a space-separated list for compatibility with + * file_validate_extensions(). */ public static function validateExtensions($element, FormStateInterface $form_state) { if (!empty($element['#value'])) { @@ -250,17 +252,17 @@ public static function validateExtensions($element, FormStateInterface $form_sta */ public static function validateMaxFilesize($element, FormStateInterface $form_state) { if (!empty($element['#value']) && !is_numeric(Bytes::toInt($element['#value']))) { - form_error($element, $form_state, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', array('!name' => t($element['title'])))); + form_error($element, $form_state, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', array('!name' => $element['title']))); } } /** * Determines the URI for a file field instance. * - * @param $data + * @param array $data * An array of token objects to pass to token_replace(). * - * @return + * @return string * A file directory URI with tokens replaced. * * @see token_replace() @@ -278,7 +280,7 @@ public function getUploadLocation($data = array()) { /** * Retrieves the upload validators for a file field. * - * @return + * @return array * An array suitable for passing to file_save_upload() or the file field * element's '#upload_validators' property. */ diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index fa5c28e..ec7090a 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -302,8 +302,9 @@ public static function value($element, $input = FALSE, FormStateInterface $form_ } /** - * Form element validation callback for upload element on file widget. Checks - * if user has uploaded more files than allowed. + * Form element validation callback for upload element on file widget. + * + * Checks if user has uploaded more files than allowed. * * This validator is used only when cardinality not set to 1 or unlimited. */ @@ -405,7 +406,9 @@ public static function process($element, FormStateInterface $form_state, $form) // not just the individual item, to be valid. foreach (array('upload_button', 'remove_button') as $key) { $element[$key]['#submit'][] = array(get_called_class(), 'submit'); - $element[$key]['#limit_validation_errors'] = array(array_slice($element['#parents'], 0, -1)); + $element[$key]['#limit_validation_errors'] = array( + array_slice($element['#parents'], 0, -1), + ); } return $element; diff --git a/core/modules/file/src/Plugin/views/argument/Fid.php b/core/modules/file/src/Plugin/views/argument/Fid.php index a296a0c..cd2c9b7 100644 --- a/core/modules/file/src/Plugin/views/argument/Fid.php +++ b/core/modules/file/src/Plugin/views/argument/Fid.php @@ -48,7 +48,7 @@ class Fid extends Numeric implements ContainerFactoryPluginInterface { * The plugin implementation definition. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Entity\Query\QueryFactory + * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query * The entity query factory. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, QueryFactory $entity_query) { diff --git a/core/modules/file/src/Plugin/views/field/FileMime.php b/core/modules/file/src/Plugin/views/field/FileMime.php index 5576e34..4603751 100644 --- a/core/modules/file/src/Plugin/views/field/FileMime.php +++ b/core/modules/file/src/Plugin/views/field/FileMime.php @@ -11,7 +11,8 @@ use Drupal\views\ResultRow; /** - * Field handler to add rendering MIME type images as an option on the filemime field. + * Field handler to add rendering MIME type images as an option + * on the filemime field. * * @ingroup views_field_handlers * diff --git a/core/modules/file/src/Plugin/views/field/Uri.php b/core/modules/file/src/Plugin/views/field/Uri.php index 2d2c481..4dab77b 100644 --- a/core/modules/file/src/Plugin/views/field/Uri.php +++ b/core/modules/file/src/Plugin/views/field/Uri.php @@ -11,7 +11,9 @@ use Drupal\views\ResultRow; /** - * Field handler to add rendering file paths as file URLs instead of as internal file URIs. + * Field handler to add rendering file paths as file URLs. + * + * instead of as internal file URIs. * * @ViewsField("file_uri") */ diff --git a/core/modules/file/src/Plugin/views/wizard/File.php b/core/modules/file/src/Plugin/views/wizard/File.php index 94529a0..d3d4ff0 100644 --- a/core/modules/file/src/Plugin/views/wizard/File.php +++ b/core/modules/file/src/Plugin/views/wizard/File.php @@ -33,11 +33,11 @@ class File extends WizardPluginBase { 'table' => 'file_managed', 'field' => 'uri', 'exclude' => TRUE, - 'file_download_path' => TRUE + 'file_download_path' => TRUE, ); /** - * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions(). + * Overrides ..\..\..\..\wizard\WizardPluginBase::defaultDisplayOptions(). */ protected function defaultDisplayOptions() { $display_options = parent::defaultDisplayOptions(); diff --git a/core/modules/file/src/Tests/CopyTest.php b/core/modules/file/src/Tests/CopyTest.php index 3a3a727..8795df8 100644 --- a/core/modules/file/src/Tests/CopyTest.php +++ b/core/modules/file/src/Tests/CopyTest.php @@ -16,7 +16,7 @@ class CopyTest extends FileManagedUnitTestBase { /** * Test file copying in the normal, base case. */ - function testNormal() { + public function testNormal() { $contents = $this->randomMachineName(10); $source = $this->createFile(NULL, $contents); $desired_uri = 'public://' . $this->randomMachineName(); @@ -45,7 +45,7 @@ function testNormal() { /** * Test renaming when copying over a file that already exists. */ - function testExistingRename() { + public function testExistingRename() { // Setup a file to overwrite. $contents = $this->randomMachineName(10); $source = $this->createFile(NULL, $contents); @@ -85,7 +85,7 @@ function testExistingRename() { /** * Test replacement when copying over a file that already exists. */ - function testExistingReplace() { + public function testExistingReplace() { // Setup a file to overwrite. $contents = $this->randomMachineName(10); $source = $this->createFile(NULL, $contents); @@ -121,10 +121,11 @@ function testExistingReplace() { } /** - * Test that copying over an existing file fails when FILE_EXISTS_ERROR is - * specified. + * Test that copying over an existing file fails when. + * + * FILE_EXISTS_ERROR is specified. */ - function testExistingError() { + public function testExistingError() { $contents = $this->randomMachineName(10); $source = $this->createFile(); $target = $this->createFile(NULL, $contents); diff --git a/core/modules/file/src/Tests/DeleteTest.php b/core/modules/file/src/Tests/DeleteTest.php index f39239f..f9aa34e 100644 --- a/core/modules/file/src/Tests/DeleteTest.php +++ b/core/modules/file/src/Tests/DeleteTest.php @@ -16,7 +16,7 @@ class DeleteTest extends FileManagedUnitTestBase { /** * Tries deleting a normal file (as opposed to a directory, symlink, etc). */ - function testUnused() { + public function testUnused() { $file = $this->createFile(); // Check that deletion removes the file and database record. @@ -30,7 +30,7 @@ function testUnused() { /** * Tries deleting a file that is in use. */ - function testInUse() { + public function testInUse() { $file = $this->createFile(); $file_usage = $this->container->get('file.usage'); $file_usage->add($file, 'testing', 'test', 1); diff --git a/core/modules/file/src/Tests/DownloadTest.php b/core/modules/file/src/Tests/DownloadTest.php index 92ba740..76dacd2 100644 --- a/core/modules/file/src/Tests/DownloadTest.php +++ b/core/modules/file/src/Tests/DownloadTest.php @@ -15,7 +15,7 @@ * @group file */ class DownloadTest extends FileManagedTestBase { - protected function setUp() { + public function setUp() { parent::setUp(); // Clear out any hook calls. file_test_reset(); @@ -24,12 +24,12 @@ protected function setUp() { /** * Test the public file transfer system. */ - function testPublicFileTransfer() { + public function testPublicFileTransfer() { // Test generating an URL to a created file. $file = $this->createFile(); $url = file_create_url($file->getFileUri()); - // URLs can't contain characters outside the ASCII set so $filename has to be - // encoded. + // URLs can't contain characters outside the ASCII set + // so $filename has to be encoded. $filename = $GLOBALS['base_url'] . '/' . file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . rawurlencode($file->getFilename()); $this->assertEqual($filename, $url, 'Correctly generated a URL for a created file.'); $this->drupalHead($url); @@ -99,14 +99,17 @@ protected function doPrivateFileTransferTest() { /** * Test file_create_url(). */ - function testFileCreateUrl() { + public function testFileCreateUrl() { // Tilde (~) is excluded from this test because it is encoded by // rawurlencode() in PHP 5.2 but not in PHP 5.3, as per RFC 3986. // @see http://www.php.net/manual/function.rawurlencode.php#86506 - $basename = " -._!$'\"()*@[]?&+%#,;=:\n\x00" . // "Special" ASCII characters. - "%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string. - "éøïвβ中國書۞"; // Characters from various non-ASCII alphabets. + // "Special" ASCII characters. + $basename = " -._!$'\"()*@[]?&+%#,;=:\n\x00" . + // Characters that look like a percent-escaped string. + "%23%25%26%2B%2F%3F" . + // Characters from various non-ASCII alphabets. + "éøïвβ中國書۞";; $basename_encoded = '%20-._%21%24%27%22%28%29%2A%40%5B%5D%3F%26%2B%25%23%2C%3B%3D%3A__' . '%2523%2525%2526%252B%252F%253F' . '%C3%A9%C3%B8%C3%AF%D0%B2%CE%B2%E4%B8%AD%E5%9C%8B%E6%9B%B8%DB%9E'; @@ -135,13 +138,13 @@ function testFileCreateUrl() { * the URL generated by file_create_url() for the specified file equals the * specified URL; fetch the URL and then compare the contents to the file. * - * @param $scheme + * @param string $scheme * A scheme, e.g. "public" - * @param $directory + * @param string $directory * A directory, possibly "" - * @param $filename + * @param string $filename * A filename - * @param $expected_url + * @param string $expected_url * The expected URL */ private function checkUrl($scheme, $directory, $filename, $expected_url) { diff --git a/core/modules/file/src/Tests/FileFieldDisplayTest.php b/core/modules/file/src/Tests/FileFieldDisplayTest.php index 6a1798d..d65e289 100644 --- a/core/modules/file/src/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/src/Tests/FileFieldDisplayTest.php @@ -19,7 +19,7 @@ class FileFieldDisplayTest extends FileFieldTestBase { /** * Tests normal formatter display on node display. */ - function testNodeDisplay() { + public function testNodeDisplay() { $field_name = strtolower($this->randomMachineName()); $type_name = 'article'; $field_settings = array( @@ -38,7 +38,8 @@ function testNodeDisplay() { $node = $this->drupalCreateNode(array('type' => $type_name)); // Check file_default last as the assertions below assume that this is the // case. - $file_formatters = array('file_table', 'file_url_plain', 'hidden', 'file_default'); + $file_formatters = array('file_table', 'file_url_plain', + 'hidden', 'file_default'); foreach ($file_formatters as $formatter) { $edit = array( "fields[$field_name][type]" => $formatter, @@ -63,7 +64,8 @@ function testNodeDisplay() { $default_output = drupal_render($file_link); $this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.'); - // Turn the "display" option off and check that the file is no longer displayed. + // Turn the "display" option off and + // Check that the file is no longer displayed. $edit = array($field_name . '[0][display]' => FALSE); $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published')); diff --git a/core/modules/file/src/Tests/FileFieldPathTest.php b/core/modules/file/src/Tests/FileFieldPathTest.php index 865317a..fa2f667 100644 --- a/core/modules/file/src/Tests/FileFieldPathTest.php +++ b/core/modules/file/src/Tests/FileFieldPathTest.php @@ -16,7 +16,7 @@ class FileFieldPathTest extends FileFieldTestBase { /** * Tests the normal formatter display on node display. */ - function testUploadPath() { + public function testUploadPath() { $field_name = strtolower($this->randomMachineName()); $type_name = 'article'; $this->createFileField($field_name, 'node', $type_name); @@ -53,7 +53,7 @@ function testUploadPath() { $node_file = file_load($node->{$field_name}->target_id); // Do token replacement using the same user which uploaded the file, not // the user running the test case. - $data = array('user' => $this->admin_user); + $data = array('user' => $this->adminUser); $subdirectory = \Drupal::token()->replace('[user:uid]/[user:name]', $data); $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->getFileUri()))); } @@ -61,15 +61,15 @@ function testUploadPath() { /** * Asserts that a file is uploaded to the right location. * - * @param $expected_path + * @param string $expected_path * The location where the file is expected to be uploaded. Duplicate file * names to not need to be taken into account. - * @param $actual_path + * @param string $actual_path * Where the file was actually uploaded. - * @param $message + * @param string $message * The message to display with this assertion. */ - function assertPathMatch($expected_path, $actual_path, $message) { + public function assertPathMatch($expected_path, $actual_path, $message) { // Strip off the extension of the expected path to allow for _0, _1, etc. // suffixes when the file hits a duplicate name. $pos = strrpos($expected_path, '.'); diff --git a/core/modules/file/src/Tests/FileFieldRSSContentTest.php b/core/modules/file/src/Tests/FileFieldRSSContentTest.php index db265c2..c0d265b 100644 --- a/core/modules/file/src/Tests/FileFieldRSSContentTest.php +++ b/core/modules/file/src/Tests/FileFieldRSSContentTest.php @@ -24,7 +24,7 @@ class FileFieldRSSContentTest extends FileFieldTestBase { /** * Tests RSS enclosure formatter display for RSS feeds. */ - function testFileFieldRSSContent() { + public function testFileFieldRSSContent() { $field_name = strtolower($this->randomMachineName()); $type_name = 'article'; $field_settings = array( @@ -70,7 +70,7 @@ function testFileFieldRSSContent() { 'attributes' => array( 'url' => url("$this->public_files_directory/$uploaded_filename", array('absolute' => TRUE)), 'length' => $node_file->getSize(), - 'type' => $node_file->getMimeType() + 'type' => $node_file->getMimeType(), ), ); $this->assertRaw(format_xml_elements(array($test_element)), 'File field RSS enclosure is displayed when viewing the RSS feed.'); diff --git a/core/modules/file/src/Tests/FileFieldRevisionTest.php b/core/modules/file/src/Tests/FileFieldRevisionTest.php index b45b200..145f344 100644 --- a/core/modules/file/src/Tests/FileFieldRevisionTest.php +++ b/core/modules/file/src/Tests/FileFieldRevisionTest.php @@ -24,7 +24,7 @@ class FileFieldRevisionTest extends FileFieldTestBase { * - When the last revision that uses a file is deleted, the original file * should be deleted also. */ - function testRevisions() { + public function testRevisions() { $type_name = 'article'; $field_name = strtolower($this->randomMachineName()); $this->createFileField($field_name, 'node', $type_name); diff --git a/core/modules/file/src/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php index fb9552a..8ef1222 100644 --- a/core/modules/file/src/Tests/FileFieldTestBase.php +++ b/core/modules/file/src/Tests/FileFieldTestBase.php @@ -18,25 +18,36 @@ abstract class FileFieldTestBase extends WebTestBase { /** - * Modules to enable. - * - * @var array - */ + * Modules to enable. + * + * @var array + */ public static $modules = array('node', 'file', 'file_module_test', 'field_ui'); - protected $admin_user; + protected $adminUser; protected function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer users', 'administer permissions', 'administer content types', 'administer node fields', 'administer node display', 'administer nodes', 'bypass node access')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array( + 'access content', + 'access administration pages', + 'administer site configuration', + 'administer users', + 'administer permissions', + 'administer content types', + 'administer node fields', + 'administer node display', + 'administer nodes', + 'bypass node access', + )); + $this->drupalLogin($this->adminUser); $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); } /** * Retrieves a sample file of the specified type. */ - function getTestFile($type_name, $size = NULL) { + public function getTestFile($type_name, $size = NULL) { // Get a file to upload. $file = current($this->drupalGetTestFiles($type_name, $size)); @@ -49,27 +60,28 @@ function getTestFile($type_name, $size = NULL) { /** * Retrieves the fid of the last inserted file. */ - function getLastFileId() { + public function getLastFileId() { return (int) db_query('SELECT MAX(fid) FROM {file_managed}')->fetchField(); } /** * Creates a new file field (storage and instance). * - * @param $name + * @param string $name * The name of the new field (all lowercase), exclude the "field_" prefix. - * @param $entity_type + * @param string $entity_type * The entity type. - * @param $bundle + * @param string $bundle * The bundle that this field will be added to. + * @param array $field_settings * @param $storage_settings * A list of field storage settings that will be added to the defaults. - * @param $instance_settings + * @param array $instance_settings * A list of instance settings that will be added to the instance defaults. - * @param $widget_settings + * @param array $widget_settings * A list of widget settings that will be added to the widget defaults. */ - function createFileField($name, $entity_type, $bundle, $storage_settings = array(), $instance_settings = array(), $widget_settings = array()) { + public function createFileField($name, $entity_type, $bundle, $storage_settings = array(), $instance_settings = array(), $widget_settings = array()) { $field_storage = entity_create('field_storage_config', array( 'entity_type' => $entity_type, 'name' => $name, @@ -86,20 +98,18 @@ function createFileField($name, $entity_type, $bundle, $storage_settings = array /** * Attaches a file field to an entity. * - * @param $name + * @param string $name * The name of the new field (all lowercase), exclude the "field_" prefix. - * @param $entity_type + * @param string $entity_type * The entity type this field will be added to. - * @param $bundle + * @param string $bundle * The bundle this field will be added to. - * @param $field_settings - * A list of field settings that will be added to the defaults. - * @param $instance_settings + * @param array $instance_settings * A list of instance settings that will be added to the instance defaults. - * @param $widget_settings + * @param array $widget_settings * A list of widget settings that will be added to the widget defaults. */ - function attachFileField($name, $entity_type, $bundle, $instance_settings = array(), $widget_settings = array()) { + public function attachFileField($name, $entity_type, $bundle, $instance_settings = array(), $widget_settings = array()) { $instance = array( 'field_name' => $name, 'label' => $name, @@ -122,7 +132,7 @@ function attachFileField($name, $entity_type, $bundle, $instance_settings = arra /** * Updates an existing file field with new settings. */ - function updateFileField($name, $type_name, $instance_settings = array(), $widget_settings = array()) { + public function updateFileField($name, $type_name, $instance_settings = array(), $widget_settings = array()) { $instance = FieldInstanceConfig::loadByName('node', $type_name, $name); $instance->settings = array_merge($instance->settings, $instance_settings); $instance->save(); @@ -137,7 +147,7 @@ function updateFileField($name, $type_name, $instance_settings = array(), $widge /** * Uploads a file to a node. */ - function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, $extras = array()) { + public function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, $extras = array()) { $edit = array( 'title[0][value]' => $this->randomMachineName(), 'revision' => (string) (int) $new_revision, @@ -175,7 +185,7 @@ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, * * Note that if replacing a file, it must first be removed then added again. */ - function removeNodeFile($nid, $new_revision = TRUE) { + public function removeNodeFile($nid, $new_revision = TRUE) { $edit = array( 'revision' => (string) (int) $new_revision, ); @@ -187,7 +197,7 @@ function removeNodeFile($nid, $new_revision = TRUE) { /** * Replaces a file within a node. */ - function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) { + public function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) { $edit = array( 'files[' . $field_name . '_0]' => drupal_realpath($file->getFileUri()), 'revision' => (string) (int) $new_revision, @@ -200,7 +210,7 @@ function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) { /** * Asserts that a file exists physically on disk. */ - function assertFileExists($file, $message = NULL) { + public function assertFileExists($file, $message = NULL) { $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri())); $this->assertTrue(is_file($file->getFileUri()), $message); } @@ -208,7 +218,7 @@ function assertFileExists($file, $message = NULL) { /** * Asserts that a file exists in the database. */ - function assertFileEntryExists($file, $message = NULL) { + public function assertFileEntryExists($file, $message = NULL) { $this->container->get('entity.manager')->getStorage('file')->resetCache(); $db_file = file_load($file->id()); $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri())); @@ -218,7 +228,7 @@ function assertFileEntryExists($file, $message = NULL) { /** * Asserts that a file does not exist on disk. */ - function assertFileNotExists($file, $message = NULL) { + public function assertFileNotExists($file, $message = NULL) { $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri())); $this->assertFalse(is_file($file->getFileUri()), $message); } @@ -226,7 +236,7 @@ function assertFileNotExists($file, $message = NULL) { /** * Asserts that a file does not exist in the database. */ - function assertFileEntryNotExists($file, $message) { + public function assertFileEntryNotExists($file, $message) { $this->container->get('entity.manager')->getStorage('file')->resetCache(); $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri())); $this->assertFalse(file_load($file->id()), $message); @@ -235,7 +245,7 @@ function assertFileEntryNotExists($file, $message) { /** * Asserts that a file's status is set to permanent in the database. */ - function assertFileIsPermanent(FileInterface $file, $message = NULL) { + public function assertFileIsPermanent(FileInterface $file, $message = NULL) { $message = isset($message) ? $message : format_string('File %file is permanent.', array('%file' => $file->getFileUri())); $this->assertTrue($file->isPermanent(), $message); } diff --git a/core/modules/file/src/Tests/FileFieldValidateTest.php b/core/modules/file/src/Tests/FileFieldValidateTest.php index 182ffad..14685d2 100644 --- a/core/modules/file/src/Tests/FileFieldValidateTest.php +++ b/core/modules/file/src/Tests/FileFieldValidateTest.php @@ -18,12 +18,12 @@ */ class FileFieldValidateTest extends FileFieldTestBase { protected $field; - protected $node_type; + protected $nodeType; /** * Tests the required property on file fields. */ - function testRequired() { + public function testRequired() { $type_name = 'article'; $field_name = strtolower($this->randomMachineName()); $field = $this->createFileField($field_name, 'node', $type_name, array(), array('required' => '1')); @@ -39,7 +39,12 @@ function testRequired() { // Create a new node with the uploaded file. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); - $this->assertTrue($nid !== FALSE, format_string('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', array('@test_file' => $test_file->getFileUri(), '@field_name' => $field_name, '@type_name' => $type_name))); + $this->assertTrue($nid !== FALSE, format_string('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', + array( + '@test_file' => $test_file->getFileUri(), + '@field_name' => $field_name, + '@type_name' => $type_name, + ))); $node = node_load($nid, TRUE); @@ -68,13 +73,15 @@ function testRequired() { /** * Tests the max file size validator. */ - function testFileMaxSize() { + public function testFileMaxSize() { $type_name = 'article'; $field_name = strtolower($this->randomMachineName()); $this->createFileField($field_name, 'node', $type_name, array(), array('required' => '1')); - $small_file = $this->getTestFile('text', 131072); // 128KB. - $large_file = $this->getTestFile('text', 1310720); // 1.2MB + // 128KB. + $small_file = $this->getTestFile('text', 131072); + // 1.2MB + $large_file = $this->getTestFile('text', 1310720); // Test uploading both a large and small file with different increments. $sizes = array( @@ -114,7 +121,7 @@ function testFileMaxSize() { /** * Tests file extension checking. */ - function testFileExtension() { + public function testFileExtension() { $type_name = 'article'; $field_name = strtolower($this->randomMachineName()); $this->createFileField($field_name, 'node', $type_name); diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php index 9ae0940..9130ce9 100644 --- a/core/modules/file/src/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php @@ -28,7 +28,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { /** * Tests upload and remove buttons for a single-valued File field. */ - function testSingleValuedWidget() { + public function testSingleValuedWidget() { $type_name = 'article'; $field_name = strtolower($this->randomMachineName()); $this->createFileField($field_name, 'node', $type_name); @@ -59,6 +59,7 @@ function testSingleValuedWidget() { case 'nojs': $this->drupalPostForm(NULL, array(), t('Remove')); break; + case 'js': $button = $this->xpath('//input[@type="submit" and @value="' . t('Remove') . '"]'); $this->drupalPostAjaxForm(NULL, array(), array((string) $button[0]['name'] => (string) $button[0]['value'])); @@ -82,7 +83,7 @@ function testSingleValuedWidget() { /** * Tests upload and remove buttons for multiple multi-valued File fields. */ - function testMultiValuedWidget() { + public function testMultiValuedWidget() { $type_name = 'article'; // Use explicit names instead of random names for those fields, because of a // bug in drupalPostForm() with multiple file uploads in one form, where the @@ -103,15 +104,14 @@ function testMultiValuedWidget() { // until after the 3rd file, and after that, isn't displayed. Because // SimpleTest triggers the last button with a given name, so upload to the // second field first. - // @todo This is only testing a non-Ajax upload, because drupalPostAjaxForm() - // does not yet emulate jQuery's file upload. - // + // @todo This is only testing a non-Ajax upload, because + // drupalPostAjaxForm() does not yet emulate jQuery's file upload. $this->drupalGet("node/add/$type_name"); foreach (array($field_name2, $field_name) as $each_field_name) { for ($delta = 0; $delta < 3; $delta++) { $edit = array('files[' . $each_field_name . '_' . $delta . '][]' => drupal_realpath($test_file->getFileUri())); - // If the Upload button doesn't exist, drupalPostForm() will automatically - // fail with an assertion message. + // If the Upload button doesn't exist, drupalPostForm() will + // automatically fail with an assertion message. $this->drupalPostForm(NULL, $edit, t('Upload')); } } @@ -122,13 +122,13 @@ function testMultiValuedWidget() { foreach (array($field_name, $field_name2) as $current_field_name) { // How many uploaded files for the current field are remaining. $remaining = 3; - // Test clicking each "Remove" button. For extra robustness, test them out - // of sequential order. They are 0-indexed, and get renumbered after each - // iteration, so array(1, 1, 0) means: + // Test clicking each "Remove" button. For extra robustness, + // test them out of sequential order. They are 0-indexed, and + // get renumbered after each iteration, so array(1, 1, 0) means: // - First remove the 2nd file. - // - Then remove what is then the 2nd file (was originally the 3rd file). + // - Then remove what is then the 2nd file(was originally the 3rd file). // - Then remove the first file. - foreach (array(1,1,0) as $delta) { + foreach (array(1, 1, 0) as $delta) { // Ensure we have the expected number of Remove buttons, and that they // are numbered sequentially. $buttons = $this->xpath('//input[@type="submit" and @value="Remove"]'); @@ -140,20 +140,21 @@ function testMultiValuedWidget() { $check_field_name = $field_name; } - $this->assertIdentical((string) $button['name'], $check_field_name . '_' . $key. '_remove_button'); + $this->assertIdentical((string) $button['name'], $check_field_name . '_' . $key . '_remove_button'); } - // "Click" the remove button (emulating either a nojs or js submission). + // "Click" remove button (emulating either a nojs or js submission). $button_name = $current_field_name . '_' . $delta . '_remove_button'; switch ($type) { case 'nojs': - // drupalPostForm() takes a $submit parameter that is the value of the - // button whose click we want to emulate. Since we have multiple - // buttons with the value "Remove", and want to control which one we - // use, we change the value of the other ones to something else. + // drupalPostForm() takes a $submit parameter that is the value + // of the button whose click we want to emulate. Since we have + // multiple buttons with the value "Remove", and want to control + // which one we use, we change the value of the other ones to + // something else. // Since non-clicked buttons aren't included in the submitted POST - // data, and since drupalPostForm() will result in $this being updated - // with a newly rebuilt form, this doesn't cause problems. + // data, and since drupalPostForm() will result in $this being + // updated with a newly rebuilt form, this doesn't cause problems. foreach ($buttons as $button) { if ($button['name'] != $button_name) { $button['value'] = 'DUMMY'; @@ -161,17 +162,18 @@ function testMultiValuedWidget() { } $this->drupalPostForm(NULL, array(), t('Remove')); break; + case 'js': - // drupalPostAjaxForm() lets us target the button precisely, so we don't - // require the workaround used above for nojs. + // drupalPostAjaxForm() lets us target the button precisely, + // so we don't require the workaround used above for nojs. $this->drupalPostAjaxForm(NULL, array(), array($button_name => t('Remove'))); break; } $num_expected_remove_buttons--; $remaining--; - // Ensure an "Upload" button for the current field is displayed with the - // correct name. + // Ensure an "Upload" button for the current field is displayed with + // the correct name. $upload_button_name = $current_field_name . '_' . $remaining . '_upload_button'; $buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', array(':name' => $upload_button_name)); $this->assertTrue(is_array($buttons) && count($buttons) == 1, format_string('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type))); @@ -199,9 +201,9 @@ function testMultiValuedWidget() { /** * Tests a file field with a "Private files" upload destination setting. */ - function testPrivateFileSetting() { + public function testPrivateFileSetting() { // Grant the admin user required permissions. - user_role_grant_permissions($this->admin_user->roles[0]->value, array('administer node fields')); + user_role_grant_permissions($this->adminUser->roles[0]->value, array('administer node fields')); $type_name = 'article'; $field_name = strtolower($this->randomMachineName()); @@ -236,11 +238,11 @@ function testPrivateFileSetting() { /** * Tests that download restrictions on private files work on comments. */ - function testPrivateFileComment() { + public function testPrivateFileComment() { $user = $this->drupalCreateUser(array('access comments')); // Grant the admin user required comment permissions. - $roles = $this->admin_user->getRoles(); + $roles = $this->adminUser->getRoles(); user_role_grant_permissions($roles[1], array('administer comment fields', 'administer comments')); // Revoke access comments permission from anon user, grant post to @@ -300,7 +302,7 @@ function testPrivateFileComment() { $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); // Unpublishes node. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save and unpublish')); // Ensures normal user can no longer download the file. @@ -312,7 +314,7 @@ function testPrivateFileComment() { /** * Tests validation with the Upload button. */ - function testWidgetValidation() { + public function testWidgetValidation() { $type_name = 'article'; $field_name = strtolower($this->randomMachineName()); $this->createFileField($field_name, 'node', $type_name); @@ -341,16 +343,19 @@ function testWidgetValidation() { $error_message = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => 'txt')); $this->assertRaw($error_message, t('Validation error when file with wrong extension uploaded (JSMode=%type).', array('%type' => $type))); - // Upload file with correct extension, check that error message is removed. + // Upload file with correct extension, check that error message is + // removed. $edit[$name] = drupal_realpath($test_file_text->getFileUri()); switch ($type) { case 'nojs': $this->drupalPostForm(NULL, $edit, t('Upload')); break; + case 'js': $button = $this->xpath('//input[@type="submit" and @value="' . t('Upload') . '"]'); $this->drupalPostAjaxForm(NULL, $edit, array((string) $button[0]['name'] => (string) $button[0]['value'])); break; + } $this->assertNoRaw($error_message, t('Validation error removed when file with correct extension uploaded (JSMode=%type).', array('%type' => $type))); } diff --git a/core/modules/file/src/Tests/FileItemTest.php b/core/modules/file/src/Tests/FileItemTest.php index 82a2ceb..06bf822 100644 --- a/core/modules/file/src/Tests/FileItemTest.php +++ b/core/modules/file/src/Tests/FileItemTest.php @@ -61,7 +61,7 @@ protected function setUp() { * Tests using entity fields of the file field type. */ public function testFileItem() { - // Create a test entity with the + // Create a test entity with the. $entity = entity_create('entity_test'); $entity->file_test->target_id = $this->file->id(); $entity->file_test->display = 1; diff --git a/core/modules/file/src/Tests/FileListingTest.php b/core/modules/file/src/Tests/FileListingTest.php index 216bb5f..b83bc14 100644 --- a/core/modules/file/src/Tests/FileListingTest.php +++ b/core/modules/file/src/Tests/FileListingTest.php @@ -32,8 +32,9 @@ protected function setUp() { /** * Calculates total count of usages for a file. * - * @param $usage array + * @param array $usage * Array of file usage information as returned from file_usage subsystem. + * * @return int * Total usage count. */ @@ -53,7 +54,7 @@ protected function sumUsages($usage) { /** * Tests file overview with different user permissions. */ - function testFileListingPages() { + public function testFileListingPages() { $file_usage = $this->container->get('file.usage'); // Users without sufficient permissions should not see file listing. $this->drupalLogin($this->base_user); @@ -143,7 +144,7 @@ function testFileListingPages() { * Creates and saves a test file. * * @return \Drupal\Core\Entity\EntityInterface - * A file entity. + * A file entity. */ protected function createFile() { // Create a new file entity. diff --git a/core/modules/file/src/Tests/FileManagedFileElementTest.php b/core/modules/file/src/Tests/FileManagedFileElementTest.php index 8368610..4001164 100644 --- a/core/modules/file/src/Tests/FileManagedFileElementTest.php +++ b/core/modules/file/src/Tests/FileManagedFileElementTest.php @@ -18,7 +18,7 @@ class FileManagedFileElementTest extends FileFieldTestBase { /** * Tests the managed_file element type. */ - function testManagedFile() { + public function testManagedFile() { // Check that $element['#size'] is passed to the child upload element. $this->drupalGet('file/test'); $this->assertFieldByXpath('//input[@name="files[nested_file]" and @size="13"]', NULL, 'The custom #size attribute is passed to the child upload element.'); diff --git a/core/modules/file/src/Tests/FileManagedTestBase.php b/core/modules/file/src/Tests/FileManagedTestBase.php index 3147f73..446fb9e 100644 --- a/core/modules/file/src/Tests/FileManagedTestBase.php +++ b/core/modules/file/src/Tests/FileManagedTestBase.php @@ -23,21 +23,22 @@ */ public static $modules = array('file_test', 'file'); - protected function setUp() { + public function setUp() { parent::setUp(); // Clear out any hook calls. file_test_reset(); } /** - * Assert that all of the specified hook_file_* hooks were called once, other - * values result in failure. + * Assert that all of the specified hook_file_* hooks were called once. * - * @param $expected + * other values result in failure. + * + * @param array $expected * Array with string containing with the hook name, e.g. 'load', 'save', * 'insert', etc. */ - function assertFileHooksCalled($expected) { + public function assertFileHooksCalled($expected) { \Drupal::state()->resetCache(); // Determine which hooks were called. @@ -46,7 +47,11 @@ function assertFileHooksCalled($expected) { // Determine if there were any expected that were not called. $uncalled = array_diff($expected, $actual); if (count($uncalled)) { - $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)))); + $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', + array( + '%expected' => implode(', ', $expected), + '%uncalled' => implode(', ', $uncalled), + ))); } else { $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected)))); @@ -65,14 +70,14 @@ function assertFileHooksCalled($expected) { /** * Assert that a hook_file_* hook was called a certain number of times. * - * @param $hook + * @param string $hook * String with the hook name, e.g. 'load', 'save', 'insert', etc. - * @param $expected_count + * @param int $expected_count * Optional integer count. - * @param $message + * @param string $message * Optional translated string message. */ - function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { + public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { $actual_count = count(file_test_get_calls($hook)); if (!isset($message)) { @@ -83,7 +88,12 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { $message = format_plural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count)); } else { - $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count)); + $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', + array( + '@name' => $hook, + '%expected' => $expected_count, + '%actual' => $actual_count, + )); } } $this->assertEqual($actual_count, $expected_count, $message); @@ -97,7 +107,7 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { * @param \Drupal\file\FileInterface $after * File object to compare. */ - function assertFileUnchanged(FileInterface $before, FileInterface $after) { + public function assertFileUnchanged(FileInterface $before, FileInterface $after) { $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', array('%file1' => $before->id(), '%file2' => $after->id())), 'File unchanged'); $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', array('%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id())), 'File unchanged'); $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', array('%file1' => $before->getFilename(), '%file2' => $after->getFilename())), 'File unchanged'); @@ -115,7 +125,7 @@ function assertFileUnchanged(FileInterface $before, FileInterface $after) { * @param \Drupal\file\FileInterface $file2 * File object to compare. */ - function assertDifferentFile(FileInterface $file1, FileInterface $file2) { + public function assertDifferentFile(FileInterface $file1, FileInterface $file2) { $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', array('%file1' => $file1->id(), '%file2' => $file2->id())), 'Different file'); $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Different file'); } @@ -128,28 +138,30 @@ function assertDifferentFile(FileInterface $file1, FileInterface $file2) { * @param \Drupal\file\FileInterface $file2 * File object to compare. */ - function assertSameFile(FileInterface $file1, FileInterface $file2) { + public function assertSameFile(FileInterface $file1, FileInterface $file2) { $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', array('%file1' => $file1->id(), '%file2-fid' => $file2->id())), 'Same file'); $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Same file'); } /** - * Create a file and save it to the files table and assert that it occurs - * correctly. + * Create a file and save it to the files table and assert. + * + * that it occurs correctly. * - * @param $filepath + * @param string $filepath * Optional string specifying the file path. If none is provided then a * randomly named file will be created in the site's files directory. - * @param $contents + * @param string $contents * Optional contents to save into the file. If a NULL value is provided an * arbitrary string will be used. - * @param $scheme + * @param string $scheme * Optional string indicating the stream scheme to use. Drupal core includes * public, private, and temporary. The public wrapper is the default. - * @return \Drupal\file\FileInterface - * File entity. + * + * @return string + * \Drupal\file\FileInterface File entity. */ - function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) { + public function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) { // Don't count hook invocations caused by creating the file. \Drupal::state()->set('file_test.count_hook_invocations', FALSE); $file = entity_create('file', array( @@ -181,7 +193,7 @@ function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) { * @return string * File URI. */ - function createUri($filepath = NULL, $contents = NULL, $scheme = NULL) { + public function createUri($filepath = NULL, $contents = NULL, $scheme = NULL) { if (!isset($filepath)) { // Prefix with non-latin characters to ensure that all file-related // tests work with international filenames. diff --git a/core/modules/file/src/Tests/FileManagedUnitTestBase.php b/core/modules/file/src/Tests/FileManagedUnitTestBase.php index 051601a..2c240f9 100644 --- a/core/modules/file/src/Tests/FileManagedUnitTestBase.php +++ b/core/modules/file/src/Tests/FileManagedUnitTestBase.php @@ -11,8 +11,8 @@ use Drupal\simpletest\DrupalUnitTestBase; /** - * Base class for file unit tests that use the file_test module to test uploads and - * hooks. + * Base class for file unit tests that use the file_test module to test uploads + * and hooks. */ abstract class FileManagedUnitTestBase extends DrupalUnitTestBase { @@ -23,7 +23,7 @@ */ public static $modules = array('file_test', 'file', 'system', 'field', 'user'); - protected function setUp() { + public function setUp() { parent::setUp(); // Clear out any hook calls. file_test_reset(); @@ -42,14 +42,15 @@ protected function setUp() { } /** - * Assert that all of the specified hook_file_* hooks were called once, other - * values result in failure. + * Assert that all of the specified hook_file_* hooks were called once. * - * @param $expected + * other values result in failure. + * + * @param array $expected * Array with string containing with the hook name, e.g. 'load', 'save', * 'insert', etc. */ - function assertFileHooksCalled($expected) { + public function assertFileHooksCalled($expected) { \Drupal::state()->resetCache(); // Determine which hooks were called. @@ -58,7 +59,11 @@ function assertFileHooksCalled($expected) { // Determine if there were any expected that were not called. $uncalled = array_diff($expected, $actual); if (count($uncalled)) { - $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)))); + $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', + array( + '%expected' => implode(', ', $expected), + '%uncalled' => implode(', ', $uncalled), + ))); } else { $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected)))); @@ -77,14 +82,14 @@ function assertFileHooksCalled($expected) { /** * Assert that a hook_file_* hook was called a certain number of times. * - * @param $hook + * @param string $hook * String with the hook name, e.g. 'load', 'save', 'insert', etc. - * @param $expected_count + * @param int $expected_count * Optional integer count. - * @param $message + * @param string $message * Optional translated string message. */ - function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { + public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { $actual_count = count(file_test_get_calls($hook)); if (!isset($message)) { @@ -95,7 +100,12 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { $message = format_plural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count)); } else { - $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count)); + $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', + array( + '@name' => $hook, + '%expected' => $expected_count, + '%actual' => $actual_count, + )); } } $this->assertEqual($actual_count, $expected_count, $message); @@ -109,7 +119,7 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { * @param \Drupal\file\FileInterface $after * File object to compare. */ - function assertFileUnchanged(FileInterface $before, FileInterface $after) { + public function assertFileUnchanged(FileInterface $before, FileInterface $after) { $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', array('%file1' => $before->id(), '%file2' => $after->id())), 'File unchanged'); $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', array('%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id())), 'File unchanged'); $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', array('%file1' => $before->getFilename(), '%file2' => $after->getFilename())), 'File unchanged'); @@ -127,7 +137,7 @@ function assertFileUnchanged(FileInterface $before, FileInterface $after) { * @param \Drupal\file\FileInterface $file2 * File object to compare. */ - function assertDifferentFile(FileInterface $file1, FileInterface $file2) { + public function assertDifferentFile(FileInterface $file1, FileInterface $file2) { $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', array('%file1' => $file1->id(), '%file2' => $file2->id())), 'Different file'); $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Different file'); } @@ -140,28 +150,30 @@ function assertDifferentFile(FileInterface $file1, FileInterface $file2) { * @param \Drupal\file\FileInterface $file2 * File object to compare. */ - function assertSameFile(FileInterface $file1, FileInterface $file2) { + public function assertSameFile(FileInterface $file1, FileInterface $file2) { $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', array('%file1' => $file1->id(), '%file2-fid' => $file2->id())), 'Same file'); $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Same file'); } /** - * Create a file and save it to the files table and assert that it occurs - * correctly. + * Create a file and save it to the files table and assert that. + * + * it occurs correctly. * - * @param $filepath + * @param string $filepath * Optional string specifying the file path. If none is provided then a * randomly named file will be created in the site's files directory. - * @param $contents + * @param string $contents * Optional contents to save into the file. If a NULL value is provided an * arbitrary string will be used. - * @param $scheme + * @param string $scheme * Optional string indicating the stream scheme to use. Drupal core includes * public, private, and temporary. The public wrapper is the default. + * * @return \Drupal\file\FileInterface * File entity. */ - function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) { + public function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) { // Don't count hook invocations caused by creating the file. \Drupal::state()->set('file_test.count_hook_invocations', FALSE); $file = entity_create('file', array( @@ -193,7 +205,7 @@ function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) { * @return string * File URI. */ - function createUri($filepath = NULL, $contents = NULL, $scheme = NULL) { + public function createUri($filepath = NULL, $contents = NULL, $scheme = NULL) { if (!isset($filepath)) { // Prefix with non-latin characters to ensure that all file-related // tests work with international filenames. diff --git a/core/modules/file/src/Tests/FilePrivateTest.php b/core/modules/file/src/Tests/FilePrivateTest.php index d1561cc..2016275 100644 --- a/core/modules/file/src/Tests/FilePrivateTest.php +++ b/core/modules/file/src/Tests/FilePrivateTest.php @@ -33,7 +33,7 @@ protected function setUp() { /** * Tests file access for file uploaded to a private node. */ - function testPrivateFile() { + public function testPrivateFile() { $type_name = 'article'; $field_name = strtolower($this->randomMachineName()); $this->createFileField($field_name, 'node', $type_name, array('uri_scheme' => 'private')); @@ -55,7 +55,7 @@ function testPrivateFile() { $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); // Test with the field that should deny access through field access. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $nid = $this->uploadNodeFile($test_file, $no_access_field_name, $type_name, TRUE, array('private' => TRUE)); \Drupal::entityManager()->getStorage('node')->resetCache(array($nid)); $node = Node::load($nid); diff --git a/core/modules/file/src/Tests/FileTokenReplaceTest.php b/core/modules/file/src/Tests/FileTokenReplaceTest.php index 36fe888..8f564db 100644 --- a/core/modules/file/src/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/src/Tests/FileTokenReplaceTest.php @@ -19,7 +19,7 @@ class FileTokenReplaceTest extends FileFieldTestBase { /** * Creates a file, then tests the tokens generated from it. */ - function testFileTokenReplacement() { + public function testFileTokenReplacement() { $token_service = \Drupal::token(); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); @@ -52,7 +52,7 @@ function testFileTokenReplacement() { $tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->id); $tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->id); $tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->id); - $tests['[file:owner]'] = String::checkPlain(user_format_name($this->admin_user)); + $tests['[file:owner]'] = String::checkPlain(user_format_name($this->adminUser)); $tests['[file:owner:uid]'] = $file->getOwnerId(); // Test to make sure that we generated something for each token. diff --git a/core/modules/file/src/Tests/LoadTest.php b/core/modules/file/src/Tests/LoadTest.php index 7c593cb..58d2d8d 100644 --- a/core/modules/file/src/Tests/LoadTest.php +++ b/core/modules/file/src/Tests/LoadTest.php @@ -16,7 +16,7 @@ class LoadTest extends FileManagedUnitTestBase { /** * Try to load a non-existent file by fid. */ - function testLoadMissingFid() { + public function testLoadMissingFid() { $this->assertFalse(file_load(-1), 'Try to load an invalid fid fails.'); $this->assertFileHooksCalled(array()); } @@ -24,7 +24,7 @@ function testLoadMissingFid() { /** * Try to load a non-existent file by URI. */ - function testLoadMissingFilepath() { + public function testLoadMissingFilepath() { $files = entity_load_multiple_by_properties('file', array('uri' => 'foobar://misc/druplicon.png')); $this->assertFalse(reset($files), "Try to load a file that doesn't exist in the database fails."); $this->assertFileHooksCalled(array()); @@ -33,7 +33,7 @@ function testLoadMissingFilepath() { /** * Try to load a non-existent file by status. */ - function testLoadInvalidStatus() { + public function testLoadInvalidStatus() { $files = entity_load_multiple_by_properties('file', array('status' => -99)); $this->assertFalse(reset($files), 'Trying to load a file with an invalid status fails.'); $this->assertFileHooksCalled(array()); @@ -42,7 +42,7 @@ function testLoadInvalidStatus() { /** * Load a single file and ensure that the correct values are returned. */ - function testSingleValues() { + public function testSingleValues() { // Create a new file entity from scratch so we know the values. $file = $this->createFile('druplicon.txt', NULL, 'public'); @@ -60,7 +60,7 @@ function testSingleValues() { /** * This will test loading file data from the database. */ - function testMultiple() { + public function testMultiple() { // Create a new file entity. $file = $this->createFile('druplicon.txt', NULL, 'public'); diff --git a/core/modules/file/src/Tests/MoveTest.php b/core/modules/file/src/Tests/MoveTest.php index 9b1bfc2..f0198d5 100644 --- a/core/modules/file/src/Tests/MoveTest.php +++ b/core/modules/file/src/Tests/MoveTest.php @@ -16,7 +16,7 @@ class MoveTest extends FileManagedUnitTestBase { /** * Move a normal file. */ - function testNormal() { + public function testNormal() { $contents = $this->randomMachineName(10); $source = $this->createFile(NULL, $contents); $desired_filepath = 'public://' . $this->randomMachineName(); @@ -46,7 +46,7 @@ function testNormal() { /** * Test renaming when moving onto a file that already exists. */ - function testExistingRename() { + public function testExistingRename() { // Setup a file to overwrite. $contents = $this->randomMachineName(10); $source = $this->createFile(NULL, $contents); @@ -81,7 +81,7 @@ function testExistingRename() { /** * Test replacement when moving onto a file that already exists. */ - function testExistingReplace() { + public function testExistingReplace() { // Setup a file to overwrite. $contents = $this->randomMachineName(10); $source = $this->createFile(NULL, $contents); @@ -113,7 +113,7 @@ function testExistingReplace() { /** * Test replacement when moving onto itself. */ - function testExistingReplaceSelf() { + public function testExistingReplaceSelf() { // Setup a file to overwrite. $contents = $this->randomMachineName(10); $source = $this->createFile(NULL, $contents); @@ -133,10 +133,11 @@ function testExistingReplaceSelf() { } /** - * Test that moving onto an existing file fails when FILE_EXISTS_ERROR is - * specified. + * Test that moving onto an existing file fails when. + * + * FILE_EXISTS_ERROR is specified. */ - function testExistingError() { + public function testExistingError() { $contents = $this->randomMachineName(10); $source = $this->createFile(); $target = $this->createFile(NULL, $contents); diff --git a/core/modules/file/src/Tests/RemoteFileSaveUploadTest.php b/core/modules/file/src/Tests/RemoteFileSaveUploadTest.php index 81f4340..b087e12 100644 --- a/core/modules/file/src/Tests/RemoteFileSaveUploadTest.php +++ b/core/modules/file/src/Tests/RemoteFileSaveUploadTest.php @@ -21,7 +21,7 @@ class RemoteFileSaveUploadTest extends SaveUploadTest { */ public static $modules = array('file_test'); - protected function setUp() { + public function setUp() { parent::setUp(); \Drupal::config('system.file')->set('default_scheme', 'dummy-remote')->save(); } diff --git a/core/modules/file/src/Tests/SaveDataTest.php b/core/modules/file/src/Tests/SaveDataTest.php index 8368e0b..3e7622f 100644 --- a/core/modules/file/src/Tests/SaveDataTest.php +++ b/core/modules/file/src/Tests/SaveDataTest.php @@ -16,7 +16,7 @@ class SaveDataTest extends FileManagedUnitTestBase { /** * Test the file_save_data() function when no filename is provided. */ - function testWithoutFilename() { + public function testWithoutFilename() { $contents = $this->randomMachineName(8); $result = file_save_data($contents); @@ -38,7 +38,7 @@ function testWithoutFilename() { /** * Test the file_save_data() function when a filename is provided. */ - function testWithFilename() { + public function testWithFilename() { $contents = $this->randomMachineName(8); // Using filename with non-latin characters. @@ -63,7 +63,7 @@ function testWithFilename() { /** * Test file_save_data() when renaming around an existing file. */ - function testExistingRename() { + public function testExistingRename() { // Setup a file to overwrite. $existing = $this->createFile(); $contents = $this->randomMachineName(8); @@ -91,7 +91,7 @@ function testExistingRename() { /** * Test file_save_data() when replacing an existing file. */ - function testExistingReplace() { + public function testExistingReplace() { // Setup a file to overwrite. $existing = $this->createFile(); $contents = $this->randomMachineName(8); @@ -118,7 +118,7 @@ function testExistingReplace() { /** * Test that file_save_data() fails overwriting an existing file. */ - function testExistingError() { + public function testExistingError() { $contents = $this->randomMachineName(8); $existing = $this->createFile(NULL, $contents); diff --git a/core/modules/file/src/Tests/SaveTest.php b/core/modules/file/src/Tests/SaveTest.php index ee6c1a3..9d5caac 100644 --- a/core/modules/file/src/Tests/SaveTest.php +++ b/core/modules/file/src/Tests/SaveTest.php @@ -15,7 +15,7 @@ * @group file */ class SaveTest extends FileManagedUnitTestBase { - function testFileSave() { + public function testFileSave() { // Create a new file entity. $file = entity_create('file', array( 'uid' => 1, @@ -57,8 +57,9 @@ function testFileSave() { $this->assertEqual($loaded_file->isPermanent(), $file->isPermanent(), 'Status was saved correctly.'); $this->assertEqual($loaded_file->langcode->value, 'en', 'Langcode was saved correctly.'); - // Try to insert a second file with the same name apart from case insensitivity - // to ensure the 'uri' index allows for filenames with different cases. + // Try to insert a second file with the same name apart from case + // insensitivity to ensure the 'uri' index allows for filenames + // with different cases. $file = entity_create('file', array( 'uid' => 1, 'filename' => 'DRUPLICON.txt', diff --git a/core/modules/file/src/Tests/SaveUploadTest.php b/core/modules/file/src/Tests/SaveUploadTest.php index 30e681d..bb762a5 100644 --- a/core/modules/file/src/Tests/SaveUploadTest.php +++ b/core/modules/file/src/Tests/SaveUploadTest.php @@ -28,7 +28,7 @@ class SaveUploadTest extends FileManagedTestBase { */ protected $maxFidBefore; - protected function setUp() { + public function setUp() { parent::setUp(); $account = $this->drupalCreateUser(); $this->drupalLogin($account); @@ -62,7 +62,7 @@ protected function setUp() { /** * Test the file_save_upload() function. */ - function testNormal() { + public function testNormal() { $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField(); $this->assertTrue($max_fid_after > $this->maxFidBefore, 'A new file was created.'); $file1 = file_load($max_fid_after); @@ -111,7 +111,7 @@ function testNormal() { /** * Test extension handling. */ - function testHandleExtension() { + public function testHandleExtension() { // The file being tested is a .gif which is in the default safe list // of extensions to allow when the extension validator isn't used. This is // implicitly tested at the testNormal() test. Here we tell @@ -172,7 +172,7 @@ function testHandleExtension() { /** * Test dangerous file handling. */ - function testHandleDangerousFile() { + public function testHandleDangerousFile() { $config = \Drupal::config('system.file'); // Allow the .php extension and make sure it gets renamed to .txt for // safety. Also check to make sure its MIME type was changed. @@ -215,7 +215,7 @@ function testHandleDangerousFile() { /** * Test file munge handling. */ - function testHandleFileMunge() { + public function testHandleFileMunge() { // Ensure insecure uploads are disabled for this test. \Drupal::config('system.file')->set('allow_insecure_uploads', 0)->save(); $this->image = file_move($this->image, $this->image->getFileUri() . '.foo.' . $this->image_extension); @@ -264,10 +264,10 @@ function testHandleFileMunge() { /** * Test renaming when uploading over a file that already exists. */ - function testExistingRename() { + public function testExistingRename() { $edit = array( 'file_test_replace' => FILE_EXISTS_RENAME, - 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()) + 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()), ); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, 'Received a 200 response for posted test file.'); @@ -280,10 +280,10 @@ function testExistingRename() { /** * Test replacement when uploading over a file that already exists. */ - function testExistingReplace() { + public function testExistingReplace() { $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()) + 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()), ); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, 'Received a 200 response for posted test file.'); @@ -296,10 +296,10 @@ function testExistingReplace() { /** * Test for failure when uploading over a file that already exists. */ - function testExistingError() { + public function testExistingError() { $edit = array( 'file_test_replace' => FILE_EXISTS_ERROR, - 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()) + 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()), ); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, 'Received a 200 response for posted test file.'); @@ -312,7 +312,7 @@ function testExistingError() { /** * Test for no failures when not uploading a file. */ - function testNoUpload() { + public function testNoUpload() { $this->drupalPostForm('file-test/upload', array(), t('Submit')); $this->assertNoRaw(t('Epic upload FAIL!'), 'Failure message not found.'); } diff --git a/core/modules/file/src/Tests/SpaceUsedTest.php b/core/modules/file/src/Tests/SpaceUsedTest.php index b9ad13f..6c5b124 100644 --- a/core/modules/file/src/Tests/SpaceUsedTest.php +++ b/core/modules/file/src/Tests/SpaceUsedTest.php @@ -13,7 +13,7 @@ * @group file */ class SpaceUsedTest extends FileManagedUnitTestBase { - protected function setUp() { + public function setUp() { parent::setUp(); // Create records for a couple of users with different sizes. @@ -56,14 +56,14 @@ protected function createFileWithSize($uri, $size, $uid, $status = FILE_STATUS_P /** * Test different users with the default status. */ - function testFileSpaceUsed() { + public function testFileSpaceUsed() { $file = $this->container->get('entity.manager')->getStorage('file'); // Test different users with default status. $this->assertEqual($file->spaceUsed(2), 70); $this->assertEqual($file->spaceUsed(3), 300); $this->assertEqual($file->spaceUsed(), 370); - // Test the status fields + // Test the status fields. $this->assertEqual($file->spaceUsed(NULL, 0), 4); $this->assertEqual($file->spaceUsed(NULL, FILE_STATUS_PERMANENT), 370); diff --git a/core/modules/file/src/Tests/UsageTest.php b/core/modules/file/src/Tests/UsageTest.php index d251bec..e292b02 100644 --- a/core/modules/file/src/Tests/UsageTest.php +++ b/core/modules/file/src/Tests/UsageTest.php @@ -16,7 +16,7 @@ class UsageTest extends FileManagedUnitTestBase { /** * Tests \Drupal\file\FileUsage\DatabaseFileUsageBackend::listUsage(). */ - function testGetUsage() { + public function testGetUsage() { $file = $this->createFile(); db_insert('file_usage') ->fields(array( @@ -24,7 +24,7 @@ function testGetUsage() { 'module' => 'testing', 'type' => 'foo', 'id' => 1, - 'count' => 1 + 'count' => 1, )) ->execute(); db_insert('file_usage') @@ -33,7 +33,7 @@ function testGetUsage() { 'module' => 'testing', 'type' => 'bar', 'id' => 2, - 'count' => 2 + 'count' => 2, )) ->execute(); @@ -49,7 +49,7 @@ function testGetUsage() { /** * Tests \Drupal\file\FileUsage\DatabaseFileUsageBackend::add(). */ - function testAddUsage() { + public function testAddUsage() { $file = $this->createFile(); $file_usage = $this->container->get('file.usage'); $file_usage->add($file, 'testing', 'foo', 1); @@ -75,7 +75,7 @@ function testAddUsage() { /** * Tests \Drupal\file\FileUsage\DatabaseFileUsageBackend::delete(). */ - function testRemoveUsage() { + public function testRemoveUsage() { $file = $this->createFile(); $file_usage = $this->container->get('file.usage'); db_insert('file_usage') @@ -159,7 +159,7 @@ function createTempFiles() { /** * Ensure that temporary files are removed by default. */ - function testTempFileCleanupDefault() { + public function testTempFileCleanupDefault() { list($temp_old, $temp_new, $perm_old, $perm_new) = $this->createTempFiles(); // Run cron and then ensure that only the old, temp file was deleted. @@ -173,7 +173,7 @@ function testTempFileCleanupDefault() { /** * Ensure that temporary files are kept as configured. */ - function testTempFileNoCleanup() { + public function testTempFileNoCleanup() { list($temp_old, $temp_new, $perm_old, $perm_new) = $this->createTempFiles(); // Set the max age to 0, meaning no temporary files will be deleted. @@ -192,7 +192,7 @@ function testTempFileNoCleanup() { /** * Ensure that temporary files are kept as configured. */ - function testTempFileCustomCleanup() { + public function testTempFileCustomCleanup() { list($temp_old, $temp_new, $perm_old, $perm_new) = $this->createTempFiles(); // Set the max age to older than default. diff --git a/core/modules/file/src/Tests/ValidateTest.php b/core/modules/file/src/Tests/ValidateTest.php index 943a830..bc83dc6 100644 --- a/core/modules/file/src/Tests/ValidateTest.php +++ b/core/modules/file/src/Tests/ValidateTest.php @@ -16,7 +16,7 @@ class ValidateTest extends FileManagedUnitTestBase { /** * Test that the validators passed into are checked. */ - function testCallerValidation() { + public function testCallerValidation() { $file = $this->createFile(); // Empty validators. @@ -35,7 +35,8 @@ function testCallerValidation() { file_test_reset(); file_test_set_return('validate', array('Epic fail')); $failing = array('file_test_validator' => array(array('Failed', 'Badly'))); - $this->assertEqual(file_validate($file, $failing), array('Failed', 'Badly', 'Epic fail'), 'Validating returns errors.'); + $this->assertEqual(file_validate($file, $failing), array( + 'Failed', 'Badly', 'Epic fail'), 'Validating returns errors.'); $this->assertFileHooksCalled(array('validate')); } } diff --git a/core/modules/file/src/Tests/ValidatorTest.php b/core/modules/file/src/Tests/ValidatorTest.php index b1824b2..dde62a6 100644 --- a/core/modules/file/src/Tests/ValidatorTest.php +++ b/core/modules/file/src/Tests/ValidatorTest.php @@ -24,7 +24,7 @@ class ValidatorTest extends FileManagedUnitTestBase { */ protected $non_image; - protected function setUp() { + public function setUp() { parent::setUp(); $this->image = entity_create('file'); @@ -39,7 +39,7 @@ protected function setUp() { /** * Test the file_validate_extensions() function. */ - function testFileValidateExtensions() { + public function testFileValidateExtensions() { $file = entity_create('file', array('filename' => 'asdf.txt')); $errors = file_validate_extensions($file, 'asdf txt pork'); $this->assertEqual(count($errors), 0, 'Valid extension accepted.', 'File'); @@ -50,9 +50,9 @@ function testFileValidateExtensions() { } /** - * This ensures a specific file is actually an image. + * This ensures a specific file is actually an image. */ - function testFileValidateIsImage() { + public function testFileValidateIsImage() { $this->assertTrue(file_exists($this->image->getFileUri()), 'The image being tested exists.', 'File'); $errors = file_validate_is_image($this->image); $this->assertEqual(count($errors), 0, 'No error reported for our image file.', 'File'); @@ -63,10 +63,11 @@ function testFileValidateIsImage() { } /** - * 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() { + public function testFileValidateImageResolution() { // Non-images. $errors = file_validate_image_resolution($this->non_image); $this->assertEqual(count($errors), 0, 'Should not get any errors for a non-image file.', 'File'); @@ -105,16 +106,17 @@ function testFileValidateImageResolution() { drupal_unlink('temporary://druplicon.png'); } else { - // TODO: should check that the error is returned if no toolkit is available. + // TODO: should check that the error is returned + // if no toolkit is available. $errors = file_validate_image_resolution($this->image, '5x10'); $this->assertEqual(count($errors), 1, 'Oversize images that cannot be scaled get an error.', 'File'); } } /** - * This will ensure the filename length is valid. + * This will ensure the filename length is valid. */ - function testFileValidateNameLength() { + public function testFileValidateNameLength() { // Create a new file entity. $file = entity_create('file'); @@ -139,7 +141,7 @@ function testFileValidateNameLength() { /** * Test file_validate_size(). */ - function testFileValidateSize() { + public function testFileValidateSize() { // Run these tests as a regular user. $user = entity_create('user', array('uid' => 2, 'name' => $this->randomMachineName())); $user->enforceIsNew(); diff --git a/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php b/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php index 0529090..c61d275 100644 --- a/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php +++ b/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php @@ -16,6 +16,8 @@ class FileModuleTestForm extends FormBase { /** + * Returns file module test form. + * * {@inheritdoc} */ public function getFormId() { diff --git a/core/modules/file/tests/file_test/src/DummyReadOnlyStreamWrapper.php b/core/modules/file/tests/file_test/src/DummyReadOnlyStreamWrapper.php index d230bc5..0c1690a 100644 --- a/core/modules/file/tests/file_test/src/DummyReadOnlyStreamWrapper.php +++ b/core/modules/file/tests/file_test/src/DummyReadOnlyStreamWrapper.php @@ -15,7 +15,7 @@ * Dummy stream wrapper implementation (dummy-readonly://). */ class DummyReadOnlyStreamWrapper extends LocalReadOnlyStream { - function getDirectoryPath() { + public function getDirectoryPath() { return conf_path() . '/files'; } @@ -24,7 +24,7 @@ function getDirectoryPath() { * * Return a dummy path for testing. */ - function getInternalUri() { + public function getInternalUri() { return '/dummy/example.txt'; } @@ -33,7 +33,7 @@ function getInternalUri() { * * Return the HTML URI of a public file. */ - function getExternalUrl() { + public function getExternalUrl() { return '/dummy/example.txt'; } } diff --git a/core/modules/file/tests/file_test/src/DummyRemoteStreamWrapper.php b/core/modules/file/tests/file_test/src/DummyRemoteStreamWrapper.php index 2741196..ad91a3f 100644 --- a/core/modules/file/tests/file_test/src/DummyRemoteStreamWrapper.php +++ b/core/modules/file/tests/file_test/src/DummyRemoteStreamWrapper.php @@ -17,7 +17,7 @@ * Basically just the public scheme but not returning a local file for realpath. */ class DummyRemoteStreamWrapper extends PublicStream { - function realpath() { + public function realpath() { return FALSE; } } diff --git a/core/modules/file/tests/file_test/src/DummyStreamWrapper.php b/core/modules/file/tests/file_test/src/DummyStreamWrapper.php index cbea40f..6d6e31d 100644 --- a/core/modules/file/tests/file_test/src/DummyStreamWrapper.php +++ b/core/modules/file/tests/file_test/src/DummyStreamWrapper.php @@ -15,7 +15,7 @@ * Dummy stream wrapper implementation (dummy://). */ class DummyStreamWrapper extends LocalStream { - function getDirectoryPath() { + public function getDirectoryPath() { return conf_path() . '/files'; } @@ -24,7 +24,7 @@ function getDirectoryPath() { * * Return a dummy path for testing. */ - function getInternalUri() { + public function getInternalUri() { return '/dummy/example.txt'; } @@ -33,7 +33,7 @@ function getInternalUri() { * * Return the HTML URI of a public file. */ - function getExternalUrl() { + public function getExternalUrl() { return '/dummy/example.txt'; } } diff --git a/core/modules/syslog/src/Tests/SyslogTest.php b/core/modules/syslog/src/Tests/SyslogTest.php index 6d479ac..3cb4b30 100644 --- a/core/modules/syslog/src/Tests/SyslogTest.php +++ b/core/modules/syslog/src/Tests/SyslogTest.php @@ -37,7 +37,8 @@ function testSettings() { $this->drupalGet('admin/config/development/logging'); if ($this->parse()) { - $field = $this->xpath('//option[@value=:value]', array(':value' => LOG_LOCAL6)); // Should be one field. + // Should be one field. + $field = $this->xpath('//option[@value=:value]', array(':value' => LOG_LOCAL6)); $this->assertTrue($field[0]['selected'] == 'selected', 'Facility value saved.'); } }