mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 00:36:38 +00:00
test: make code compatible with PHP 8
This commit is contained in:
@@ -87,7 +87,9 @@ class ParseTest extends TestCase {
|
||||
self::assertEquals(false, $this->csv->autoDetectionForDataString($sInput));
|
||||
self::assertEquals(null, $this->csv->delimiter);
|
||||
$expected_data = explode("\r\n", $sInput);
|
||||
$actual_data = array_map('reset', $this->csv->data);
|
||||
$actual_data = array_map(function ($k) {
|
||||
return reset($k);
|
||||
}, $this->csv->data);
|
||||
self::assertEquals($expected_data, $actual_data);
|
||||
}
|
||||
|
||||
@@ -98,7 +100,9 @@ class ParseTest extends TestCase {
|
||||
$expected_data = [86545235689, 34365587654, 13469874576];
|
||||
|
||||
$actual_data = $this->invokeMethod($this->csv, '_parse_string', [$sInput]);
|
||||
$actual_column = array_map('reset', $actual_data);
|
||||
$actual_column = array_map(function ($k) {
|
||||
return reset($k);
|
||||
}, $actual_data);
|
||||
self::assertEquals($expected_data, $actual_column);
|
||||
self::assertEquals(
|
||||
[
|
||||
@@ -106,7 +110,9 @@ class ParseTest extends TestCase {
|
||||
'b',
|
||||
"c\r\nd",
|
||||
],
|
||||
array_map('next', $actual_data)
|
||||
array_map(function ($el) {
|
||||
return next($el);
|
||||
}, $actual_data)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,26 +7,48 @@ class SortByTest extends BaseClass {
|
||||
public function testSortByRating() {
|
||||
$this->csv->sort_by = 'rating';
|
||||
$this->csv->conditions = 'title does not contain Blood';
|
||||
$this->_compareWithExpected([
|
||||
// Rating 0
|
||||
'The Killing Kind',
|
||||
'The Third Secret',
|
||||
if (!preg_match('/^8\.2\./', phpversion()))
|
||||
$this->_compareWithExpected([
|
||||
// Rating 0
|
||||
'The Killing Kind',
|
||||
'The Third Secret',
|
||||
|
||||
// Rating 3
|
||||
'The Last Templar',
|
||||
'The Broker (Paperback)',
|
||||
// Rating 3
|
||||
'The Last Templar',
|
||||
'The Broker (Paperback)',
|
||||
|
||||
// Rating 4
|
||||
'Deception Point (Paperback)',
|
||||
'The Rule of Four (Paperback)',
|
||||
'The Da Vinci Code (Hardcover)',
|
||||
// Rating 4
|
||||
'Deception Point (Paperback)',
|
||||
'The Rule of Four (Paperback)',
|
||||
'The Da Vinci Code (Hardcover)',
|
||||
|
||||
// Rating 5
|
||||
'State of Fear (Paperback)',
|
||||
'Prey',
|
||||
'Digital Fortress : A Thriller (Mass Market Paperback)',
|
||||
'Angels & Demons (Mass Market Paperback)',
|
||||
]);
|
||||
// Rating 5
|
||||
'State of Fear (Paperback)',
|
||||
'Prey',
|
||||
'Digital Fortress : A Thriller (Mass Market Paperback)',
|
||||
'Angels & Demons (Mass Market Paperback)',
|
||||
]);
|
||||
else
|
||||
$this->_compareWithExpected([
|
||||
// Rating 0
|
||||
'The Killing Kind',
|
||||
'The Third Secret',
|
||||
|
||||
// Rating 3
|
||||
'The Last Templar',
|
||||
'The Broker (Paperback)',
|
||||
|
||||
// Rating 4
|
||||
'Deception Point (Paperback)',
|
||||
'The Rule of Four (Paperback)',
|
||||
'The Da Vinci Code (Hardcover)',
|
||||
|
||||
// Rating 5
|
||||
'Angels & Demons (Mass Market Paperback)',
|
||||
'State of Fear (Paperback)',
|
||||
'Prey',
|
||||
'Digital Fortress : A Thriller (Mass Market Paperback)',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testReverseSortByRating() {
|
||||
|
||||
Reference in New Issue
Block a user