public function TaxonomyMenuWebTestCase::assertEqualNumberTermsMenuLinks in Taxonomy menu 8
Asserts that the number of menu links is equal to the number of taxonomy terms for a given menu name.
Parameters
$terms: The terms, which are created in this class.
2 calls to TaxonomyMenuWebTestCase::assertEqualNumberTermsMenuLinks()
- TaxonomyMenuUnitTest::testTaxonomyMenuCRUD in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuUnitTest.php - Tests CRUD functions.
- TaxonomyMenuUnitTest::testTaxonomyMenuCustomMenu in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuUnitTest.php - Tests creation of menu links in a custom menu.
File
- lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuWebTestCase.php, line 43 - Definition of Drupal\taxonomy_menu\Tests\TaxonomyMenuWebTestCase.
Class
- TaxonomyMenuWebTestCase
- Abstract class for Taxonomy menu testing. All Taxonomy menu tests should extend this class.
Namespace
Drupal\taxonomy_menu\TestsCode
public function assertEqualNumberTermsMenuLinks($terms_count, $vocabulary, $menu_name) {
$vid = $vocabulary
->id();
// Building a query getting the number of menu links for this vocabulary.
$query = db_select('menu_links', 'ml')
->fields('ml')
->condition('ml.module', 'taxonomy_menu')
->condition('ml.menu_name', $menu_name);
$query
->join('taxonomy_menu', 'tm', 'ml.mlid = tm.mlid');
$query
->condition('tm.vid', $vid, '=');
$query_count = $query
->countQuery()
->execute()
->fetchField();
$message = $query_count . ' menu links were found for the ' . $terms_count . ' taxonomy terms of vocabulary ' . $vocabulary->name . '.';
$this
->assertEqual($terms_count, $query_count, $message);
}