diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..12bd60e
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,17 @@
+language: php
+
+php:
+ - 5.6
+ - 5.5
+ - 5.4
+ - 5.3
+ - hhvm
+
+script:
+ - phpunit --configuration tests/phpunit.xml
+
+notifications:
+ email:
+ - will.knauss@gmail.com
+ on_success: never
+ on_failure: always
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..71b1056
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,15 @@
+COMPOSER_BIN_DIR := vendor/bin
+PHPUNIT_ARGS = -c tests/phpunit.xml
+
+test: phpunit-dep
+ ${COMPOSER_BIN_DIR}/phpunit ${PHPUNIT_ARGS}
+
+phpunit-dep:
+ test -f ${COMPOSER_BIN_DIR}/phpunit || ( \
+ echo "phpunit is required to run tests." \
+ "Please run: composer install" >&2 && \
+ exit 1 \
+ )
+
+.SILENT:
+.PHONY: test phpunit-dep
diff --git a/parsecsv.lib.php b/parsecsv.lib.php
index 8bdff62..d14d3f0 100644
--- a/parsecsv.lib.php
+++ b/parsecsv.lib.php
@@ -145,7 +145,7 @@ class parseCSV {
* @var string
*/
public $enclosure = '"';
-
+
/**
* Enclose All
* Force enclosing all columns
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
new file mode 100644
index 0000000..e5cc951
--- /dev/null
+++ b/tests/Bootstrap.php
@@ -0,0 +1,6 @@
+csv = new parseCSV();
+ }
+
+ /**
+ * Tear down
+ * Tear down our test environment objects
+ *
+ * @access public
+ */
+ public function tearDown() {
+ $this->csv = null;
+ }
+
+ public function test_offset_param() {
+ $offset = 10;
+ $this->csv = new parseCSV(null,$offset);
+ $this->assertTrue(is_numeric($this->csv->offset));
+ $this->assertEquals($offset,$this->csv->offset);
+ }
+
+ public function test_limit_param() {
+ $limit = 10;
+ $this->csv = new parseCSV(null,null,$limit);
+ $this->assertTrue(is_numeric($this->csv->limit));
+ $this->assertEquals($limit,$this->csv->limit);
+ }
+
+ public function test_conditions_param() {
+ $conditions = 'some column NOT value';
+ $this->csv = new parseCSV(null,null,null,$conditions);
+ $this->assertTrue(is_string($this->csv->conditions));
+ $this->assertEquals($conditions,$this->csv->conditions);
+ }
+
+ public function test_keep_file_data_param() {
+ $keep = true;
+ $this->csv = new parseCSV(null,null,null,null,$keep);
+ $this->assertTrue(is_bool($this->csv->keep_file_data));
+ $this->assertEquals($keep,$this->csv->keep_file_data);
+ }
+
+ public function test_input_param() {
+ $csv = "col1,col2,col3\r\nval1,val2,val3\r\nval1A,val2A,val3A\r\n";
+ $this->csv = new parseCSV($csv,null,null,null,true);
+ $this->assertTrue(is_string($this->csv->file_data));
+ $this->assertEquals($csv,$this->csv->file_data);
+ }
+}
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
new file mode 100644
index 0000000..71c00fb
--- /dev/null
+++ b/tests/phpunit.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ properties/
+ methods/
+
+
+
diff --git a/tests/properties/default_values_test.php b/tests/properties/default_values_test.php
new file mode 100644
index 0000000..631350a
--- /dev/null
+++ b/tests/properties/default_values_test.php
@@ -0,0 +1,161 @@
+csv = new parseCSV();
+ }
+
+ /**
+ * Tear down
+ * Tear down our test environment objects
+ *
+ * @access public
+ */
+ public function tearDown() {
+ $this->csv = null;
+ }
+
+ public function test_heading_default() {
+ $this->assertTrue(is_bool($this->csv->heading));
+ $this->assertTrue($this->csv->heading);
+ }
+
+ public function test_fields_default() {
+ $this->assertTrue(is_array($this->csv->fields));
+ $this->assertCount(0,$this->csv->fields);
+ }
+
+ public function test_sort_by_default() {
+ $this->assertNull($this->csv->sort_by);
+ }
+
+ public function test_sort_reverse_default() {
+ $this->assertTrue(is_bool($this->csv->sort_reverse));
+ $this->assertFalse($this->csv->sort_reverse);
+ }
+
+ public function test_sort_type_default() {
+ $this->assertNull($this->csv->sort_type);
+ }
+
+ public function test_delimiter_default() {
+ $this->assertTrue(is_string($this->csv->delimiter));
+ $this->assertEquals(',',$this->csv->delimiter);
+ }
+
+ public function test_enclosure_default() {
+ $this->assertTrue(is_string($this->csv->enclosure));
+ $this->assertEquals('"',$this->csv->enclosure);
+ }
+
+ public function test_enclose_all_default() {
+ $this->assertTrue(is_bool($this->csv->enclose_all));
+ $this->assertFalse($this->csv->enclose_all);
+ }
+
+ public function test_conditions_default() {
+ $this->assertNull($this->csv->conditions);
+ }
+
+ public function test_offset_default() {
+ $this->assertNull($this->csv->offset);
+ }
+
+ public function test_limit_default() {
+ $this->assertNull($this->csv->limit);
+ }
+
+ public function test_auto_depth_default() {
+ $this->assertTrue(is_numeric($this->csv->auto_depth));
+ $this->assertEquals(15,$this->csv->auto_depth);
+ }
+
+ public function test_auto_non_chars_default() {
+ $this->assertTrue(is_string($this->csv->auto_non_chars));
+ $this->assertEquals("a-zA-Z0-9\n\r",$this->csv->auto_non_chars);
+ }
+
+ public function test_auto_preferred_default() {
+ $this->assertTrue(is_string($this->csv->auto_preferred));
+ $this->assertEquals(",;\t.:|",$this->csv->auto_preferred);
+ }
+
+ public function test_convert_encoding_default() {
+ $this->assertTrue(is_bool($this->csv->convert_encoding));
+ $this->assertFalse($this->csv->convert_encoding);
+ }
+
+ public function test_input_encoding_default() {
+ $this->assertTrue(is_string($this->csv->input_encoding));
+ $this->assertEquals('ISO-8859-1',$this->csv->input_encoding);
+ }
+
+ public function test_output_encoding_default() {
+ $this->assertTrue(is_string($this->csv->output_encoding));
+ $this->assertEquals('ISO-8859-1',$this->csv->output_encoding);
+ }
+
+ public function test_linefeed_default() {
+ $this->assertTrue(is_string($this->csv->linefeed));
+ $this->assertEquals("\r",$this->csv->linefeed);
+ }
+
+ public function test_output_delimiter_default() {
+ $this->assertTrue(is_string($this->csv->output_delimiter));
+ $this->assertEquals(',',$this->csv->output_delimiter);
+ }
+
+ public function test_output_filename_default() {
+ $this->assertTrue(is_string($this->csv->output_filename));
+ $this->assertEquals('data.csv',$this->csv->output_filename);
+ }
+
+ public function test_keep_file_data_default() {
+ $this->assertTrue(is_bool($this->csv->keep_file_data));
+ $this->assertFalse($this->csv->keep_file_data);
+ }
+
+ public function test_file_default() {
+ $this->assertNull($this->csv->file);
+ }
+
+ public function test_file_data_default() {
+ $this->assertNull($this->csv->file_data);
+ }
+
+ public function test_error_default() {
+ $this->assertTrue(is_numeric($this->csv->error));
+ $this->assertEquals(0,$this->csv->error);
+ }
+
+ public function test_error_info_default() {
+ $this->assertTrue(is_array($this->csv->error_info));
+ $this->assertCount(0,$this->csv->error_info);
+ }
+
+ public function test_titles_default() {
+ $this->assertTrue(is_array($this->csv->titles));
+ $this->assertCount(0,$this->csv->titles);
+ }
+
+ public function test_data_default() {
+ $this->assertTrue(is_array($this->csv->data));
+ $this->assertCount(0,$this->csv->data);
+ }
+}
diff --git a/tests/properties/worthless_test.php b/tests/properties/worthless_test.php
new file mode 100644
index 0000000..5491c8c
--- /dev/null
+++ b/tests/properties/worthless_test.php
@@ -0,0 +1,144 @@
+csv = new parseCSV();
+
+ //setup the reflection class
+ $this->reflection = new ReflectionClass($this->csv);
+
+ //setup the reflected class properties
+ $this->properties = $this->reflection->getProperties();
+ }
+
+ /**
+ * Tear down
+ * Tear down our test environment objects
+ *
+ * @access public
+ */
+ public function tearDown() {
+ $this->csv = null;
+ $this->reflection = null;
+ $this->properties = null;
+ }
+
+ /**
+ * test_propertiesCount
+ * Counts the number of properties to make sure we didn't add or
+ * subtract any without thinking
+ *
+ * @access public
+ */
+ public function test_propertiesCount() {
+ $this->assertCount(27,$this->properties);
+ }
+
+ /**
+ * test_property_names
+ * We have an expected set of properties that should exists
+ * Make sure our expected number of properties matches the real
+ * count of properties and also check to make sure our expected
+ * properties exists within the class
+ *
+ * @access public
+ */
+ public function test_property_names() {
+ //set our expected properties name(s)
+ $names = array(
+ 'heading',
+ 'fields',
+ 'sort_by',
+ 'sort_reverse',
+ 'sort_type',
+ 'delimiter',
+ 'enclosure',
+ 'enclose_all',
+ 'conditions',
+ 'offset',
+ 'limit',
+ 'auto_depth',
+ 'auto_non_chars',
+ 'auto_preferred',
+ 'convert_encoding',
+ 'input_encoding',
+ 'output_encoding',
+ 'linefeed',
+ 'output_delimiter',
+ 'output_filename',
+ 'keep_file_data',
+ 'file',
+ 'file_data',
+ 'error',
+ 'error_info',
+ 'titles',
+ 'data'
+ );
+
+ //find our real properties
+ $real_properties = array();
+ for ($a=0; $aproperties); $a++) {
+ $real_properties[] = $this->properties[$a]->getName();
+ }
+
+ //lets make sure our expected matches the number of real properties
+ $this->assertCount(count($names),$this->properties);
+
+ //lets loop through our expected to make sure they exists
+ for ($a=0; $aassertTrue(in_array($names[$a],$real_properties));
+ }
+ }
+
+ /**
+ * test_count_public_properties
+ * We at this point only have public properties so
+ * lets verify all properties are public
+ *
+ * @access public
+ */
+ public function test_count_public_properties() {
+ $counter = 0;
+
+ for ($a=0; $aproperties); $a++) {
+ if ($this->properties[$a]->isPublic() === true) {
+ $counter++;
+ }
+ }
+
+ $this->assertCount($counter,$this->properties);
+ }
+}