From 8a0c8abaec86b4e73b46bec29806c88e0cb73315 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Thu, 3 Oct 2013 22:13:40 +0300 Subject: [PATCH] Issue #2104229 by claudiu.cristea: Deprecate file_usage(). --- core/includes/file.inc | 2 -- core/modules/editor/editor.module | 4 ++-- .../Drupal/editor/Tests/EditorFileUsageTest.php | 15 ++++++++------- core/modules/file/file.module | 15 +++++++++------ core/modules/file/lib/Drupal/file/Entity/File.php | 4 ++-- .../lib/Drupal/file/FileUsage/FileUsageBase.php | 4 ++-- .../Plugin/field/field_type/FileFieldItemList.php | 6 +++--- .../file/Plugin/field/field_type/FileItem.php | 6 +++--- .../file/lib/Drupal/file/Tests/DeleteTest.php | 13 +++++++------ .../file/lib/Drupal/file/Tests/FileListingTest.php | 9 +++++---- .../file/lib/Drupal/file/Tests/UsageTest.php | 22 ++++++++++++---------- core/modules/image/image.module | 12 ++++++------ .../Tests/Upgrade/UserPictureUpgradePathTest.php | 5 +++-- 13 files changed, 62 insertions(+), 55 deletions(-) diff --git a/core/includes/file.inc b/core/includes/file.inc index 788f213..b023a67 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -912,7 +912,6 @@ function file_create_filename($basename, $directory) { * The file id. * * @see file_unmanaged_delete() - * @see file_usage()->listUsage() */ function file_delete($fid) { return file_delete_multiple(array($fid)); @@ -929,7 +928,6 @@ function file_delete($fid) { * The file id. * * @see file_unmanaged_delete() - * @see file_usage()->listUsage() */ function file_delete_multiple(array $fids) { entity_delete_multiple('file', $fids); diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 6364102..5d31cd1 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -488,7 +488,7 @@ function _editor_record_file_usage(array $uuids, EntityInterface $entity) { $file->status = FILE_STATUS_PERMANENT; $file->save(); } - file_usage()->add($file, 'editor', $entity->entityType(), $entity->id()); + \Drupal::service('file.usage')->add($file, 'editor', $entity->entityType(), $entity->id()); } } @@ -508,7 +508,7 @@ function _editor_record_file_usage(array $uuids, EntityInterface $entity) { function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count) { foreach ($uuids as $uuid) { $file = entity_load_by_uuid('file', $uuid); - file_usage()->delete($file, 'editor', $entity->entityType(), $entity->id(), $count); + \Drupal::service('file.usage')->delete($file, 'editor', $entity->entityType(), $entity->id(), $count); } } diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorFileUsageTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorFileUsageTest.php index 97715b5..e9bd058 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/EditorFileUsageTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorFileUsageTest.php @@ -63,7 +63,8 @@ function testEditorEntityHooks() { $image->setFileUri('core/misc/druplicon.png'); $image->setFilename(drupal_basename($image->getFileUri())); $image->save(); - $this->assertIdentical(array(), file_usage()->listUsage($image), 'The image has zero usages.'); + $file_usage = $this->container->get('file.usage'); + $this->assertIdentical(array(), $file_usage->listUsage($image), 'The image has zero usages.'); // Test editor_entity_insert(): increment. $this->createUser(); @@ -77,7 +78,7 @@ function testEditorEntityHooks() { 'uid' => 1, )); $node->save(); - $this->assertIdentical(array('editor' => array('node' => array(1 => '1'))), file_usage()->listUsage($image), 'The image has 1 usage.'); + $this->assertIdentical(array('editor' => array('node' => array(1 => '1'))), $file_usage->listUsage($image), 'The image has 1 usage.'); // Test editor_entity_update(): increment, twice, by creating new revisions. $node->setNewRevision(TRUE); @@ -85,7 +86,7 @@ function testEditorEntityHooks() { $second_revision_id = $node->getRevisionId(); $node->setNewRevision(TRUE); $node->save(); - $this->assertIdentical(array('editor' => array('node' => array(1 => '3'))), file_usage()->listUsage($image), 'The image has 3 usages.'); + $this->assertIdentical(array('editor' => array('node' => array(1 => '3'))), $file_usage->listUsage($image), 'The image has 3 usages.'); // Test hook_entity_update(): decrement, by modifying the last revision: // remove the data- attribute from the body field. @@ -94,21 +95,21 @@ function testEditorEntityHooks() { $new_value = str_replace('data-editor-file-uuid', 'data-editor-file-uuid-modified', $original_value); $body->setValue($new_value); $node->save(); - $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), file_usage()->listUsage($image), 'The image has 2 usages.'); + $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image), 'The image has 2 usages.'); // Test hook_entity_update(): increment, by modifying the last revision: // readd the data- attribute to the body field. $node->get('body')->offsetGet(0)->get('value')->setValue($original_value); $node->save(); - $this->assertIdentical(array('editor' => array('node' => array(1 => '3'))), file_usage()->listUsage($image), 'The image has 3 usages.'); + $this->assertIdentical(array('editor' => array('node' => array(1 => '3'))), $file_usage->listUsage($image), 'The image has 3 usages.'); // Test editor_entity_revision_delete(): decrement, by deleting a revision. entity_revision_delete('node', $second_revision_id); - $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), file_usage()->listUsage($image), 'The image has 2 usages.'); + $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image), 'The image has 2 usages.'); // Test editor_entity_delete(). $node->delete(); - $this->assertIdentical(array(), file_usage()->listUsage($image), 'The image has zero usages again.'); + $this->assertIdentical(array(), $file_usage->listUsage($image), 'The image has zero usages again.'); } } diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 16ce43f..c881fad 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -121,6 +121,9 @@ function file_load($fid, $reset = FALSE) { /** * Returns the file usage service. * + * @deprecated as of Drupal 8.0. Use \Drupal::service('file.usage') instead, or + * even better have the file usage service injected into your object. + * * @return \Drupal\file\FileUsage\FileUsageInterface. */ function file_usage() { @@ -274,7 +277,7 @@ function file_move(File $source, $destination = NULL, $replace = FILE_EXISTS_REN \Drupal::moduleHandler()->invokeAll('file_move', array($file, $source)); // Delete the original if it's not in use elsewhere. - if ($delete_source && !file_usage()->listUsage($source)) { + if ($delete_source && !\Drupal::service('file.usage')->listUsage($source)) { $source->delete(); } @@ -702,7 +705,7 @@ function file_cron() { $result = \Drupal::entityManager()->getStorageController('file')->retrieveTemporaryFiles(); foreach ($result as $row) { if ($file = file_load($row->fid)) { - $references = file_usage()->listUsage($file); + $references = \Drupal::service('file.usage')->listUsage($file); if (empty($references)) { if (file_exists($file->getFileUri())) { $file->delete(); @@ -722,8 +725,8 @@ function file_cron() { * Saves file uploads to a new location. * * The files will be added to the {file_managed} table as temporary files. - * Temporary files are periodically cleaned. Use file_usage()->add() to register - * the usage of the file which will automatically mark it as permanent. + * Temporary files are periodically cleaned. Use the 'file.usage' service to + * register the usage of the file which will automatically mark it as permanent. * * @param $form_field_name * A string that is the associative array key of the upload form element in @@ -1359,7 +1362,7 @@ function file_managed_file_validate(&$element, &$form_state) { foreach ($fids as $fid) { if ($file = file_load($fid)) { if ($file->isPermanent()) { - $references = file_usage()->listUsage($file); + $references = \Drupal::service('file.usage')->listUsage($file); if (empty($references)) { form_error($element, t('The file used in the !name field may not be referenced.', array('!name' => $element['#title']))); } @@ -1852,7 +1855,7 @@ function file_get_file_references(File $file, $field = NULL, $age = EntityStorag // Fill the static cache, disregard $field and $field_type for now. if (!isset($references[$file->id()][$age])) { $references[$file->id()][$age] = array(); - $usage_list = file_usage()->listUsage($file); + $usage_list = \Drupal::service('file.usage')->listUsage($file); $file_usage_list = isset($usage_list['file']) ? $usage_list['file'] : array(); foreach ($file_usage_list as $entity_type => $entity_ids) { $entity_info = entity_get_info($entity_type); diff --git a/core/modules/file/lib/Drupal/file/Entity/File.php b/core/modules/file/lib/Drupal/file/Entity/File.php index b8823e3..17c70f5 100644 --- a/core/modules/file/lib/Drupal/file/Entity/File.php +++ b/core/modules/file/lib/Drupal/file/Entity/File.php @@ -199,10 +199,10 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr foreach ($entities as $entity) { // Delete all remaining references to this file. - $file_usage = file_usage()->listUsage($entity); + $file_usage = \Drupal::service('file.usage')->listUsage($entity); if (!empty($file_usage)) { foreach ($file_usage as $module => $usage) { - file_usage()->delete($entity, $module); + \Drupal::service('file.usage')->delete($entity, $module); } } // Delete the actual file. Failures due to invalid files and files that diff --git a/core/modules/file/lib/Drupal/file/FileUsage/FileUsageBase.php b/core/modules/file/lib/Drupal/file/FileUsage/FileUsageBase.php index 2111492..aef295c 100644 --- a/core/modules/file/lib/Drupal/file/FileUsage/FileUsageBase.php +++ b/core/modules/file/lib/Drupal/file/FileUsage/FileUsageBase.php @@ -18,7 +18,7 @@ * Implements Drupal\file\FileUsage\FileUsageInterface::add(). */ public function add(File $file, $module, $type, $id, $count = 1) { - // Make sure that a used file is permament. + // Make sure that a used file is permanent. if (!$file->isPermanent()) { $file->setPermanent(); $file->save(); @@ -31,7 +31,7 @@ public function add(File $file, $module, $type, $id, $count = 1) { public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1) { // If there are no more remaining usages of this file, mark it as temporary, // which result in a delete through system_cron(). - $usage = file_usage()->listUsage($file); + $usage = \Drupal::service('file.usage')->listUsage($file); if (empty($usage)) { $file->setTemporary(); $file->save(); diff --git a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileFieldItemList.php b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileFieldItemList.php index 5420d8e..169c3d0 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileFieldItemList.php +++ b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileFieldItemList.php @@ -37,7 +37,7 @@ protected function updateFileUsage() { // deletion of previous file usages are necessary. if (!empty($entity->original) && $entity->getRevisionId() != $entity->original->getRevisionId()) { foreach ($this->list as $item) { - file_usage()->add($item->entity, 'file', $entity->entityType(), $entity->id()); + \Drupal::service('file.usage')->add($item->entity, 'file', $entity->entityType(), $entity->id()); } return; } @@ -56,14 +56,14 @@ protected function updateFileUsage() { $original_fids[] = $item->target_id; if ($item->target_id && !in_array($item->target_id, $fids)) { // Decrement the file usage count by 1. - file_usage()->delete($item->entity, 'file', $entity->entityType(), $entity->id()); + \Drupal::service('file.usage')->delete($item->entity, 'file', $entity->entityType(), $entity->id()); } } // Add new usage entries for newly added files. foreach ($this->list as $item) { if ($item->target_id && !in_array($item->target_id, $original_fids)) { - file_usage()->add($item->entity, 'file', $entity->entityType(), $entity->id()); + \Drupal::service('file.usage')->add($item->entity, 'file', $entity->entityType(), $entity->id()); } } } diff --git a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php index fc6be34..2dba6f3 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php +++ b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php @@ -208,7 +208,7 @@ public function insert() { $entity = $this->getRoot(); // Add a new usage for this new uploaded file. - file_usage()->add($this->entity, 'file', $entity->entityType(), $entity->id()); + \Drupal::service('file.usage')->add($this->entity, 'file', $entity->entityType(), $entity->id()); } /** @@ -219,7 +219,7 @@ public function delete() { $entity = $this->getRoot(); // Delete all file usages within this entity. - file_usage()->delete($this->entity, 'file', $entity->entityType(), $entity->id(), 0); + \Drupal::service('file.usage')->delete($this->entity, 'file', $entity->entityType(), $entity->id(), 0); } /** @@ -230,7 +230,7 @@ public function deleteRevision() { $entity = $this->getRoot(); // Decrement the file usage count by 1. - file_usage()->delete($this->entity, 'file', $entity->entityType(), $entity->id()); + \Drupal::service('file.usage')->delete($this->entity, 'file', $entity->entityType(), $entity->id()); } /** diff --git a/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php b/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php index 9bd52bc..c6486fe 100644 --- a/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php @@ -38,11 +38,12 @@ function testUnused() { */ function testInUse() { $file = $this->createFile(); - file_usage()->add($file, 'testing', 'test', 1); - file_usage()->add($file, 'testing', 'test', 1); + $file_usage = $this->container->get('file.usage'); + $file_usage->add($file, 'testing', 'test', 1); + $file_usage->add($file, 'testing', 'test', 1); - file_usage()->delete($file, 'testing', 'test', 1); - $usage = file_usage()->listUsage($file); + $file_usage->delete($file, 'testing', 'test', 1); + $usage = $file_usage->listUsage($file); $this->assertEqual($usage['testing']['test'], array(1 => 1), 'Test file is still in use.'); $this->assertTrue(file_exists($file->getFileUri()), 'File still exists on the disk.'); $this->assertTrue(file_load($file->id()), 'File still exists in the database.'); @@ -50,8 +51,8 @@ function testInUse() { // Clear out the call to hook_file_load(). file_test_reset(); - file_usage()->delete($file, 'testing', 'test', 1); - $usage = file_usage()->listUsage($file); + $file_usage->delete($file, 'testing', 'test', 1); + $usage = $file_usage->listUsage($file); $this->assertFileHooksCalled(array('load', 'update')); $this->assertTrue(empty($usage), 'File usage data was removed.'); $this->assertTrue(file_exists($file->getFileUri()), 'File still exists on the disk.'); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php b/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php index 3126560..424514b 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php @@ -60,7 +60,8 @@ protected function sumUsages($usage) { * Tests file overview with different user permissions. */ function testFileListingPages() { - // Users without sufficent permissions should not see file listing. + $file_usage = $this->container->get('file.usage'); + // Users without sufficient permissions should not see file listing. $this->drupalLogin($this->base_user); $this->drupalGet('admin/content/files'); $this->assertResponse(403); @@ -102,11 +103,11 @@ function testFileListingPages() { $this->drupalGet('admin/content/files'); $file = entity_load('file', $orphaned_file); - $usage = $this->sumUsages(file_usage()->listUsage($file)); + $usage = $this->sumUsages($file_usage->listUsage($file)); $this->assertRaw('admin/content/files/usage/' . $file->id() . '">' . $usage); $file = entity_load('file', $used_file); - $usage = $this->sumUsages(file_usage()->listUsage($file)); + $usage = $this->sumUsages($file_usage->listUsage($file)); $this->assertRaw('admin/content/files/usage/' . $file->id() . '">' . $usage); $result = $this->xpath("//td[contains(@class, 'views-field-status') and contains(text(), :value)]", array(':value' => t('Temporary'))); @@ -115,7 +116,7 @@ function testFileListingPages() { // Test file usage page. foreach ($nodes as $node) { $file = entity_load('file', $node->file->target_id); - $usage = file_usage()->listUsage($file); + $usage = $file_usage->listUsage($file); $this->drupalGet('admin/content/files/usage/' . $file->id()); $this->assertResponse(200); $this->assertText($node->getTitle(), 'Node title found on usage page.'); diff --git a/core/modules/file/lib/Drupal/file/Tests/UsageTest.php b/core/modules/file/lib/Drupal/file/Tests/UsageTest.php index 17e51d8..c4b053c 100644 --- a/core/modules/file/lib/Drupal/file/Tests/UsageTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/UsageTest.php @@ -20,7 +20,7 @@ public static function getInfo() { } /** - * Tests file_usage()->listUsage(). + * Tests \Drupal\file\FileUsage\DatabaseFileUsageBackend::listUsage(). */ function testGetUsage() { $file = $this->createFile(); @@ -43,7 +43,7 @@ function testGetUsage() { )) ->execute(); - $usage = file_usage()->listUsage($file); + $usage = $this->container->get('file.usage')->listUsage($file); $this->assertEqual(count($usage['testing']), 2, 'Returned the correct number of items.'); $this->assertTrue(isset($usage['testing']['foo'][1]), 'Returned the correct id.'); @@ -53,15 +53,16 @@ function testGetUsage() { } /** - * Tests file_usage()->add(). + * Tests \Drupal\file\FileUsage\DatabaseFileUsageBackend::add(). */ function testAddUsage() { $file = $this->createFile(); - file_usage()->add($file, 'testing', 'foo', 1); + $file_usage = $this->container->get('file.usage'); + $file_usage->add($file, 'testing', 'foo', 1); // Add the file twice to ensure that the count is incremented rather than // creating additional records. - file_usage()->add($file, 'testing', 'bar', 2); - file_usage()->add($file, 'testing', 'bar', 2); + $file_usage->add($file, 'testing', 'bar', 2); + $file_usage->add($file, 'testing', 'bar', 2); $usage = db_select('file_usage', 'f') ->fields('f') @@ -78,10 +79,11 @@ function testAddUsage() { } /** - * Tests file_usage()->delete(). + * Tests \Drupal\file\FileUsage\DatabaseFileUsageBackend::delete(). */ function testRemoveUsage() { $file = $this->createFile(); + $file_usage = $this->container->get('file.usage'); db_insert('file_usage') ->fields(array( 'fid' => $file->id(), @@ -93,7 +95,7 @@ function testRemoveUsage() { ->execute(); // Normal decrement. - file_usage()->delete($file, 'testing', 'bar', 2); + $file_usage->delete($file, 'testing', 'bar', 2); $count = db_select('file_usage', 'f') ->fields('f', array('count')) ->condition('f.fid', $file->id()) @@ -102,7 +104,7 @@ function testRemoveUsage() { $this->assertEqual(2, $count, 'The count was decremented correctly.'); // Multiple decrement and removal. - file_usage()->delete($file, 'testing', 'bar', 2, 2); + $file_usage->delete($file, 'testing', 'bar', 2, 2); $count = db_select('file_usage', 'f') ->fields('f', array('count')) ->condition('f.fid', $file->id()) @@ -111,7 +113,7 @@ function testRemoveUsage() { $this->assertIdentical(FALSE, $count, 'The count was removed entirely when empty.'); // Non-existent decrement. - file_usage()->delete($file, 'testing', 'bar', 2); + $file_usage->delete($file, 'testing', 'bar', 2); $count = db_select('file_usage', 'f') ->fields('f', array('count')) ->condition('f.fid', $file->id()) diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 137bf66..4b47592 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -453,12 +453,12 @@ function image_field_entity_update(FieldInterface $field) { if ($file_new) { $file_new->status = FILE_STATUS_PERMANENT; $file_new->save(); - file_usage()->add($file_new, 'image', 'default_image', $field->uuid); + \Drupal::service('file.usage')->add($file_new, 'image', 'default_image', $field->uuid); } // Is there an old file? if ($fid_old && ($file_old = file_load($fid_old[0]))) { - file_usage()->delete($file_old, 'image', 'default_image', $field->uuid); + \Drupal::service('file.usage')->delete($file_old, 'image', 'default_image', $field->uuid); } } @@ -500,11 +500,11 @@ function image_field_instance_update(FieldInstanceInterface $field_instance) { if ($file_new) { $file_new->status = FILE_STATUS_PERMANENT; $file_new->save(); - file_usage()->add($file_new, 'image', 'default_image', $field_instance->uuid); + \Drupal::service('file.usage')->add($file_new, 'image', 'default_image', $field_instance->uuid); } // Delete the old file, if present. if ($fid_old && ($file_old = file_load($fid_old[0]))) { - file_usage()->delete($file_old, 'image', 'default_image', $field_instance->uuid); + \Drupal::service('file.usage')->delete($file_old, 'image', 'default_image', $field_instance->uuid); } } @@ -528,7 +528,7 @@ function image_field_entity_delete(FieldInterface $field) { // The value of a managed_file element can be an array if #extended == TRUE. $fid = (isset($field->settings['default_image']['fids']) ? $field->settings['default_image']['fids'] : $field->settings['default_image']); if ($fid && ($file = file_load($fid[0]))) { - file_usage()->delete($file, 'image', 'default_image', $field->uuid); + \Drupal::service('file.usage')->delete($file, 'image', 'default_image', $field->uuid); } } @@ -551,6 +551,6 @@ function image_field_instance_delete(FieldInstanceInterface $field_instance) { // Remove the default image when the instance is deleted. if ($fid && ($file = file_load($fid))) { - file_usage()->delete($file, 'image', 'default_image', $field_instance->uuid); + \Drupal::service('file.usage')->delete($file, 'image', 'default_image', $field_instance->uuid); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php index c8825af..a6c9033 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php @@ -39,6 +39,7 @@ public function setUp() { */ public function testUserPictureUpgrade() { $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); + $file_usage = $this->container->get('file.usage'); // Retrieve the field instance and check for migrated settings. $instance = field_info_instance('user', 'user_picture', 'user'); @@ -51,7 +52,7 @@ public function testUserPictureUpgrade() { $this->assertFalse(empty($file->uuid->value)); // Check file usage for the default image. - $usage = file_usage()->listUsage($file); + $usage = $file_usage->listUsage($file); $field = field_info_field('user', 'user_picture'); $this->assertTrue(isset($usage['image']['default_image'][$field['uuid']])); @@ -71,7 +72,7 @@ public function testUserPictureUpgrade() { $user = user_load(1); $file = $user->user_picture->entity; $this->assertEqual('public://user_pictures_dir/faked_image.png', $file->getFileUri()); - $usage = file_usage()->listUsage($file); + $usage = $file_usage->listUsage($file); $this->assertEqual(1, $usage['file']['user'][1]); } -- 1.8.3.1