tests/WriterTest.php
/**
     * @testdox Test to write 100,000 Records into CSV and read them
     * @covers ::writeRecordsToCsv
     * @throws CsvException
     */
@testdox Test to write 100,000 Records into CSV and read them
@covers ::writeRecordsToCsv
@throws CsvException
@testdox Test to write 100 000 Records into CSV and read them @covers :: writeRecordsToCsv @throws CsvException
public function testWriteMassiveCsvData(): void
    {
        $faker = Factory::create('de_DE');
        $records = [
            [
                'id',
                'name',
                'firstname',
                'street',
                'city'
            ],
        ];
        for ($i = 0; $i < 100000; $i++) {
            $records[] = [
                'id' => mt_rand(0, 200),
                'name' => $faker->name,
                'firstname' => $faker->firstName,
                'street' => $faker->streetAddress,
                'city' => $faker->city,
            ];
        }
        $this->assertCount(100001, $records);
        $start = microtime(true);
        $writer = new Writer(__DIR__);
        $this->assertFileExists($writer->getTempCsvFilePath());
        $writer->setHeader(array_shift($records));
        $writer->writeRecordsToCsv($records);
        $end = microtime(true);
        $runtime = $end - $start;
        $this->assertTrue(
            5 > $runtime,
            'The massive CSV Data Writing must be faster then 5 sek. (Runtime: %.2f)'
        );
        $this->generatedFiles[] = ($csvFilePath = $writer->getCsvFilePath());
        $this->assertFileExists($csvFilePath);
    }
public function testWriteMassiveCsvData ( ) : void { $ faker = Factory :: create ( 'de_DE' ) ; $ records = [ [ 'id' , 'name' , 'firstname' , 'street' , 'city' ] , ] ; for ( $ i = 0 ; $ i < 100000 ; $ i ++ ) { $ records [ ] = [ 'id' => mt_rand ( 0 , 200 ) , 'name' => $ faker -> name , 'firstname' => $ faker -> firstName , 'street' => $ faker -> streetAddress , 'city' => $ faker -> city , ] ; } $ this -> assertCount ( 100001 , $ records ) ; $ start = microtime ( true ) ; $ writer = new Writer ( __DIR__ ) ; $ this -> assertFileExists ( $ writer -> getTempCsvFilePath ( ) ) ; $ writer -> setHeader ( array_shift ( $ records ) ) ; $ writer -> writeRecordsToCsv ( $ records ) ; $ end = microtime ( true ) ; $ runtime = $ end - $ start ; $ this -> assertTrue ( 5 > $ runtime , 'The massive CSV Data Writing must be faster then 5 sek. (Runtime: %.2f)' ) ; $ this -> generatedFiles [ ] = ( $ csvFilePath = $ writer -> getCsvFilePath ( ) ) ; $ this -> assertFileExists ( $ csvFilePath ) ; }
@testdox Test to write 100,000 Records into CSV and read them
 @covers ::writeRecordsToCsv
 @throws CsvException
@testdox Test to write 100 000 Records into CSV and read them @covers :: writeRecordsToCsv @throws CsvException