/**
  * Test case teardown
  */
 public function tearDown()
 {
     eZURLWildcard::removeByIDs(array($this->wildcard->attribute('id')));
     eZURLWildcard::expireCache();
     clearstatcache();
     sleep(1);
     parent::tearDown();
 }
$infoCode = 'no-errors';
// This will be modified if info/warning is given to user.
$infoData = array();
// Extra parameters can be added to this array
$wildcardSrcText = false;
$wildcardDstText = false;
$wildcardType = false;
if ($Module->isCurrentAction('RemoveAllWildcards')) {
    eZURLWildcard::removeAll();
    eZURLWildcard::expireCache();
    $infoCode = "feedback-wildcard-removed-all";
} else {
    if ($Module->isCurrentAction('RemoveWildcard')) {
        if ($http->hasPostVariable('WildcardIDList')) {
            $wildcardIDs = $http->postVariable('WildcardIDList');
            eZURLWildcard::removeByIDs($wildcardIDs);
            eZURLWildcard::expireCache();
            $infoCode = "feedback-wildcard-removed";
        }
    } else {
        if ($Module->isCurrentAction('NewWildcard')) {
            $wildcardSrcText = trim($Module->actionParameter('WildcardSourceText'));
            $wildcardDstText = trim($Module->actionParameter('WildcardDestinationText'));
            $wildcardType = $http->hasPostVariable('WildcardType') && strlen(trim($http->postVariable('WildcardType'))) > 0;
            if (strlen($wildcardSrcText) == 0) {
                $infoCode = "error-no-wildcard-text";
            } else {
                if (strlen($wildcardDstText) == 0) {
                    $infoCode = "error-no-wildcard-destination-text";
                } else {
                    $wildcard = eZURLWildcard::fetchBySourceURL($wildcardSrcText, false);
 /**
  * Tests the removeByIDs method
  *
  * @depends testFetch
  */
 public function testRemoveByIDs()
 {
     // Removing odd wildcards
     for ($i = 0; $i < $this->generatedWildcards; ++$i) {
         if ($i % 2) {
             $wildcardsToRemove[] = $this->wildcardObjects["testOdd/{$i}/*"]->attribute('id');
         }
     }
     eZURLWildcard::removeByIDs($wildcardsToRemove);
     // Check if the removed wildcards were removed, and the kept ones were kept
     for ($i = 0; $i < $this->generatedWildcards; ++$i) {
         if ($i % 2) {
             $this->assertNull(eZURLWildcard::fetch($this->wildcardObjects["testOdd/{$i}/*"]->attribute('id')), "A removed wildcard entry still exists");
         } else {
             $this->assertTrue(is_object(eZURLWildcard::fetch($this->wildcardObjects["testPair/{$i}/*"]->attribute('id'))), "A kept wildcard entry no longer exists");
         }
     }
 }
Пример #4
0
 /**
  * Tests the removeByIDs method
  *
  * Outline:
  * 1. Create a set of wildcards
  * 2. Call removeByIDs with a part of this list
  * 3. Check each item of the list, and check if the removed ones were removed
  *
  * @depends testStore
  * @depends testFetch
  **/
 public function testRemoveByIDs()
 {
     self::removeAllWildcards();
     // 1. Create a set of wildcards
     for ($i = 0; $i < 20; $i++) {
         $wildcard = self::createWildcard("testRemoveByIDs/{$i}/*", '/', eZURLWildcard::TYPE_DIRECT);
         if ($i % 2 == 0) {
             $wildcardsToRemove[$wildcard->attribute('id')] = $wildcard;
         } else {
             $wildcardsToKeep[$wildcard->attribute('id')] = $wildcard;
         }
     }
     // 2. call removeByIDs
     eZURLWildcard::removeByIDs(array_keys($wildcardsToRemove));
     // 3. Check if the removed wildcards were removed, and the kept ones were kept
     foreach (array_keys($wildcardsToRemove) as $wildcardID) {
         $this->assertNull(eZURLWildcard::fetch($wildcardID), "A removed wildcard entry still exists");
     }
     foreach (array_keys($wildcardsToKeep) as $wildcardID) {
         $this->assertTrue(is_object(eZURLWildcard::fetch($wildcardID)), "A kept wildcard entry no longer exists");
     }
 }