コード例 #1
0
ファイル: RetrieveRecord.test.php プロジェクト: g105b/phpcsv
 /**
  * @dataProvider \g105b\phpcsv\TestHelper::data_randomFilePath
  */
 public function testGetByField($filePath)
 {
     $originalRows = TestHelper::createCsv($filePath);
     $headers = array_shift($originalRows);
     $csv = new Csv($filePath);
     $result = $csv->getBy("gender", "F");
     $filteredRows = array_filter($originalRows, function ($row) use($headers) {
         $genderFieldNum = array_search("gender", $headers);
         return $row[$genderFieldNum] === "M";
     });
     $originalSource = $originalRows[$result["rowNum"]];
     $rowWithHeaders = $csv->toAssociative($originalSource);
     $this->assertEquals($rowWithHeaders, $result);
 }