Exemplo n.º 1
0
 private static function getFileList($dataPath)
 {/*{{{*/
     $dirList = XString::listDir($dataPath);
     $fileList = array();
     foreach ($dirList as $dirName)
     {
         $dirPath = $dataPath.$dirName;
         if (is_dir($dirPath))
         {
             $files = XString::listFile($dirPath, false);
             if ($files)
             {
                 $fileList[$dirName] = $files; 
             }
         }
     }
     return $fileList;
 }/*}}}*/
Exemplo n.º 2
0
    public function testFile()
    {/*{{{*/
        $maxFileSize = 10*1024*1024;
        $maxItemCount = 10000;
        $configs =  BeanFinder::get('configs');
        $dataPath = $configs->dataPath."complete/";
        
        //文件夹存在
        $this->assertTrue(is_dir($dataPath));

        //取所有文件夹下的文件
        $dirList = XString::listDir($dataPath);

        if ($dirList)
        {
            foreach ($dirList as $dir)
            {
                $fileList = XString::listFile($dataPath.$dir);
                foreach ($fileList as $file)
                {
                    //单个文件不超过10M
                    $this->assertFalse((filesize($file) > $maxFileSize), $file."过大\n");
                }
            }

            foreach ($dirList as $dir)
            {
                $fileList = XString::listFile($dataPath.$dir);
                foreach ($fileList as $file)
                {
                    $xmlData = $xmlHospitalList = $xmlHospital = array();
                    $xmlData = file_get_contents($file);
                    $xmlHospitalList = XString::xmlToArray($xmlData);
                    if (isset($xmlHospitalList['item']) && $xmlHospitalList['item'])
                    {
                        //每个文件数量不超过10000
                        $xmlHospital = array_pop($xmlHospitalList['item']);
                        $this->assertFalse(count($xmlHospital) > $maxItemCount);
                    }
                }
            }
        }
    }/*}}}*/