diff options
author | ignace nyamagana butera <nyamsprod@gmail.com> | 2014-04-11 13:42:14 +0200 |
---|---|---|
committer | Ignace Nyamagana Butera <nyamsprod@gmail.com> | 2014-04-14 15:11:57 +0200 |
commit | c623d3dbd71bda1c1b109c9e6901e47817fa947b (patch) | |
tree | da84c3ce71a9a4b8851c97833ff92f36adbb9fd4 /test | |
parent | 3cdd4d14b233b5a0863eb7c13b46fb23978081bc (diff) | |
download | csv-c623d3dbd71bda1c1b109c9e6901e47817fa947b.zip csv-c623d3dbd71bda1c1b109c9e6901e47817fa947b.tar.gz csv-c623d3dbd71bda1c1b109c9e6901e47817fa947b.tar.bz2 |
implementing consistency check in the Writer class #34
Diffstat (limited to 'test')
-rw-r--r-- | test/WriterTest.php | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/test/WriterTest.php b/test/WriterTest.php index ecfcb90..bf922c0 100644 --- a/test/WriterTest.php +++ b/test/WriterTest.php @@ -87,13 +87,48 @@ class WriterTest extends PHPUnit_Framework_TestCase /** * @expectedException InvalidArgumentException */ + public function testColumCountSetterGetter() + { + $this->assertSame(-1, $this->csv->getColumnCount()); + $this->csv->setColumnCount(3); + $this->assertSame(3, $this->csv->getColumnCount()); + $this->csv->setColumnCount('toto'); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testColumCountConsistency() + { + $this->csv->insertOne(['john', 'doe', 'john.doe@example.com']); + $this->csv->setColumnCount(2); + $this->csv->insertOne(['jane', 'jane.doe@example.com']); + $this->csv->setColumnCount(3); + $this->csv->insertOne(['jane', 'jane.doe@example.com']); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testAutoDetectColumnCount() + { + $this->csv->autoDetectColumnCount(); + $this->assertSame(-1, $this->csv->getColumnCount()); + $this->csv->insertOne(['john', 'doe', 'john.doe@example.com']); + $this->assertSame(3, $this->csv->getColumnCount()); + $this->csv->insertOne(['jane', 'jane.doe@example.com']); + } + + /** + * @expectedException InvalidArgumentException + */ public function testFailedInsertWithWrongData() { $this->csv->insertOne(new DateTime); } /** - * @expectedException RuntimeException + * @expectedException InvalidArgumentException */ public function testFailedInsertWithMultiDimensionArray() { |