Merge remote-tracking branch 'origin/test-helper-for-itexia-master' into delete_this_branch

This commit is contained in:
Christian Bläul
2018-02-18 19:41:38 +01:00
4 changed files with 9 additions and 4 deletions

View File

@@ -37,7 +37,7 @@ trait DatatypeTrait {
return 'integer'; return 'integer';
} }
if (preg_match('/^[+-]?([0-9]*[.])?([0-9]|[.][0-9])+$/', $value)) { if (preg_match('/(^[+-]?$)|(^[+-]?[0-9]+([,.][0-9])?[0-9]*(e[+-]?[0-9]+)?$)/', $value)) {
return 'float'; return 'float';
} }
@@ -75,12 +75,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) {

View File

@@ -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',

View File

@@ -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
1 sep=;
2 title;isbn;publishedAt;published;count;price; title;isbn;publishedAt;published;count;price
3 Красивая кулинария;5454-5587-3210;21.05.2011;true;1;10.99
4 The Wine Connoisseurs;2547-8548-2541;12.12.2011;TRUE;;20,33
5 Weißwein;1313-4545-8875;23.02.2012;false;10;10

View File

@@ -70,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);
} }
/** /**