Esempio n. 1
0
 private function getDataInfo($dataArray)
 {/*{{{*/
     if(is_array($dataArray) && !empty($dataArray))
     {
         foreach($dataArray as $data)
         {
             $dataDir = $this->dataPath.$data.'/';
             $res[$data] = XString::listFile($dataDir);
         }
         return $res;
     }
     return null;
 }/*}}}*/
 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;
 }/*}}}*/
Esempio n. 3
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);
                    }
                }
            }
        }
    }/*}}}*/
Esempio n. 4
0
 private function completeData($functionName)
 {/*{{{*/
     $className = str_replace("test", '', $functionName);
     $this->assertTrue(class_exists($className), $className."类不存在\n");
     $factory = new OpenFactory;
     $factory->wrapData();
     $dataPath = $configs->standardPath.strtolower($className);
     $configs =  BeanFinder::get('configs');
     $resPath = $configs->resPath.strtolower($className);
     $this->assertTrue(is_dir($resPath), $resPath."路径不存在\n");
     $fileList = XString::listFile($resPath);
     $this->assertNotEmpty($fileList, $className."下没有文件\n");
     XString::clearDir($dataPath);
     foreach ($fileList as $key => $file)
     {
         if (strstr($file, 'xml') == false)
         {
             unset ($fileList[$key]);
         }
     }
     return $fileList;
 }/*}}}*/