Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-36113 - lib: Unit tests for importing csv files with empty lines …

…in the middle of the file.
  • Loading branch information...
commit 13041f21254c2d3306d1ff2dcf3b0ad4a0b9fe78 1 parent 415a6ff
@abgreeve abgreeve authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 lib/tests/csvclass_test.php
View
18 lib/tests/csvclass_test.php
@@ -34,6 +34,7 @@ class csvclass_testcase extends advanced_testcase {
var $teststring = '';
var $teststring2 = '';
var $teststring3 = '';
+ var $teststring4 = '';
protected function setUp(){
@@ -65,6 +66,16 @@ protected function setUp(){
"Fred Flint","<p>Find the stone inside the box</p>",Asahi,"A fourth column"
"Sarah Smith","<p>How are the people next door?</p>,Yebisu,"Forget the next"
';
+
+ $this->teststring4 = 'fullname,"description of things",beer
+"Douglas Dirk","<p>I am fine, thankyou.</p>",Becks
+
+"Addelyn Francis","<p>Thanks for the cake</p>",Becks
+"Josh Frankson","<p>Everything is fine</p>",Asahi
+
+
+"Heath Forscyth","<p>We are going to make you lose your mind</p>",Fosters
+';
}
public function test_csv_functions() {
@@ -113,5 +124,12 @@ public function test_csv_functions() {
$csvimport->cleanup();
$csvimport->close();
$this->assertEquals($importerror, $errortext);
+
+ // Testing for empty lines.
+ $iid = csv_import_reader::get_new_iid('blanklines');
+ $csvimport = new csv_import_reader($iid, 'blanklines');
+ $contentcount = $csvimport->load_csv_content($this->teststring4, 'utf-8', 'comma');
+ // Five lines including the headings should be imported.
+ $this->assertEquals($contentcount, 5);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.