コード例 #1
0
  function _checkProperNesting($nodes, $line='')
  {
    $paths[] = ComplexArray :: getMinColumnValue('path', $nodes, $index);

    $counter = 0;
    foreach($nodes as $id => $node)
    {
      if($counter == 0)
      {
        $this->assertEqual($node['path'], $paths[0],
          'first element path is invalid: ' . $node['path'] . ' , expected : ' . $paths[0] . ' at line: ' . $line);
      }
      elseif(preg_match('~^(.*/)[^/]+/$~', $node['path'], $matches))
      {
        $prev_path = $matches[1];
        $this->assertTrue(in_array($prev_path, $paths),
          'path is improperly nested: ' . $node['path'] . ' , expected parent not found: ' . $prev_path . ' at line: ' . $line);
      }
      else
      {
        $this->assertFalse(true, 'path is invalid: ' . $node['path'] . ' at line: ' . $line);
      }

      $paths[] = $node['path'];
      $counter++;
    }
  }
コード例 #2
0
  function _checkProperNesting($nodes, $line='')
  {
    $this->assertEqual(ComplexArray :: sortArray($nodes, array('path' => 'ASC')),
                       $nodes);

    $path = ComplexArray :: getMinColumnValue('path', $nodes, $index);
    $parent_paths[] = $this->_getParentPath($path);

    $counter = 0;
    foreach($nodes as $id => $node)
    {
      $parent_path = $this->_getParentPath($node['path']);

      $this->assertTrue(in_array($parent_path, $parent_paths),
        'path is improperly nested: ' . $node['path'] . ' , expected parent not found: ' . $parent_path . ' at line: ' . $line);

      $parent_paths[] = $node['path'];
    }
  }