-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve CallbackStreamFilter implementation
- Loading branch information
Showing
14 changed files
with
510 additions
and
121 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
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 |
---|---|---|
|
@@ -324,36 +324,36 @@ public function testEnclosure(): void | |
$this->csv->setEnclosure('foo'); | ||
} | ||
|
||
public function testAddStreamFilter(): void | ||
public function testappendStreamFilter(): void | ||
{ | ||
$csv = Reader::createFromPath(__DIR__.'/../test_files/foo.csv'); | ||
$csv->addStreamFilter('string.rot13'); | ||
$csv->addStreamFilter('string.tolower'); | ||
$csv->addStreamFilter('string.toupper'); | ||
$csv->appendStreamFilter('string.rot13'); | ||
$csv->appendStreamFilter('string.tolower'); | ||
$csv->appendStreamFilter('string.toupper'); | ||
foreach ($csv as $row) { | ||
self::assertSame($row, ['WBUA', 'QBR', '[email protected]']); | ||
} | ||
} | ||
|
||
public function testFailedAddStreamFilter(): void | ||
public function testFailedappendStreamFilter(): void | ||
{ | ||
$csv = Writer::createFromFileObject(new SplTempFileObject()); | ||
self::assertFalse($csv->supportsStreamFilterOnWrite()); | ||
|
||
$this->expectException(UnavailableFeature::class); | ||
|
||
$csv->addStreamFilter('string.toupper'); | ||
$csv->appendStreamFilter('string.toupper'); | ||
} | ||
|
||
public function testFailedAddStreamFilterWithWrongFilter(): void | ||
public function testFailedappendStreamFilterWithWrongFilter(): void | ||
{ | ||
$this->expectException(InvalidArgument::class); | ||
|
||
/** @var resource $tmpfile */ | ||
$tmpfile = tmpfile(); | ||
|
||
Writer::createFromStream($tmpfile) | ||
->addStreamFilter('foobar.toupper'); | ||
->appendStreamFilter('foobar.toupper'); | ||
} | ||
|
||
public function testStreamFilterDetection(): void | ||
|
@@ -363,7 +363,7 @@ public function testStreamFilterDetection(): void | |
|
||
self::assertFalse($csv->hasStreamFilter($filtername)); | ||
|
||
$csv->addStreamFilter($filtername); | ||
$csv->appendStreamFilter($filtername); | ||
|
||
self::assertTrue($csv->hasStreamFilter($filtername)); | ||
} | ||
|
@@ -372,7 +372,7 @@ public function testClearAttachedStreamFilters(): void | |
{ | ||
$path = __DIR__.'/../test_files/foo.csv'; | ||
$csv = Reader::createFromPath($path); | ||
$csv->addStreamFilter('string.toupper'); | ||
$csv->appendStreamFilter('string.toupper'); | ||
|
||
self::assertStringContainsString('JOHN', $csv->toString()); | ||
|
||
|
@@ -384,7 +384,7 @@ public function testClearAttachedStreamFilters(): void | |
public function testSetStreamFilterOnWriter(): void | ||
{ | ||
$csv = Writer::createFromPath(__DIR__.'/../test_files/newline.csv', 'w+'); | ||
$csv->addStreamFilter('string.toupper'); | ||
$csv->appendStreamFilter('string.toupper'); | ||
$csv->insertOne([1, 'two', 3, "new\r\nline"]); | ||
|
||
self::assertStringContainsString("1,TWO,3,\"NEW\r\nLINE\"", $csv->toString()); | ||
|
Oops, something went wrong.