summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CsvTest.php26
-rw-r--r--test/ReaderTest.php10
-rw-r--r--test/WriterTest.php2
3 files changed, 17 insertions, 21 deletions
diff --git a/test/CsvTest.php b/test/CsvTest.php
index c912a18..4934211 100644
--- a/test/CsvTest.php
+++ b/test/CsvTest.php
@@ -100,33 +100,29 @@ class CsvTest extends PHPUnit_Framework_TestCase
$this->csv->setDelimiter('foo');
}
- public function testDetectDelimiter()
+ public function testDetectDelimiterList()
{
- $this->assertSame($this->csv->detectDelimiter(), ',');
+ $this->assertSame([','], $this->csv->detectDelimiterList());
}
/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage `$nb_rows` must be a valid positive integer
*/
- public function testDetectDelimiterWithInvalidRowLimit()
+ public function testDetectDelimiterListWithInvalidRowLimit()
{
- $this->csv->detectDelimiter(-4);
+ $this->csv->detectDelimiterList(-4);
}
- public function testDetectDelimiterWithNoCSV()
+ public function testDetectDelimiterListWithNoCSV()
{
$file = new SplTempFileObject;
$file->fwrite("How are you today ?\nI'm doing fine thanks!");
$csv = Writer::createFromFileObject($file);
- $this->assertNull($csv->detectDelimiter(5, ['toto', '|']));
+ $this->assertSame([], $csv->detectDelimiterList(5, ['toto', '|']));
}
- /**
- * @expectedException RuntimeException
- * @expectedExceptionMessage 'too many delimiters were found: `;`,`|`'
- */
- public function testDetectDelimiterWithInconsistentCSV()
+ public function testDetectDelimiterListWithInconsistentCSV()
{
$data = new SplTempFileObject;
$data->setCsvControl(';');
@@ -137,7 +133,7 @@ class CsvTest extends PHPUnit_Framework_TestCase
$data->fputcsv(['toto', 'tata', 'tutu']);
$csv = Writer::createFromFileObject($data);
- $csv->detectDelimiter(5, ['|']);
+ $this->assertSame(['|', ';'], $csv->detectDelimiterList(5, ['|']));
}
/**
@@ -180,10 +176,10 @@ class CsvTest extends PHPUnit_Framework_TestCase
public function testEncoding()
{
$expected = 'iso-8859-15';
- $this->csv->setEncoding($expected);
- $this->assertSame(strtoupper($expected), $this->csv->getEncoding());
+ $this->csv->setEncodingFrom($expected);
+ $this->assertSame(strtoupper($expected), $this->csv->getEncodingFrom());
- $this->csv->setEncoding('');
+ $this->csv->setEncodingFrom('');
}
public function testToString()
diff --git a/test/ReaderTest.php b/test/ReaderTest.php
index 7773d6e..f18324c 100644
--- a/test/ReaderTest.php
+++ b/test/ReaderTest.php
@@ -71,7 +71,7 @@ class ReaderTest extends PHPUnit_Framework_TestCase
$func = function ($row) {
return ! in_array('jane', $row);
};
- $this->csv->setFilter($func);
+ $this->csv->addFilter($func);
$this->assertCount(1, $this->csv->fetchAll());
@@ -97,7 +97,7 @@ class ReaderTest extends PHPUnit_Framework_TestCase
$func = function ($rowA, $rowB) {
return strcmp($rowA[0], $rowB[0]);
};
- $this->csv->setSortBy($func);
+ $this->csv->addSortBy($func);
$this->assertSame(array_reverse($this->expected), $this->csv->fetchAll());
$this->csv->addSortBy($func);
@@ -114,7 +114,7 @@ class ReaderTest extends PHPUnit_Framework_TestCase
$func = function ($rowA, $rowB) {
return strcmp($rowA[0], $rowB[0]);
};
- $csv->setSortBy($func);
+ $csv->addSortBy($func);
$this->assertSame([
['john', 'doe', 'john.doe@example.com'],
['john', 'doe', 'john.doe@example.com']
@@ -182,7 +182,7 @@ class ReaderTest extends PHPUnit_Framework_TestCase
public function testFetchCol()
{
- $this->assertSame(['john', 'jane'], $this->csv->fetchCol(0));
+ $this->assertSame(['john', 'jane'], $this->csv->fetchColumn(0));
$this->assertSame(['john', 'jane'], $this->csv->fetchColumn());
}
@@ -283,7 +283,7 @@ EOF;
public function testGetWriter2()
{
- $csv = Reader::createFromPath(__DIR__.'/foo.csv')->getWriter('a+');
+ $csv = Reader::createFromPath(__DIR__.'/foo.csv')->newWriter('a+');
$this->assertInstanceOf('\League\Csv\Writer', $csv);
}
}
diff --git a/test/WriterTest.php b/test/WriterTest.php
index 7b514c6..aedee30 100644
--- a/test/WriterTest.php
+++ b/test/WriterTest.php
@@ -214,7 +214,7 @@ class WriterTest extends PHPUnit_Framework_TestCase
$this->csv->insertOne($row);
}
- $reader = $this->csv->getReader();
+ $reader = $this->csv->newReader();
$this->assertSame(['john', 'doe', 'john.doe@example.com'], $reader->fetchOne(0));
}
}