コード例 #1
0
ファイル: Data.test.php プロジェクト: g105b/phpcsv
 /**
  * @dataProvider \g105b\phpcsv\TestHelper::data_randomFilePath
  */
 public function testUnicodeData($filePath)
 {
     $csv = new Csv($filePath);
     $data = [["EnglishWord" => "American", "ChineseWord" => "美国人"], ["EnglishWord" => "French", "ChineseWord" => "法国人"], ["EnglishWord" => "German", "ChineseWord" => "德国人"]];
     foreach ($data as $d) {
         $csv->add($d);
     }
     $this->assertEquals($data[1], $csv->get(1));
 }
コード例 #2
0
ファイル: CreateRecord.test.php プロジェクト: g105b/phpcsv
 /**
  * @dataProvider \g105b\phpcsv\TestHelper::data_randomFilePath
  */
 public function testAddingMissingFieldsIndexed($filePath)
 {
     $csv = new Csv($filePath);
     $csv->add(["firstName" => "Alan", "lastName" => "Statham", "Job Title" => "Consultant Radiologist"]);
     $csv->add([2 => "Surgical Registrar"]);
     $row = $csv->get(1);
     $this->assertArrayHasKey("firstName", $row);
     $this->assertArrayHasKey("lastName", $row);
     $this->assertArrayHasKey("Job Title", $row);
     $csv->add([0 => "Martin"]);
     $row = $csv->get(2);
     $this->assertArrayHasKey("firstName", $row);
     $this->assertArrayHasKey("lastName", $row);
     $this->assertArrayHasKey("Job Title", $row);
 }
コード例 #3
0
ファイル: LoadFile.test.php プロジェクト: g105b/phpcsv
 /**
  * @dataProvider \g105b\phpcsv\TestHelper::data_randomFilePath
  */
 public function testFileNotDeletedWhenChanges($filePath)
 {
     $csv = new Csv($filePath);
     $csv->add(["key" => "value"]);
     $csv = null;
     $this->assertFileExists($filePath);
 }