@@ -257,31 +257,52 @@ public function testEncodeFormulas()
257
257
258
258
$ this ->assertSame (<<<'CSV'
259
259
0
260
- " =2+3"
260
+ ' =2+3
261
261
262
262
CSV
263
263
, $ this ->encoder ->encode (['=2+3 ' ], 'csv ' ));
264
264
265
265
$ this ->assertSame (<<<'CSV'
266
266
0
267
- " -2+3"
267
+ ' -2+3
268
268
269
269
CSV
270
270
, $ this ->encoder ->encode (['-2+3 ' ], 'csv ' ));
271
271
272
272
$ this ->assertSame (<<<'CSV'
273
273
0
274
- " +2+3"
274
+ ' +2+3
275
275
276
276
CSV
277
277
, $ this ->encoder ->encode (['+2+3 ' ], 'csv ' ));
278
278
279
279
$ this ->assertSame (<<<'CSV'
280
280
0
281
- " @MyDataColumn"
281
+ ' @MyDataColumn
282
282
283
283
CSV
284
284
, $ this ->encoder ->encode (['@MyDataColumn ' ], 'csv ' ));
285
+
286
+ $ this ->assertSame (<<<'CSV'
287
+ 0
288
+ "' tab"
289
+
290
+ CSV
291
+ , $ this ->encoder ->encode (["\ttab " ], 'csv ' ));
292
+
293
+ $ this ->assertSame (<<<'CSV'
294
+ 0
295
+ "'=1+2"";=1+2"
296
+
297
+ CSV
298
+ , $ this ->encoder ->encode (['=1+2";=1+2 ' ], 'csv ' ));
299
+
300
+ $ this ->assertSame (<<<'CSV'
301
+ 0
302
+ "'=1+2'"" ;,=1+2"
303
+
304
+ CSV
305
+ , $ this ->encoder ->encode (['=1+2 \'" ;,=1+2 ' ], 'csv ' ));
285
306
}
286
307
287
308
public function testDoNotEncodeFormulas ()
@@ -313,13 +334,34 @@ public function testDoNotEncodeFormulas()
313
334
314
335
CSV
315
336
, $ this ->encoder ->encode (['@MyDataColumn ' ], 'csv ' ));
337
+
338
+ $ this ->assertSame (<<<'CSV'
339
+ 0
340
+ " tab"
341
+
342
+ CSV
343
+ , $ this ->encoder ->encode (["\ttab " ], 'csv ' ));
344
+
345
+ $ this ->assertSame (<<<'CSV'
346
+ 0
347
+ "=1+2"";=1+2"
348
+
349
+ CSV
350
+ , $ this ->encoder ->encode (['=1+2";=1+2 ' ], 'csv ' ));
351
+
352
+ $ this ->assertSame (<<<'CSV'
353
+ 0
354
+ "=1+2'"" ;,=1+2"
355
+
356
+ CSV
357
+ , $ this ->encoder ->encode (['=1+2 \'" ;,=1+2 ' ], 'csv ' ));
316
358
}
317
359
318
360
public function testEncodeFormulasWithSettingsPassedInContext ()
319
361
{
320
362
$ this ->assertSame (<<<'CSV'
321
363
0
322
- " =2+3"
364
+ ' =2+3
323
365
324
366
CSV
325
367
, $ this ->encoder ->encode (['=2+3 ' ], 'csv ' , [
@@ -328,7 +370,7 @@ public function testEncodeFormulasWithSettingsPassedInContext()
328
370
329
371
$ this ->assertSame (<<<'CSV'
330
372
0
331
- " -2+3"
373
+ ' -2+3
332
374
333
375
CSV
334
376
, $ this ->encoder ->encode (['-2+3 ' ], 'csv ' , [
@@ -337,7 +379,7 @@ public function testEncodeFormulasWithSettingsPassedInContext()
337
379
338
380
$ this ->assertSame (<<<'CSV'
339
381
0
340
- " +2+3"
382
+ ' +2+3
341
383
342
384
CSV
343
385
, $ this ->encoder ->encode (['+2+3 ' ], 'csv ' , [
@@ -346,12 +388,39 @@ public function testEncodeFormulasWithSettingsPassedInContext()
346
388
347
389
$ this ->assertSame (<<<'CSV'
348
390
0
349
- " @MyDataColumn"
391
+ ' @MyDataColumn
350
392
351
393
CSV
352
394
, $ this ->encoder ->encode (['@MyDataColumn ' ], 'csv ' , [
353
395
CsvEncoder::ESCAPE_FORMULAS_KEY => true ,
354
396
]));
397
+
398
+ $ this ->assertSame (<<<'CSV'
399
+ 0
400
+ "' tab"
401
+
402
+ CSV
403
+ , $ this ->encoder ->encode (["\ttab " ], 'csv ' , [
404
+ CsvEncoder::ESCAPE_FORMULAS_KEY => true ,
405
+ ]));
406
+
407
+ $ this ->assertSame (<<<'CSV'
408
+ 0
409
+ "'=1+2"";=1+2"
410
+
411
+ CSV
412
+ , $ this ->encoder ->encode (['=1+2";=1+2 ' ], 'csv ' , [
413
+ CsvEncoder::ESCAPE_FORMULAS_KEY => true ,
414
+ ]));
415
+
416
+ $ this ->assertSame (<<<'CSV'
417
+ 0
418
+ "'=1+2'"" ;,=1+2"
419
+
420
+ CSV
421
+ , $ this ->encoder ->encode (['=1+2 \'" ;,=1+2 ' ], 'csv ' , [
422
+ CsvEncoder::ESCAPE_FORMULAS_KEY => true ,
423
+ ]));
355
424
}
356
425
357
426
public function testEncodeWithoutHeader ()
0 commit comments