mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
Merge pull request #164 from parsecsv/composer-validate
Quality improvement, but no bug fixes or new features
This commit is contained in:
@@ -1,15 +1,20 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
|
- 7.3
|
||||||
- 7.2
|
- 7.2
|
||||||
- 7.1
|
- 7.1
|
||||||
- 7.0
|
- 7.0
|
||||||
- 5.6
|
- 5.6
|
||||||
- 5.5
|
- 5.5
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- composer update
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- phpunit --version
|
- composer validate
|
||||||
- phpunit --configuration tests/phpunit.xml
|
- vendor/bin/phpunit --version
|
||||||
|
- vendor/bin/phpunit --configuration tests/phpunit.xml
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
"homepage": "https://github.com/Fonata"
|
"homepage": "https://github.com/Fonata"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"autoload":{
|
"autoload": {
|
||||||
"psr-4":{
|
"psr-4": {
|
||||||
"ParseCsv\\": "src",
|
"ParseCsv\\": "src",
|
||||||
"ParseCsv\\extensions\\": "src\\extensions"
|
"ParseCsv\\extensions\\": "src\\extensions"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev":{
|
"autoload-dev": {
|
||||||
"psr-4":{
|
"psr-4": {
|
||||||
"ParseCsv\\tests\\": "tests"
|
"ParseCsv\\tests\\": "tests"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -40,6 +40,11 @@
|
|||||||
"suggest": {
|
"suggest": {
|
||||||
"illuminate/support": "Fluent array interface for map functions"
|
"illuminate/support": "Fluent array interface for map functions"
|
||||||
},
|
},
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/parsecsv/parsecsv-for-php/issues",
|
"issues": "https://github.com/parsecsv/parsecsv-for-php/issues",
|
||||||
"source": "https://github.com/parsecsv/parsecsv-for-php"
|
"source": "https://github.com/parsecsv/parsecsv-for-php"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
# include parseCSV class.
|
# include parseCSV class.
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
use ParseCsv\Csv;
|
use ParseCsv\Csv;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
# include parseCSV class.
|
# include parseCSV class.
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
use ParseCsv\Csv;
|
use ParseCsv\Csv;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
# include parseCSV class.
|
# include parseCSV class.
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
use ParseCsv\Csv;
|
use ParseCsv\Csv;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
# include parseCSV class.
|
# include parseCSV class.
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
use ParseCsv\Csv;
|
use ParseCsv\Csv;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class Csv {
|
|||||||
public $auto_depth = 15;
|
public $auto_depth = 15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auto Non Charts
|
* Auto Non Chars
|
||||||
* Characters that should be ignored when attempting to auto-detect delimiter
|
* Characters that should be ignored when attempting to auto-detect delimiter
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
@@ -287,7 +287,7 @@ class Csv {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Data
|
* Data
|
||||||
* Two dimensional array of CSV data
|
* Two-dimensional array of CSV data
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@@ -299,7 +299,7 @@ class Csv {
|
|||||||
* Constructor
|
* Constructor
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
* @param string|null $input The CSV string or a direct filepath
|
* @param string|null $input The CSV string or a direct file path
|
||||||
* @param integer|null $offset Number of rows to ignore from the
|
* @param integer|null $offset Number of rows to ignore from the
|
||||||
* beginning of the data
|
* beginning of the data
|
||||||
* @param integer|null $limit Limits the number of returned rows
|
* @param integer|null $limit Limits the number of returned rows
|
||||||
@@ -355,7 +355,7 @@ class Csv {
|
|||||||
* Parse
|
* Parse
|
||||||
* Parse a CSV file or string
|
* Parse a CSV file or string
|
||||||
*
|
*
|
||||||
* @param string|null $input The CSV string or a direct filepath
|
* @param string|null $input The CSV string or a direct file path
|
||||||
* @param integer $offset Number of rows to ignore from the
|
* @param integer $offset Number of rows to ignore from the
|
||||||
* beginning of the data
|
* beginning of the data
|
||||||
* @param integer $limit Limits the number of returned rows to
|
* @param integer $limit Limits the number of returned rows to
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ParseCsv\enums;
|
namespace ParseCsv\enums;
|
||||||
|
|
||||||
use ReflectionClass;
|
|
||||||
|
|
||||||
abstract class AbstractEnum {
|
abstract class AbstractEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new value of some type
|
* Creates a new value of some type
|
||||||
*
|
*
|
||||||
@@ -11,15 +11,14 @@ abstract class AbstractEnum {
|
|||||||
*
|
*
|
||||||
* @throws \UnexpectedValueException if incompatible type is given.
|
* @throws \UnexpectedValueException if incompatible type is given.
|
||||||
*/
|
*/
|
||||||
public function __construct($value)
|
public function __construct($value) {
|
||||||
{
|
|
||||||
if (!$this->isValid($value)) {
|
if (!$this->isValid($value)) {
|
||||||
throw new \UnexpectedValueException("Value '$value' is not part of the enum " . get_called_class());
|
throw new \UnexpectedValueException("Value '$value' is not part of the enum " . get_called_class());
|
||||||
}
|
}
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getConstants(){
|
public static function getConstants() {
|
||||||
$class = get_called_class();
|
$class = get_called_class();
|
||||||
$reflection = new \ReflectionClass($class);
|
$reflection = new \ReflectionClass($class);
|
||||||
|
|
||||||
@@ -33,8 +32,7 @@ abstract class AbstractEnum {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isValid($value)
|
public static function isValid($value) {
|
||||||
{
|
|
||||||
return in_array($value, static::getConstants(), true);
|
return in_array($value, static::getConstants(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class FileProcessingModeEnum {
|
|||||||
const MODE_FILE_OVERWRITE = false;
|
const MODE_FILE_OVERWRITE = false;
|
||||||
|
|
||||||
public static function getAppendMode($mode) {
|
public static function getAppendMode($mode) {
|
||||||
if ($mode == self::MODE_FILE_APPEND){
|
if ($mode == self::MODE_FILE_APPEND) {
|
||||||
return 'ab';
|
return 'ab';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ParseCsv\enums;
|
namespace ParseCsv\enums;
|
||||||
|
|
||||||
|
|
||||||
class SortEnum extends AbstractEnum {
|
class SortEnum extends AbstractEnum {
|
||||||
|
|
||||||
const __DEFAULT = self::SORT_TYPE_REGULAR;
|
const __DEFAULT = self::SORT_TYPE_REGULAR;
|
||||||
|
|
||||||
const SORT_TYPE_REGULAR = 'regular';
|
const SORT_TYPE_REGULAR = 'regular';
|
||||||
@@ -14,11 +16,11 @@ class SortEnum extends AbstractEnum {
|
|||||||
private static $sorting = array(
|
private static $sorting = array(
|
||||||
self::SORT_TYPE_REGULAR => SORT_REGULAR,
|
self::SORT_TYPE_REGULAR => SORT_REGULAR,
|
||||||
self::SORT_TYPE_STRING => SORT_STRING,
|
self::SORT_TYPE_STRING => SORT_STRING,
|
||||||
self::SORT_TYPE_NUMERIC => SORT_NUMERIC
|
self::SORT_TYPE_NUMERIC => SORT_NUMERIC,
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function getSorting($type){
|
public static function getSorting($type) {
|
||||||
if (array_key_exists($type, self::$sorting)){
|
if (array_key_exists($type, self::$sorting)) {
|
||||||
return self::$sorting[$type];
|
return self::$sorting[$type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ use ParseCsv\enums\DatatypeEnum;
|
|||||||
trait DatatypeTrait {
|
trait DatatypeTrait {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Datatypes
|
* Data Types
|
||||||
* Datatypes of CSV data-columns
|
* Data types of CSV data-columns, keyed by the column name. Possible values
|
||||||
|
* are string, float, integer, boolean, date. See DatatypeEnum.
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $data_types = [];
|
public $data_types = [];
|
||||||
@@ -19,8 +19,6 @@ trait DatatypeTrait {
|
|||||||
* Check data type for one column.
|
* Check data type for one column.
|
||||||
* Check for most commonly data type for one column.
|
* Check for most commonly data type for one column.
|
||||||
*
|
*
|
||||||
* @access private
|
|
||||||
*
|
|
||||||
* @param array $datatypes
|
* @param array $datatypes
|
||||||
*
|
*
|
||||||
* @return string|false
|
* @return string|false
|
||||||
@@ -47,8 +45,6 @@ trait DatatypeTrait {
|
|||||||
*
|
*
|
||||||
* Requires PHP >= 5.5
|
* Requires PHP >= 5.5
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
*
|
|
||||||
* @uses DatatypeEnum::getValidTypeFromSample
|
* @uses DatatypeEnum::getValidTypeFromSample
|
||||||
*
|
*
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
@@ -80,34 +76,28 @@ trait DatatypeTrait {
|
|||||||
*
|
*
|
||||||
* Requires PHP >= 5.5
|
* Requires PHP >= 5.5
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
*
|
|
||||||
* @uses DatatypeEnum::getValidTypeFromSample
|
* @uses DatatypeEnum::getValidTypeFromSample
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function autoDetectFileHasHeading(){
|
public function autoDetectFileHasHeading() {
|
||||||
if (empty($this->data)){
|
if (empty($this->data)) {
|
||||||
throw new \UnexpectedValueException('No data set yet.');
|
throw new \UnexpectedValueException('No data set yet.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->heading){
|
if ($this->heading) {
|
||||||
$firstRow = $this->titles;
|
$firstRow = $this->titles;
|
||||||
} else {
|
} else {
|
||||||
$firstRow = $this->data[0];
|
$firstRow = $this->data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$firstRow = array_filter($firstRow);
|
$firstRow = array_filter($firstRow);
|
||||||
if (empty($firstRow)){
|
if (empty($firstRow)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$firstRowDatatype = array_map(DatatypeEnum::class . '::getValidTypeFromSample', $firstRow);
|
$firstRowDatatype = array_map(DatatypeEnum::class . '::getValidTypeFromSample', $firstRow);
|
||||||
|
|
||||||
if ($this->getMostFrequentDatatypeForColumn($firstRowDatatype) !== DatatypeEnum::TYPE_STRING){
|
return $this->getMostFrequentDatatypeForColumn($firstRowDatatype) === DatatypeEnum::TYPE_STRING;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
namespace ParseCsv\tests\methods;
|
namespace ParseCsv\tests\methods;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use ParseCsv\enums\DatatypeEnum;
|
use ParseCsv\enums\DatatypeEnum;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class DatatypeTest extends TestCase
|
class DatatypeTest extends TestCase {
|
||||||
{
|
|
||||||
public function testSampleIsValidInteger(){
|
public function testSampleIsValidInteger() {
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('1'));
|
$this->assertEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('1'));
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('+1'));
|
$this->assertEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('+1'));
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('-1'));
|
$this->assertEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('-1'));
|
||||||
@@ -27,7 +27,7 @@ class DatatypeTest extends TestCase
|
|||||||
$this->assertNotEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('2018-02-19'));
|
$this->assertNotEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('2018-02-19'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSampleIsValidBool(){
|
public function testSampleIsValidBool() {
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('true'));
|
$this->assertEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('true'));
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('TRUE'));
|
$this->assertEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('TRUE'));
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('false'));
|
$this->assertEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('false'));
|
||||||
@@ -39,7 +39,7 @@ class DatatypeTest extends TestCase
|
|||||||
$this->assertNotEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('0.1'));
|
$this->assertNotEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('0.1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSampleIsValidFloat(){
|
public function testSampleIsValidFloat() {
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('1.0'));
|
$this->assertEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('1.0'));
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('-1.1'));
|
$this->assertEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('-1.1'));
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('+1,1'));
|
$this->assertEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('+1,1'));
|
||||||
@@ -54,7 +54,7 @@ class DatatypeTest extends TestCase
|
|||||||
$this->assertNotEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('2018-02-19'));
|
$this->assertNotEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('2018-02-19'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSampleIsValidDate(){
|
public function testSampleIsValidDate() {
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_DATE, DatatypeEnum::getValidTypeFromSample('2018-02-19'));
|
$this->assertEquals(DatatypeEnum::TYPE_DATE, DatatypeEnum::getValidTypeFromSample('2018-02-19'));
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_DATE, DatatypeEnum::getValidTypeFromSample('18-2-19'));
|
$this->assertEquals(DatatypeEnum::TYPE_DATE, DatatypeEnum::getValidTypeFromSample('18-2-19'));
|
||||||
$this->assertEquals(DatatypeEnum::TYPE_DATE, DatatypeEnum::getValidTypeFromSample('01.02.2018'));
|
$this->assertEquals(DatatypeEnum::TYPE_DATE, DatatypeEnum::getValidTypeFromSample('01.02.2018'));
|
||||||
|
|||||||
@@ -238,9 +238,9 @@ class ParseTest extends TestCase {
|
|||||||
/**
|
/**
|
||||||
* Call protected/private method of a class.
|
* Call protected/private method of a class.
|
||||||
*
|
*
|
||||||
* @param object &$object Instantiated object that we will run method on.
|
* @param object &$object Instantiated object that we will run method on.
|
||||||
* @param string $methodName Method name to call
|
* @param string $methodName Method name to call
|
||||||
* @param array $parameters Array of parameters to pass into method.
|
* @param array $parameters Array of parameters to pass into method.
|
||||||
*
|
*
|
||||||
* @return mixed Method return.
|
* @return mixed Method return.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ParseCsv\tests\methods;
|
namespace ParseCsv\tests\methods;
|
||||||
|
|
||||||
use ParseCsv\Csv;
|
use ParseCsv\Csv;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class SaveTest extends TestCase
|
class SaveTest extends TestCase {
|
||||||
{
|
|
||||||
|
|
||||||
/** @var Csv */
|
/** @var Csv */
|
||||||
private $csv;
|
private $csv;
|
||||||
|
|||||||
@@ -75,13 +75,13 @@ class UnparseTest extends Testcase {
|
|||||||
$this->unparseAndCompare($expected, $fields);
|
$this->unparseAndCompare($expected, $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnparseDefaultFirstRowMissing(){
|
public function testUnparseDefaultFirstRowMissing() {
|
||||||
unset($this->csv->data[0]);
|
unset($this->csv->data[0]);
|
||||||
$expected = "column1,column2\rvalue3,value4\r";
|
$expected = "column1,column2\rvalue3,value4\r";
|
||||||
$this->unparseAndCompare($expected);
|
$this->unparseAndCompare($expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnparseDefaultWithoutData(){
|
public function testUnparseDefaultWithoutData() {
|
||||||
unset($this->csv->data[0]);
|
unset($this->csv->data[0]);
|
||||||
unset($this->csv->data[1]);
|
unset($this->csv->data[1]);
|
||||||
$expected = "column1,column2\r";
|
$expected = "column1,column2\r";
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ class BaseClass extends TestCase {
|
|||||||
* CSV
|
* CSV
|
||||||
* The parseCSV object
|
* The parseCSV object
|
||||||
*
|
*
|
||||||
* @access protected
|
|
||||||
* @var Csv
|
* @var Csv
|
||||||
*/
|
*/
|
||||||
protected $csv;
|
protected $csv;
|
||||||
@@ -19,10 +18,8 @@ class BaseClass extends TestCase {
|
|||||||
/**
|
/**
|
||||||
* Setup
|
* Setup
|
||||||
* Setup our test environment objects
|
* Setup our test environment objects
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
protected function setUp() {
|
||||||
$this->csv = new Csv();
|
$this->csv = new Csv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace ParseCsv\tests\properties;
|
|||||||
* Tests related to the $offset property
|
* Tests related to the $offset property
|
||||||
*/
|
*/
|
||||||
class OffsetTest extends BaseClass {
|
class OffsetTest extends BaseClass {
|
||||||
|
|
||||||
public function testOffsetOfOne() {
|
public function testOffsetOfOne() {
|
||||||
$this->csv->offset = 1;
|
$this->csv->offset = 1;
|
||||||
$this->csv->auto(__DIR__ . '/../methods/fixtures/datatype.csv');
|
$this->csv->auto(__DIR__ . '/../methods/fixtures/datatype.csv');
|
||||||
|
|||||||
@@ -147,25 +147,25 @@ class PublicPropertiesTest extends TestCase {
|
|||||||
$this->assertCount($counter, $this->properties);
|
$this->assertCount($counter, $this->properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultSortTypeIsRegular(){
|
public function testDefaultSortTypeIsRegular() {
|
||||||
$this->assertEquals(SortEnum::SORT_TYPE_REGULAR, $this->csv->sort_type);
|
$this->assertEquals(SortEnum::SORT_TYPE_REGULAR, $this->csv->sort_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetSortType(){
|
public function testSetSortType() {
|
||||||
$this->csv->sort_type = 'numeric';
|
$this->csv->sort_type = 'numeric';
|
||||||
$this->assertEquals(SortEnum::SORT_TYPE_NUMERIC, $this->csv->sort_type);
|
$this->assertEquals(SortEnum::SORT_TYPE_NUMERIC, $this->csv->sort_type);
|
||||||
|
|
||||||
$this->csv->sort_type = 'string';
|
$this->csv->sort_type = 'string';
|
||||||
$this->assertEquals(SortEnum::SORT_TYPE_STRING, $this->csv->sort_type);
|
$this->assertEquals(SortEnum::SORT_TYPE_STRING, $this->csv->sort_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSorting(){
|
public function testGetSorting() {
|
||||||
$this->csv->sort_type = 'numeric';
|
$this->csv->sort_type = 'numeric';
|
||||||
$sorting = SortEnum::getSorting($this->csv->sort_type);
|
$sorting = SortEnum::getSorting($this->csv->sort_type);
|
||||||
$this->assertEquals(SORT_NUMERIC, $sorting);
|
$this->assertEquals(SORT_NUMERIC, $sorting);
|
||||||
|
|
||||||
$this->csv->sort_type = 'string';
|
$this->csv->sort_type = 'string';
|
||||||
$sorting = SortEnum::getSorting($this->csv->sort_type);
|
$sorting = SortEnum::getSorting($this->csv->sort_type);
|
||||||
$this->assertEquals(SORT_STRING, $sorting);
|
$this->assertEquals(SORT_STRING, $sorting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user