Exemplo n.º 1
0
 /**
  * @dataProvider \g105b\phpcsv\TestHelper::data_randomFilePath
  */
 public function testHeaderRowLoad($filePath)
 {
     $rows = TestHelper::createCsv($filePath);
     $csv = new Csv($filePath);
     $headerRow = $csv->getHeaders();
     $this->assertEquals($rows[0], $headerRow);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider \g105b\phpcsv\TestHelper::data_randomFilePath
  */
 public function testGetAllDoesNotGiveHeaderRow($filePath)
 {
     TestHelper::createCsv($filePath, 10);
     $csv = new Csv($filePath);
     $headers = $csv->getHeaders();
     $allRows = $csv->getAll();
     $this->assertNotEquals($headers, array_values($allRows[0]));
 }
Exemplo n.º 3
0
 /**
  * @dataProvider \g105b\phpcsv\TestHelper::data_randomFilePath
  */
 public function testNewLine($filePath)
 {
     TestHelper::createCsv($filePath, 10);
     $csv = new Csv($filePath);
     $all = $csv->getAll();
     $numberOfRows = count($all);
     $csv->setIdField("rowNum");
     $headers = $csv->getHeaders();
     $rowThatHasNewLine = rand(0, 9);
     $fieldThatHasQuotes = rand(0, count($headers) - 2);
     $headerName = $headers[$fieldThatHasQuotes];
     $row = $csv->get($rowThatHasNewLine);
     $fieldValue = "New...\n...Line!";
     $row[$headerName] = $fieldValue;
     $csv->updateRow($rowThatHasNewLine, $row);
     $all = $csv->getAll(true);
     $this->assertEquals($numberOfRows, count($all), 'Should have same number of rows after update');
     $rowAfterUpdate = $csv->get($rowThatHasNewLine);
     $this->assertEquals($fieldValue, $rowAfterUpdate[$headerName]);
 }