/** * Tests the fetchList method * * Outline: * 1. Fetch the list * 2. Check that all returned wildcards are part of this list * * @todo Also test fetchList with an offset/limit */ public function testFetchList() { // 1. Fetch the list $fetchedWildcards = eZURLWildcard::fetchList(); // 2. Check if every fetched wildcard is in the creation list, and the opposite $this->assertSame(count($this->wildcardObjects), count($fetchedWildcards), "Mismatch between created and fetched wildcards count"); foreach ($fetchedWildcards as $fetchedWildcard) { $wildcard = $this->wildcardObjects[$fetchedWildcard->attribute('source_url')]; $this->assertEquals($wildcard->attribute('source_url'), $fetchedWildcard->attribute('source_url')); $this->assertEquals($wildcard->attribute('destination_url'), $fetchedWildcard->attribute('destination_url')); $this->assertEquals($wildcard->attribute('type'), $fetchedWildcard->attribute('type')); $this->assertEquals($wildcard->attribute('id'), $fetchedWildcard->attribute('id')); } }
$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); $tpl->setVariable('wildcardType', $wildcardType); $tpl->setVariable('limitList', $limitList); $tpl->setVariable('limitID', $limitID); $tpl->setVariable('view_parameters', $viewParameters); $Result = array();
/** * Tests the removeAll method * * Outline: * 1. Create a set of wildcards * 2. Call removeall * 3. Check if all these wildcards were removed * * @depends testStore * @depends testFetchList **/ public function testRemoveAll() { // 1. Create a set of wildcards for ($i = 0; $i < 10; $i++) { self::createWildcard("testRemoveAll/{$i}/*", '/', eZURLWildcard::TYPE_DIRECT); } // 2. Call removeAll eZURLWildcard::removeAll(); // 3. Check if all wildcards are indeed gone $wildcards = eZURLWildcard::fetchList(); $this->assertTrue(count($wildcards) == 0, count($wildcards) . " wildcards still exist in the database"); }