3 namespace Drupal\taxonomy\Tests;
5 use Drupal\Component\Utility\Tags;
6 use Drupal\Component\Utility\Unicode;
7 use Drupal\Core\Field\FieldStorageDefinitionInterface;
8 use Drupal\field\Entity\FieldConfig;
9 use Drupal\taxonomy\Entity\Term;
10 use Drupal\taxonomy\Entity\Vocabulary;
13 * Tests load, save and delete for taxonomy terms.
17 class TermTest extends TaxonomyTestBase {
20 * Vocabulary for testing.
22 * @var \Drupal\taxonomy\VocabularyInterface
24 protected $vocabulary;
27 * Taxonomy term reference field for testing.
29 * @var \Drupal\field\FieldConfigInterface
38 public static $modules = ['block'];
43 protected function setUp() {
46 $this->drupalPlaceBlock('local_actions_block');
47 $this->drupalPlaceBlock('local_tasks_block');
48 $this->drupalPlaceBlock('page_title_block');
50 $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access']));
51 $this->vocabulary = $this->createVocabulary();
53 $field_name = 'taxonomy_' . $this->vocabulary->id();
57 $this->vocabulary->id() => $this->vocabulary->id(),
59 'auto_create' => TRUE,
61 $this->createEntityReferenceField('node', 'article', $field_name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
62 $this->field = FieldConfig::loadByName('node', 'article', $field_name);
64 entity_get_form_display('node', 'article', 'default')
65 ->setComponent($field_name, [
66 'type' => 'options_select',
69 entity_get_display('node', 'article', 'default')
70 ->setComponent($field_name, [
71 'type' => 'entity_reference_label',
77 * Test terms in a single and multiple hierarchy.
79 public function testTaxonomyTermHierarchy() {
80 // Create two taxonomy terms.
81 $term1 = $this->createTerm($this->vocabulary);
82 $term2 = $this->createTerm($this->vocabulary);
84 // Get the taxonomy storage.
85 $taxonomy_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
87 // Check that hierarchy is flat.
88 $vocabulary = Vocabulary::load($this->vocabulary->id());
89 $this->assertEqual(0, $vocabulary->getHierarchy(), 'Vocabulary is flat.');
91 // Edit $term2, setting $term1 as parent.
93 $edit['parent[]'] = [$term1->id()];
94 $this->drupalPostForm('taxonomy/term/' . $term2->id() . '/edit', $edit, t('Save'));
96 // Check the hierarchy.
97 $children = $taxonomy_storage->loadChildren($term1->id());
98 $parents = $taxonomy_storage->loadParents($term2->id());
99 $this->assertTrue(isset($children[$term2->id()]), 'Child found correctly.');
100 $this->assertTrue(isset($parents[$term1->id()]), 'Parent found correctly.');
102 // Load and save a term, confirming that parents are still set.
103 $term = Term::load($term2->id());
105 $parents = $taxonomy_storage->loadParents($term2->id());
106 $this->assertTrue(isset($parents[$term1->id()]), 'Parent found correctly.');
108 // Create a third term and save this as a parent of term2.
109 $term3 = $this->createTerm($this->vocabulary);
110 $term2->parent = [$term1->id(), $term3->id()];
112 $parents = $taxonomy_storage->loadParents($term2->id());
113 $this->assertTrue(isset($parents[$term1->id()]) && isset($parents[$term3->id()]), 'Both parents found successfully.');
117 * Tests that many terms with parents show on each page
119 public function testTaxonomyTermChildTerms() {
120 // Set limit to 10 terms per page. Set variable to 9 so 10 terms appear.
121 $this->config('taxonomy.settings')->set('terms_per_page_admin', '9')->save();
122 $term1 = $this->createTerm($this->vocabulary);
125 $taxonomy_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
127 // Create 40 terms. Terms 1-12 get parent of $term1. All others are
129 for ($x = 1; $x <= 40; $x++) {
131 // Set terms in order so we know which terms will be on which pages.
132 $edit['weight'] = $x;
134 // Set terms 1-20 to be children of first term created.
136 $edit['parent'] = $term1->id();
138 $term = $this->createTerm($this->vocabulary, $edit);
139 $children = $taxonomy_storage->loadChildren($term1->id());
140 $parents = $taxonomy_storage->loadParents($term->id());
141 $terms_array[$x] = Term::load($term->id());
145 $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
146 $this->assertText($term1->getName(), 'Parent Term is displayed on Page 1');
147 for ($x = 1; $x <= 13; $x++) {
148 $this->assertText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' found on Page 1');
152 $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 1]]);
153 $this->assertText($term1->getName(), 'Parent Term is displayed on Page 2');
154 for ($x = 1; $x <= 18; $x++) {
155 $this->assertText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' found on Page 2');
159 $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 2]]);
160 $this->assertNoText($term1->getName(), 'Parent Term is not displayed on Page 3');
161 for ($x = 1; $x <= 17; $x++) {
162 $this->assertNoText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' not found on Page 3');
164 for ($x = 18; $x <= 25; $x++) {
165 $this->assertText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' found on Page 3');
170 * Test that hook_node_$op implementations work correctly.
172 * Save & edit a node and assert that taxonomy terms are saved/loaded properly.
174 public function testTaxonomyNode() {
175 // Create two taxonomy terms.
176 $term1 = $this->createTerm($this->vocabulary);
177 $term2 = $this->createTerm($this->vocabulary);
181 $edit['title[0][value]'] = $this->randomMachineName();
182 $edit['body[0][value]'] = $this->randomMachineName();
183 $edit[$this->field->getName() . '[]'] = $term1->id();
184 $this->drupalPostForm('node/add/article', $edit, t('Save'));
186 // Check that the term is displayed when the node is viewed.
187 $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
188 $this->drupalGet('node/' . $node->id());
189 $this->assertText($term1->getName(), 'Term is displayed when viewing the node.');
191 $this->clickLink(t('Edit'));
192 $this->assertText($term1->getName(), 'Term is displayed when editing the node.');
193 $this->drupalPostForm(NULL, [], t('Save'));
194 $this->assertText($term1->getName(), 'Term is displayed after saving the node with no changes.');
196 // Edit the node with a different term.
197 $edit[$this->field->getName() . '[]'] = $term2->id();
198 $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
200 $this->drupalGet('node/' . $node->id());
201 $this->assertText($term2->getName(), 'Term is displayed when viewing the node.');
204 $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Preview'));
205 $this->assertUniqueText($term2->getName(), 'Term is displayed when previewing the node.');
206 $this->drupalPostForm('node/' . $node->id() . '/edit', NULL, t('Preview'));
207 $this->assertUniqueText($term2->getName(), 'Term is displayed when previewing the node again.');
211 * Test term creation with a free-tagging vocabulary from the node form.
213 public function testNodeTermCreationAndDeletion() {
214 // Enable tags in the vocabulary.
215 $field = $this->field;
216 entity_get_form_display($field->getTargetEntityTypeId(), $field->getTargetBundle(), 'default')
217 ->setComponent($field->getName(), [
218 'type' => 'entity_reference_autocomplete_tags',
220 'placeholder' => 'Start typing here.',
224 // Prefix the terms with a letter to ensure there is no clash in the first
226 // @see https://www.drupal.org/node/2397691
228 'term1' => 'a' . $this->randomMachineName(),
229 'term2' => 'b' . $this->randomMachineName(),
230 'term3' => 'c' . $this->randomMachineName() . ', ' . $this->randomMachineName(),
231 'term4' => 'd' . $this->randomMachineName(),
235 $edit['title[0][value]'] = $this->randomMachineName();
236 $edit['body[0][value]'] = $this->randomMachineName();
237 // Insert the terms in a comma separated list. Vocabulary 1 is a
238 // free-tagging field created by the default profile.
239 $edit[$field->getName() . '[target_id]'] = Tags::implode($terms);
241 // Verify the placeholder is there.
242 $this->drupalGet('node/add/article');
243 $this->assertRaw('placeholder="Start typing here."', 'Placeholder is present.');
245 // Preview and verify the terms appear but are not created.
246 $this->drupalPostForm(NULL, $edit, t('Preview'));
247 foreach ($terms as $term) {
248 $this->assertText($term, 'The term appears on the node preview.');
250 $tree = $this->container->get('entity.manager')->getStorage('taxonomy_term')->loadTree($this->vocabulary->id());
251 $this->assertTrue(empty($tree), 'The terms are not created on preview.');
253 // taxonomy.module does not maintain its static caches.
254 taxonomy_terms_static_reset();
256 // Save, creating the terms.
257 $this->drupalPostForm('node/add/article', $edit, t('Save'));
258 $this->assertText(t('@type @title has been created.', ['@type' => t('Article'), '@title' => $edit['title[0][value]']]), 'The node was created successfully.');
260 // Verify that the creation message contains a link to a node.
261 $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'node/']);
262 $this->assert(isset($view_link), 'The message area contains a link to a node');
264 foreach ($terms as $term) {
265 $this->assertText($term, 'The term was saved and appears on the node page.');
268 // Get the created terms.
270 foreach ($terms as $key => $term) {
271 $term_objects[$key] = taxonomy_term_load_multiple_by_name($term);
272 $term_objects[$key] = reset($term_objects[$key]);
276 $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
278 // Test editing the node.
279 $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
280 foreach ($terms as $term) {
281 $this->assertText($term, 'The term was retained after edit and still appears on the node page.');
284 // Delete term 1 from the term edit page.
285 $this->drupalGet('taxonomy/term/' . $term_objects['term1']->id() . '/edit');
286 $this->clickLink(t('Delete'));
287 $this->drupalPostForm(NULL, NULL, t('Delete'));
289 // Delete term 2 from the term delete page.
290 $this->drupalGet('taxonomy/term/' . $term_objects['term2']->id() . '/delete');
291 $this->drupalPostForm(NULL, [], t('Delete'));
292 $term_names = [$term_objects['term3']->getName(), $term_objects['term4']->getName()];
294 $this->drupalGet('node/' . $node->id());
296 foreach ($term_names as $term_name) {
297 $this->assertText($term_name, format_string('The term %name appears on the node page after two terms, %deleted1 and %deleted2, were deleted.', ['%name' => $term_name, '%deleted1' => $term_objects['term1']->getName(), '%deleted2' => $term_objects['term2']->getName()]));
299 $this->assertNoText($term_objects['term1']->getName(), format_string('The deleted term %name does not appear on the node page.', ['%name' => $term_objects['term1']->getName()]));
300 $this->assertNoText($term_objects['term2']->getName(), format_string('The deleted term %name does not appear on the node page.', ['%name' => $term_objects['term2']->getName()]));
304 * Save, edit and delete a term using the user interface.
306 public function testTermInterface() {
307 \Drupal::service('module_installer')->install(['views']);
309 'name[0][value]' => $this->randomMachineName(12),
310 'description[0][value]' => $this->randomMachineName(100),
312 // Explicitly set the parents field to 'root', to ensure that
313 // TermForm::save() handles the invalid term ID correctly.
314 $edit['parent[]'] = [0];
316 // Create the term to edit.
317 $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
319 $terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
320 $term = reset($terms);
321 $this->assertNotNull($term, 'Term found in database.');
323 // Submitting a term takes us to the add page; we need the List page.
324 $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
326 $this->clickLink(t('Edit'));
328 $this->assertRaw($edit['name[0][value]'], 'The randomly generated term name is present.');
329 $this->assertText($edit['description[0][value]'], 'The randomly generated term description is present.');
332 'name[0][value]' => $this->randomMachineName(14),
333 'description[0][value]' => $this->randomMachineName(102),
337 $this->drupalPostForm('taxonomy/term/' . $term->id() . '/edit', $edit, t('Save'));
339 // Check that the term is still present at admin UI after edit.
340 $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
341 $this->assertText($edit['name[0][value]'], 'The randomly generated term name is present.');
342 $this->assertLink(t('Edit'));
344 // Check the term link can be clicked through to the term page.
345 $this->clickLink($edit['name[0][value]']);
346 $this->assertResponse(200, 'Term page can be accessed via the listing link.');
348 // View the term and check that it is correct.
349 $this->drupalGet('taxonomy/term/' . $term->id());
350 $this->assertText($edit['name[0][value]'], 'The randomly generated term name is present.');
351 $this->assertText($edit['description[0][value]'], 'The randomly generated term description is present.');
353 // Did this page request display a 'term-listing-heading'?
354 $this->assertTrue($this->xpath('//div[contains(@class, "field--name-description")]'), 'Term page displayed the term description element.');
355 // Check that it does NOT show a description when description is blank.
356 $term->setDescription(NULL);
358 $this->drupalGet('taxonomy/term/' . $term->id());
359 $this->assertFalse($this->xpath('//div[contains(@class, "field--entity-taxonomy-term--description")]'), 'Term page did not display the term description when description was blank.');
361 // Check that the description value is processed.
362 $value = $this->randomMachineName();
363 $term->setDescription($value);
365 $this->assertEqual($term->description->processed, "<p>$value</p>\n");
367 // Check that the term feed page is working.
368 $this->drupalGet('taxonomy/term/' . $term->id() . '/feed');
371 $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
372 $this->clickLink(t('Delete'));
373 $this->drupalPostForm(NULL, NULL, t('Delete'));
375 // Assert that the term no longer exists.
376 $this->drupalGet('taxonomy/term/' . $term->id());
377 $this->assertResponse(404, 'The taxonomy term page was not found.');
381 * Save, edit and delete a term using the user interface.
383 public function testTermReorder() {
384 $this->createTerm($this->vocabulary);
385 $this->createTerm($this->vocabulary);
386 $this->createTerm($this->vocabulary);
388 $taxonomy_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
390 // Fetch the created terms in the default alphabetical order, i.e. term1
391 // precedes term2 alphabetically, and term2 precedes term3.
392 $taxonomy_storage->resetCache();
393 list($term1, $term2, $term3) = $taxonomy_storage->loadTree($this->vocabulary->id(), 0, NULL, TRUE);
395 $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
397 // Each term has four hidden fields, "tid:1:0[tid]", "tid:1:0[parent]",
398 // "tid:1:0[depth]", and "tid:1:0[weight]". Change the order to term2,
399 // term3, term1 by setting weight property, make term3 a child of term2 by
400 // setting the parent and depth properties, and update all hidden fields.
402 'terms[tid:' . $term2->id() . ':0][term][tid]' => $term2->id(),
403 'terms[tid:' . $term2->id() . ':0][term][parent]' => 0,
404 'terms[tid:' . $term2->id() . ':0][term][depth]' => 0,
405 'terms[tid:' . $term2->id() . ':0][weight]' => 0,
406 'terms[tid:' . $term3->id() . ':0][term][tid]' => $term3->id(),
407 'terms[tid:' . $term3->id() . ':0][term][parent]' => $term2->id(),
408 'terms[tid:' . $term3->id() . ':0][term][depth]' => 1,
409 'terms[tid:' . $term3->id() . ':0][weight]' => 1,
410 'terms[tid:' . $term1->id() . ':0][term][tid]' => $term1->id(),
411 'terms[tid:' . $term1->id() . ':0][term][parent]' => 0,
412 'terms[tid:' . $term1->id() . ':0][term][depth]' => 0,
413 'terms[tid:' . $term1->id() . ':0][weight]' => 2,
415 $this->drupalPostForm(NULL, $edit, t('Save'));
417 $taxonomy_storage->resetCache();
418 $terms = $taxonomy_storage->loadTree($this->vocabulary->id());
419 $this->assertEqual($terms[0]->tid, $term2->id(), 'Term 2 was moved above term 1.');
420 $this->assertEqual($terms[1]->parents, [$term2->id()], 'Term 3 was made a child of term 2.');
421 $this->assertEqual($terms[2]->tid, $term1->id(), 'Term 1 was moved below term 2.');
423 $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', [], t('Reset to alphabetical'));
424 // Submit confirmation form.
425 $this->drupalPostForm(NULL, [], t('Reset to alphabetical'));
426 // Ensure form redirected back to overview.
427 $this->assertUrl('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
429 $taxonomy_storage->resetCache();
430 $terms = $taxonomy_storage->loadTree($this->vocabulary->id(), 0, NULL, TRUE);
431 $this->assertEqual($terms[0]->id(), $term1->id(), 'Term 1 was moved to back above term 2.');
432 $this->assertEqual($terms[1]->id(), $term2->id(), 'Term 2 was moved to back below term 1.');
433 $this->assertEqual($terms[2]->id(), $term3->id(), 'Term 3 is still below term 2.');
434 $this->assertEqual($terms[2]->parents, [$term2->id()], 'Term 3 is still a child of term 2.');
438 * Test saving a term with multiple parents through the UI.
440 public function testTermMultipleParentsInterface() {
441 // Add a new term to the vocabulary so that we can have multiple parents.
442 $parent = $this->createTerm($this->vocabulary);
444 // Add a new term with multiple parents.
446 'name[0][value]' => $this->randomMachineName(12),
447 'description[0][value]' => $this->randomMachineName(100),
448 'parent[]' => [0, $parent->id()],
450 // Save the new term.
451 $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
453 // Check that the term was successfully created.
454 $terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
455 $term = reset($terms);
456 $this->assertNotNull($term, 'Term found in database.');
457 $this->assertEqual($edit['name[0][value]'], $term->getName(), 'Term name was successfully saved.');
458 $this->assertEqual($edit['description[0][value]'], $term->getDescription(), 'Term description was successfully saved.');
459 // Check that the parent tid is still there. The other parent (<root>) is
460 // not added by \Drupal\taxonomy\TermStorageInterface::loadParents().
461 $parents = $this->container->get('entity.manager')->getStorage('taxonomy_term')->loadParents($term->id());
462 $parent = reset($parents);
463 $this->assertEqual($edit['parent[]'][1], $parent->id(), 'Term parents were successfully saved.');
467 * Test taxonomy_term_load_multiple_by_name().
469 public function testTaxonomyGetTermByName() {
470 $term = $this->createTerm($this->vocabulary);
472 // Load the term with the exact name.
473 $terms = taxonomy_term_load_multiple_by_name($term->getName());
474 $this->assertTrue(isset($terms[$term->id()]), 'Term loaded using exact name.');
476 // Load the term with space concatenated.
477 $terms = taxonomy_term_load_multiple_by_name(' ' . $term->getName() . ' ');
478 $this->assertTrue(isset($terms[$term->id()]), 'Term loaded with extra whitespace.');
480 // Load the term with name uppercased.
481 $terms = taxonomy_term_load_multiple_by_name(strtoupper($term->getName()));
482 $this->assertTrue(isset($terms[$term->id()]), 'Term loaded with uppercased name.');
484 // Load the term with name lowercased.
485 $terms = taxonomy_term_load_multiple_by_name(strtolower($term->getName()));
486 $this->assertTrue(isset($terms[$term->id()]), 'Term loaded with lowercased name.');
488 // Try to load an invalid term name.
489 $terms = taxonomy_term_load_multiple_by_name('Banana');
490 $this->assertFalse($terms, 'No term loaded with an invalid name.');
492 // Try to load the term using a substring of the name.
493 $terms = taxonomy_term_load_multiple_by_name(Unicode::substr($term->getName(), 2), 'No term loaded with a substring of the name.');
494 $this->assertFalse($terms);
496 // Create a new term in a different vocabulary with the same name.
497 $new_vocabulary = $this->createVocabulary();
498 $new_term = Term::create([
499 'name' => $term->getName(),
500 'vid' => $new_vocabulary->id(),
504 // Load multiple terms with the same name.
505 $terms = taxonomy_term_load_multiple_by_name($term->getName());
506 $this->assertEqual(count($terms), 2, 'Two terms loaded with the same name.');
508 // Load single term when restricted to one vocabulary.
509 $terms = taxonomy_term_load_multiple_by_name($term->getName(), $this->vocabulary->id());
510 $this->assertEqual(count($terms), 1, 'One term loaded when restricted by vocabulary.');
511 $this->assertTrue(isset($terms[$term->id()]), 'Term loaded using exact name and vocabulary machine name.');
513 // Create a new term with another name.
514 $term2 = $this->createTerm($this->vocabulary);
516 // Try to load a term by name that doesn't exist in this vocabulary but
517 // exists in another vocabulary.
518 $terms = taxonomy_term_load_multiple_by_name($term2->getName(), $new_vocabulary->id());
519 $this->assertFalse($terms, 'Invalid term name restricted by vocabulary machine name not loaded.');
521 // Try to load terms filtering by a non-existing vocabulary.
522 $terms = taxonomy_term_load_multiple_by_name($term2->getName(), 'non_existing_vocabulary');
523 $this->assertEqual(count($terms), 0, 'No terms loaded when restricted by a non-existing vocabulary.');
527 * Tests that editing and saving a node with no changes works correctly.
529 public function testReSavingTags() {
530 // Enable tags in the vocabulary.
531 $field = $this->field;
532 entity_get_form_display($field->getTargetEntityTypeId(), $field->getTargetBundle(), 'default')
533 ->setComponent($field->getName(), [
534 'type' => 'entity_reference_autocomplete_tags',
538 // Create a term and a node using it.
539 $term = $this->createTerm($this->vocabulary);
541 $edit['title[0][value]'] = $this->randomMachineName(8);
542 $edit['body[0][value]'] = $this->randomMachineName(16);
543 $edit[$this->field->getName() . '[target_id]'] = $term->getName();
544 $this->drupalPostForm('node/add/article', $edit, t('Save'));
546 // Check that the term is displayed when editing and saving the node with no
548 $this->clickLink(t('Edit'));
549 $this->assertRaw($term->getName(), 'Term is displayed when editing the node.');
550 $this->drupalPostForm(NULL, [], t('Save'));
551 $this->assertRaw($term->getName(), 'Term is displayed after saving the node with no changes.');
555 * Check the breadcrumb on edit and delete a term page.
557 public function testTermBreadcrumbs() {
559 'name[0][value]' => $this->randomMachineName(14),
560 'description[0][value]' => $this->randomMachineName(100),
565 $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
567 $terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
568 $term = reset($terms);
569 $this->assertNotNull($term, 'Term found in database.');
571 // Check the breadcrumb on the term edit page.
572 $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
573 $breadcrumbs = $this->cssSelect('nav.breadcrumb ol li a');
574 $this->assertIdentical(count($breadcrumbs), 2, 'The breadcrumbs are present on the page.');
575 $this->assertIdentical((string) $breadcrumbs[0], 'Home', 'First breadcrumb text is Home');
576 $this->assertIdentical((string) $breadcrumbs[1], $term->label(), 'Second breadcrumb text is term name on term edit page.');
577 $this->assertEscaped((string) $breadcrumbs[1], 'breadcrumbs displayed and escaped.');
579 // Check the breadcrumb on the term delete page.
580 $this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
581 $breadcrumbs = $this->cssSelect('nav.breadcrumb ol li a');
582 $this->assertIdentical(count($breadcrumbs), 2, 'The breadcrumbs are present on the page.');
583 $this->assertIdentical((string) $breadcrumbs[0], 'Home', 'First breadcrumb text is Home');
584 $this->assertIdentical((string) $breadcrumbs[1], $term->label(), 'Second breadcrumb text is term name on term delete page.');
585 $this->assertEscaped((string) $breadcrumbs[1], 'breadcrumbs displayed and escaped.');