Example #1
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");
     }
 }
 /**
  * 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");
         }
     }
 }
 /**
  * Test for the fetch method
  *
  * Outline:
  * 1. Create a wildcard object
  * 2. Fetch this object
  * 3. Compare the values from the fetched object with the creation data
  **/
 public function testFetch()
 {
     // 1. Create a wildcard object
     $wildcard = self::createWildcard($sourceURL = 'testFetch/*', $destinationURL = '/', $type = eZURLWildcard::TYPE_DIRECT);
     $id = $wildcard->attribute('id');
     unset($wildcard);
     // 2. Fetch the created object by its ID
     $fetchedWildcard = eZURLWildcard::fetch($id);
     // 3. Test the data
     $this->assertTrue(is_object($fetchedWildcard), "Failed fetching the wildcard object by ID");
     $this->assertEquals($sourceURL, $fetchedWildcard->attribute('source_url'));
     $this->assertEquals($destinationURL, $fetchedWildcard->attribute('destination_url'));
     $this->assertEquals($type, $fetchedWildcard->attribute('type'));
     $this->assertEquals($id, $fetchedWildcard->attribute('id'));
 }