/**
  * Test the descending recursive search on a directory tree
  * with a three level structure.
  *
  * @return void
  */
 public function testThreeLevelDescendingRecursiveSearch()
 {
     // create the three level tree
     $level1 = $this->namingDirectory->createSubdirectory('level1');
     $level2 = $level1->createSubdirectory('level2');
     $level3 = $level2->createSubdirectory('level3');
     // bind a value and search recursive
     $this->namingDirectory->bind($name = 'php:level1/level2/level3/test', $value = 'testValue');
     $this->assertSame($this->namingDirectory->search($name), $value);
 }
示例#2
0
 /**
  * Create and return a new naming subdirectory with the attributes
  * of this one.
  *
  * @param string $name   The name of the new subdirectory
  * @param array  $filter Array with filters that will be applied when copy the attributes
  *
  * @return \TechDivision\Naming\NamingDirectory The new naming subdirectory
  */
 public function createSubdirectory($name, array $filter = array())
 {
     // create a new subdirectory instance
     $subdirectory = new NamingDirectory($name, $this);
     // copy the attributes specified by the filter
     if (sizeof($filter) > 0) {
         foreach ($this->getAllKeys() as $key => $value) {
             foreach ($filter as $pattern) {
                 if (fnmatch($pattern, $key)) {
                     $subdirectory->bind($key, $value);
                 }
             }
         }
     }
     // bind it the directory
     $this->bind($name, $subdirectory);
     // return the instance
     return $subdirectory;
 }