mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
Merge pull request #4 from parsecsv/test-helper-for-itexia-with-namespaces
Test helper for ITEXIA fork with namespaces
This commit is contained in:
@@ -45,12 +45,17 @@ trait DatatypeTrait {
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
|
* @uses getDatatypeFromString
|
||||||
|
*
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
public function getDatatypes() {
|
public function getDatatypes() {
|
||||||
if (empty($this->data)) {
|
if (empty($this->data)) {
|
||||||
$this->data = $this->parse_string();
|
$this->data = $this->parse_string();
|
||||||
}
|
}
|
||||||
|
if (!is_array($this->data)) {
|
||||||
|
throw new \Exception('No data set yet.');
|
||||||
|
}
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($this->titles as $cName) {
|
foreach ($this->titles as $cName) {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
require './vendor/autoload.php';
|
chdir(__DIR__ . '/..');
|
||||||
|
if (!file_exists('vendor/autoload.php')) {
|
||||||
|
`composer dump-autoload`;
|
||||||
|
}
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
if (!class_exists('PHPUnit\Framework\TestCase')) {
|
if (!class_exists('PHPUnit\Framework\TestCase')) {
|
||||||
// we run on an older PHPUnit version without namespaces.
|
// we run on an older PHPUnit version without namespaces.
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class ParseTest extends TestCase
|
|||||||
* @depends testSepRowAutoDetection
|
* @depends testSepRowAutoDetection
|
||||||
*/
|
*/
|
||||||
public function testGetColumnDatatypes() {
|
public function testGetColumnDatatypes() {
|
||||||
$this->csv->auto('tests/methods/fixtures/datatype.csv');
|
$this->csv->auto(__DIR__ . '/fixtures/datatype.csv');
|
||||||
$this->csv->getDatatypes();
|
$this->csv->getDatatypes();
|
||||||
$expected = [
|
$expected = [
|
||||||
'title' => 'string',
|
'title' => 'string',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
sep=;
|
sep=;
|
||||||
title;isbn;publishedAt;published;count;price;
|
title;isbn;publishedAt;published;count;price
|
||||||
Красивая кулинария;5454-5587-3210;21.05.2011;true;1;10.99
|
Красивая кулинария;5454-5587-3210;21.05.2011;true;1;10.99
|
||||||
The Wine Connoisseurs;2547-8548-2541;12.12.2011;TRUE;;20,33
|
The Wine Connoisseurs;2547-8548-2541;12.12.2011;TRUE;;20,33
|
||||||
Weißwein;1313-4545-8875;23.02.2012;false;10;10
|
Weißwein;1313-4545-8875;23.02.2012;false;10;10
|
||||||
|
|||||||
|
@@ -11,7 +11,7 @@ class default_values_properties_Test extends TestCase {
|
|||||||
* The parseCSV object
|
* The parseCSV object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var [parseCSV]
|
* @var Csv
|
||||||
*/
|
*/
|
||||||
protected $csv = null;
|
protected $csv = null;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ class default_values_properties_Test extends TestCase {
|
|||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
//setup parse CSV
|
//setup parse CSV
|
||||||
$this->csv = new parseCSV();
|
$this->csv = new Csv();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class DefaultValuesTest extends TestCase {
|
|||||||
* The parseCSV object
|
* The parseCSV object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var [parseCSV]
|
* @var Csv
|
||||||
*/
|
*/
|
||||||
protected $csv = null;
|
protected $csv = null;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class DefaultValuesTest extends TestCase {
|
|||||||
* The reflection class object
|
* The reflection class object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var [ReflectionClass]
|
* @var \ReflectionClass
|
||||||
*/
|
*/
|
||||||
protected $reflection = null;
|
protected $reflection = null;
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@ class DefaultValuesTest extends TestCase {
|
|||||||
* Reflection Properties
|
* Reflection Properties
|
||||||
* The reflected class properties
|
* The reflected class properties
|
||||||
*
|
*
|
||||||
|
* @var \ReflectionProperty[]
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected $properties = null;
|
protected $properties = null;
|
||||||
@@ -43,7 +44,7 @@ class DefaultValuesTest extends TestCase {
|
|||||||
$this->csv = new Csv();
|
$this->csv = new Csv();
|
||||||
|
|
||||||
//setup the reflection class
|
//setup the reflection class
|
||||||
$this->reflection = new ReflectionClass($this->csv);
|
$this->reflection = new \ReflectionClass($this->csv);
|
||||||
|
|
||||||
//setup the reflected class properties
|
//setup the reflected class properties
|
||||||
$this->properties = $this->reflection->getProperties();
|
$this->properties = $this->reflection->getProperties();
|
||||||
@@ -69,7 +70,7 @@ class DefaultValuesTest extends TestCase {
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function test_propertiesCount() {
|
public function test_propertiesCount() {
|
||||||
$this->assertCount(28, $this->properties);
|
$this->assertCount(29, $this->properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +117,7 @@ class DefaultValuesTest extends TestCase {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Find our real properties
|
// Find our real properties
|
||||||
$real_properties = array_map(function (ReflectionProperty $property) {
|
$real_properties = array_map(function (\ReflectionProperty $property) {
|
||||||
return $property->getName();
|
return $property->getName();
|
||||||
}, $this->properties);
|
}, $this->properties);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user