Ejemplo n.º 1
0
 public function testValueEqual()
 {
     $this->assertTrue(HArray::valueEqual(array(), array()));
     $this->assertFalse(HArray::valueEqual(array(), array(1)));
     $this->assertTrue(HArray::valueEqual(array(1, 'a'), array('a', 1)));
     $this->assertTrue(HArray::valueEqual(array(1, 2), array('2', '1')));
 }
Ejemplo n.º 2
0
 /**
  * Compare if directories and files in two directories are the same.
  * @param string $dir1
  * @param string $dir2
  * @return boolean TRUE if two directories are equal, FALSE otherwise.
  */
 public static function dirsEqual($dir1, $dir2)
 {
     $result = TRUE;
     // Compare files.
     $files1 = self::listFileOnly($dir1);
     $files2 = self::listFileOnly($dir2);
     $result = \Umbalaconmeogia\Util\HArray::valueEqual(array_keys($files1), array_keys($files2));
     // Compare files' content
     if ($result) {
         foreach ($files1 as $key => $path1) {
             $path2 = $files2[$key];
             if (!File::filesEqual($path1, $path2)) {
                 $result = FALSE;
                 break;
             }
         }
     }
     // Compare sub directories.
     if ($result) {
         $files1 = self::listDirOnly($dir1);
         $files2 = self::listDirOnly($dir2);
         $result = \Umbalaconmeogia\Util\HArray::valueEqual(array_keys($files1), array_keys($files2));
         if ($result) {
             foreach ($files1 as $key => $path1) {
                 $path2 = $files2[$key];
                 if (!File::dirsEqual($path1, $path2)) {
                     $result = FALSE;
                     break;
                 }
             }
         } else {
         }
     }
     return $result;
 }