Issue #1981418 by andypost, pcambra, tim.plunkett, dsdeiz, alweb: Drop taxonomy_vocabulary_sort().
parent
462855448a
commit
8c88c03bd4
|
@ -98,7 +98,6 @@ class VocabularyTest extends TaxonomyTestBase {
|
|||
// Load the vocabularies from the database.
|
||||
$this->container->get('entity.manager')->getStorageController('taxonomy_vocabulary')->resetCache();
|
||||
$new_vocabularies = entity_load_multiple('taxonomy_vocabulary');
|
||||
taxonomy_vocabulary_sort($new_vocabularies);
|
||||
|
||||
// Check that the weights are saved in the database correctly.
|
||||
foreach ($vocabularies as $key => $vocabulary) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Definition of Drupal\taxonomy\Tests\VocabularyUnitTest.
|
||||
* Contains \Drupal\taxonomy\Tests\VocabularyUnitTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
@ -119,20 +119,12 @@ class VocabularyUnitTest extends TaxonomyTestBase {
|
|||
$names = taxonomy_vocabulary_get_names();
|
||||
$this->assertEqual($names[$vocabulary1->id()], $vocabulary1->id(), 'Vocabulary 1 name found.');
|
||||
|
||||
// Fetch all of the vocabularies using entity_load_multiple().
|
||||
// Confirm that the vocabularies are ordered by weight.
|
||||
$vocabularies = entity_load_multiple('taxonomy_vocabulary');
|
||||
taxonomy_vocabulary_sort($vocabularies);
|
||||
$this->assertEqual(array_shift($vocabularies)->id(), $vocabulary1->id(), 'Vocabulary was found in the vocabularies array.');
|
||||
$this->assertEqual(array_shift($vocabularies)->id(), $vocabulary2->id(), 'Vocabulary was found in the vocabularies array.');
|
||||
$this->assertEqual(array_shift($vocabularies)->id(), $vocabulary3->id(), 'Vocabulary was found in the vocabularies array.');
|
||||
|
||||
// Fetch the vocabularies with entity_load_multiple(), specifying IDs.
|
||||
// Ensure they are returned in the same order as the original array.
|
||||
$vocabularies = entity_load_multiple('taxonomy_vocabulary', array($vocabulary3->id(), $vocabulary2->id(), $vocabulary1->id()));
|
||||
$this->assertEqual(array_shift($vocabularies)->id(), $vocabulary3->id(), 'Vocabulary loaded successfully by ID.');
|
||||
$this->assertEqual(array_shift($vocabularies)->id(), $vocabulary2->id(), 'Vocabulary loaded successfully by ID.');
|
||||
$this->assertEqual(array_shift($vocabularies)->id(), $vocabulary1->id(), 'Vocabulary loaded successfully by ID.');
|
||||
$loaded_order = array_keys($vocabularies);
|
||||
$expected_order = array($vocabulary3->id(), $vocabulary2->id(), $vocabulary1->id());
|
||||
$this->assertIdentical($loaded_order, $expected_order);
|
||||
|
||||
// Test loading vocabularies by their properties.
|
||||
$controller = $this->container->get('entity.manager')->getStorageController('taxonomy_vocabulary');
|
||||
|
|
|
@ -722,18 +722,6 @@ function taxonomy_vocabulary_load_multiple(array $vids = NULL) {
|
|||
return entity_load_multiple('taxonomy_vocabulary', $vids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts vocabularies by its weight and label.
|
||||
*
|
||||
* @param array $vocabularies
|
||||
* An array of \Drupal\taxonomy\Entity\Vocabulary objects.
|
||||
*/
|
||||
function taxonomy_vocabulary_sort(array &$vocabularies = array()) {
|
||||
// @todo Remove error suppressing when http://drupal.org/node/1799600 is
|
||||
// fixed.
|
||||
@uasort($vocabularies, 'Drupal\Core\Config\Entity\ConfigEntityBase::sort');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the taxonomy vocabulary entity matching a vocabulary ID.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue