public function TaxonomyMenuWebTestCase::assertEqualNumberTermsMenuLinks in Taxonomy menu 7.2
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 tests/
taxonomy_menu.test - Tests CRUD functions.
- TaxonomyMenuUnitTest::testTaxonomyMenuCustomMenu in tests/
taxonomy_menu.test - Tests creation of menu links in a custom menu.
File
- tests/
taxonomy_menu.test, line 33 - Defines abstract base test class for the Taxonomy menu module tests.
Class
- TaxonomyMenuWebTestCase
- Abstract class for Taxonomy menu testing. All Taxonomy menu tests should extend this class.
Code
public function assertEqualNumberTermsMenuLinks($terms_count, $vocabulary, $menu_name) {
$vid = $vocabulary->vid;
// 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
->execute()
->rowCount();
$message = $query_count . ' menu links were found for the ' . $terms_count . ' taxonomy terms of vocabulary ' . $vocabulary->name . '.';
$this
->assertEqual($terms_count, $query_count, $message);
}