/** * Tests the removeAll method * * @depends testFetchListCount */ public function testRemoveAll() { eZURLWildcard::removeAll(); $this->assertEquals(0, $count = eZURLWildcard::fetchListCount(), $count . " wildcards still exist in the database"); }
} } } // User preferences $limitList = array(array('id' => 1, 'value' => 10), array('id' => 2, 'value' => 25), array('id' => 3, 'value' => 50), array('id' => 4, 'value' => 100)); $limitID = eZPreferences::value('admin_urlwildcard_list_limit'); foreach ($limitList as $limitEntry) { $limitIDs[] = $limitEntry['id']; $limitValues[$limitEntry['id']] = $limitEntry['value']; } if (!in_array($limitID, $limitIDs)) { $limitID = 2; } // Fetch wildcads $wildcardsLimit = $limitValues[$limitID]; $wildcardsCount = eZURLWildcard::fetchListCount(); // check offset, it can be out of range if some wildcards were removed. if ($Offset >= $wildcardsCount) { $Offset = 0; } $wildcardList = eZURLWildcard::fetchList($Offset, $wildcardsLimit); $viewParameters = array('offset' => $Offset); $path = array(); $path[] = array('url' => false, 'text' => ezpI18n::tr('kernel/content/urlalias_wildcard', 'URL wildcard aliases')); $tpl->setVariable('wildcard_list', $wildcardList); $tpl->setVariable('wildcards_limit', $wildcardsLimit); $tpl->setVariable('wildcards_count', $wildcardsCount); $tpl->setVariable('info_code', $infoCode); $tpl->setVariable('info_data', $infoData); $tpl->setVariable('wildcardSourceText', $wildcardSrcText); $tpl->setVariable('wildcardDestinationText', $wildcardDstText);
/** * Tests the fetchListCount method * * Outline: * 1. Remove all existing wildcards * 2. Create a known number of wildcards * 3. Check if fetchListCount matches the number of created wildcards **/ public function testFetchListCount() { // 1. Remove all existing wildcards self::removeAllWildcards(); // 2. Create a known number of wildcards for ($i = 0, $wildcardsCount = 20; $i < $wildcardsCount; $i++) { self::createWildcard("testFetchListCount/{$i}/*", '/', eZURLWildcard::TYPE_DIRECT); } // 3. Check if fetchListCount matches the number of created wildcards $this->assertEquals($wildcardsCount, eZURLWildcard::fetchListCount(), "The return value from fetchListCount doesn't match the number of created wildcards"); }