-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
31 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
use SplTempFileObject; | ||
use function chr; | ||
use function function_exists; | ||
use function iterator_to_array; | ||
use function ob_get_clean; | ||
use function ob_start; | ||
use function strtolower; | ||
|
@@ -149,7 +148,6 @@ public function testChunkDoesNotTimeoutAfterReading(): void | |
{ | ||
$raw_csv = "john,doe,[email protected]\njane,doe,[email protected]\n"; | ||
$csv = Reader::createFromString($raw_csv); | ||
iterator_to_array($csv->getRecords()); | ||
|
||
self::assertSame($raw_csv, $csv->toString()); | ||
} | ||
|
@@ -173,8 +171,7 @@ public function testChunkTriggersException(): void | |
{ | ||
$this->expectException(InvalidArgument::class); | ||
|
||
$chunk = $this->csv->chunk(0); | ||
iterator_to_array($chunk); | ||
[...$this->csv->chunk(0)]; | ||
} | ||
|
||
public function testChunk(): void | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ | |
use SplTempFileObject; | ||
use function current; | ||
use function in_array; | ||
use function iterator_to_array; | ||
use function json_encode; | ||
use function next; | ||
|
||
|
@@ -67,10 +66,7 @@ public function testFilter(): void | |
$result2 = $stmt->where($func2)->process($result1, ['foo', 'bar']); | ||
$result3 = $stmt->where($func2)->process($result2, ['foo', 'bar']); | ||
|
||
self::assertNotContains( | ||
['jane', 'doe', '[email protected]'], | ||
iterator_to_array($result1, false) | ||
); | ||
self::assertNotContains(['jane', 'doe', '[email protected]'], [...$result1]); | ||
|
||
self::assertCount(0, $result2); | ||
self::assertEquals($result3, $result2); | ||
|
@@ -82,13 +78,14 @@ public function testFetchColumnTriggersException(int|string $field): void | |
$this->expectException(InvalidArgument::class); | ||
|
||
$this->csv->setHeaderOffset(0); | ||
$resultSet = $this->stmt->process($this->csv); | ||
if (is_int($field)) { | ||
iterator_to_array($this->stmt->process($this->csv)->fetchColumnByOffset($field), false); | ||
[...$resultSet->fetchColumnByOffset($field)]; | ||
|
||
return; | ||
} | ||
|
||
iterator_to_array($this->stmt->process($this->csv)->fetchColumnByName($field), false); | ||
[...$resultSet->fetchColumnByName($field)]; | ||
} | ||
|
||
public static function invalidFieldNameProvider(): array | ||
|
@@ -104,8 +101,7 @@ public function testFetchColumnTriggersOutOfRangeException(): void | |
$this->expectException(InvalidArgument::class); | ||
|
||
$this->csv->setHeaderOffset(0); | ||
$res = $this->stmt->process($this->csv)->fetchColumnByOffset(-1); | ||
iterator_to_array($res, false); | ||
[...$this->stmt->process($this->csv)->fetchColumnByOffset(-1)]; | ||
} | ||
|
||
public function testFetchColumn(): void | ||
|
@@ -119,21 +115,15 @@ public function testFetchColumnByNameTriggersException(): void | |
$this->expectException(InvalidArgument::class); | ||
$this->csv->setHeaderOffset(0); | ||
|
||
iterator_to_array( | ||
$this->stmt->process($this->csv)->fetchColumnByName('foobar'), | ||
false | ||
); | ||
[...$this->stmt->process($this->csv)->fetchColumnByName('foobar')]; | ||
} | ||
|
||
public function testFetchColumnByOffsetTriggersException(): void | ||
{ | ||
$this->expectException(InvalidArgument::class); | ||
$this->csv->setHeaderOffset(0); | ||
|
||
iterator_to_array( | ||
$this->stmt->process($this->csv)->fetchColumnByOffset(24), | ||
false | ||
); | ||
[...$this->stmt->process($this->csv)->fetchColumnByOffset(24)]; | ||
} | ||
|
||
public function testFetchColumnByOffsetTriggersOutOfRangeException(): void | ||
|
@@ -142,10 +132,7 @@ public function testFetchColumnByOffsetTriggersOutOfRangeException(): void | |
|
||
$this->csv->setHeaderOffset(0); | ||
|
||
iterator_to_array( | ||
$this->stmt->process($this->csv)->fetchColumnByOffset(-1), | ||
false | ||
); | ||
[...$this->stmt->process($this->csv)->fetchColumnByOffset(-1)]; | ||
} | ||
|
||
public function testFetchAssocWithRowIndex(): void | ||
|
@@ -166,7 +153,7 @@ public function testFetchAssocWithRowIndex(): void | |
$csv->setHeaderOffset(2); | ||
self::assertContains( | ||
['D' => '6', 'E' => '7', 'F' => '8'], | ||
iterator_to_array($this->stmt->process($csv), false) | ||
[...$this->stmt->process($csv)] | ||
); | ||
} | ||
|
||
|
@@ -194,7 +181,7 @@ public function testFetchColumnInconsistentColumnCSV(): void | |
$csv = Reader::createFromFileObject($file); | ||
$res = $this->stmt->process($csv)->fetchColumnByOffset(2); | ||
|
||
self::assertCount(1, iterator_to_array($res)); | ||
self::assertCount(1, [...$res]); | ||
} | ||
|
||
public function testFetchColumnEmptyCol(): void | ||
|
@@ -210,7 +197,7 @@ public function testFetchColumnEmptyCol(): void | |
} | ||
$csv = Reader::createFromFileObject($file); | ||
$res = $this->stmt->process($csv)->fetchColumnByOffset(2); | ||
self::assertCount(0, iterator_to_array($res)); | ||
self::assertCount(0, [...$res]); | ||
} | ||
|
||
public function testfetchOne(): void | ||
|
@@ -261,7 +248,7 @@ public static function fetchPairsDataProvider(): array | |
|
||
public function testFetchPairsWithInvalidOffset(): void | ||
{ | ||
self::assertCount(0, iterator_to_array($this->stmt->process($this->csv)->fetchPairs(10, 1), true)); | ||
self::assertCount(0, [...$this->stmt->process($this->csv)->fetchPairs(10, 1)]); | ||
} | ||
|
||
public function testFetchPairsWithInvalidValue(): void | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ | |
use SplTempFileObject; | ||
use function array_reverse; | ||
use function in_array; | ||
use function iterator_to_array; | ||
use function strcmp; | ||
use function strlen; | ||
|
||
|
@@ -108,10 +107,7 @@ public function testIntervalThrowException(): void | |
{ | ||
$this->expectException(OutOfBoundsException::class); | ||
|
||
iterator_to_array($this->stmt | ||
->offset(1) | ||
->limit(0) | ||
->process($this->csv)); | ||
[...$this->stmt->offset(1)->limit(0)->process($this->csv)]; | ||
} | ||
|
||
public function testFilter(): void | ||
|
@@ -124,10 +120,7 @@ public function testFilter(): void | |
$result2 = $stmt->where($func2)->process($result1, ['foo', 'bar']); | ||
$result3 = $stmt->where($func2)->process($result2, ['foo', 'bar']); | ||
|
||
self::assertNotContains( | ||
['jane', 'doe', '[email protected]'], | ||
iterator_to_array($result1, false) | ||
); | ||
self::assertNotContains(['jane', 'doe', '[email protected]'], [...$result1]); | ||
|
||
self::assertCount(0, $result2); | ||
self::assertEquals($result3, $result2); | ||
|
@@ -139,7 +132,7 @@ public function testOrderBy(): void | |
->orderBy(fn (array $rowA, array $rowB): int => strcmp($rowA[0], $rowB[0])) | ||
->process($this->csv); | ||
|
||
self::assertSame(array_reverse($this->expected), iterator_to_array($calculated, false)); | ||
self::assertSame(array_reverse($this->expected), array_values([...$calculated])); | ||
} | ||
|
||
public function testOrderByWithEquity(): void | ||
|
@@ -148,6 +141,6 @@ public function testOrderByWithEquity(): void | |
->orderBy(fn (array $rowA, array $rowB): int => strlen($rowA[0]) <=> strlen($rowB[0])) | ||
->process($this->csv); | ||
|
||
self::assertSame($this->expected, iterator_to_array($calculated, false)); | ||
self::assertSame($this->expected, array_values([...$calculated])); | ||
} | ||
} |