PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / rosell-dk / exec-with-fallback / tests / LineSplittingTest.php

LineSplittingTest.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/rosell-dk/exec-with-fallback/tests/LineSplittingTest.php

52 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ExecWithFallback\Tests;
3
4 use PHPUnit\Framework\TestCase;
5
6 class LineSplittingTest extends TestCase
7 {
8
9 public function splitLines($text)
10 {
11 //return preg_split('/\r\n|\r|\n/', $text);
12 //return preg_split("/\\n\\r|\\r\\n|\\n|\\r/", $text);
13 //return preg_split('/\n\r|\r\n|\n|\r/', $text);
14 return preg_split('/\r\n|\n\r|\n|\r/', $text);
15 }
16
17 public function splitLinesNoEmpty($text)
18 {
19 //return preg_split('/\r\n|\r|\n/', $text);
20 //return preg_split("/\\n\\r|\\r\\n|\\n|\\r/", $text);
21 //return preg_split('/\n\r|\r\n|\n|\r/', $text);
22 return preg_split('/[\r\n]+/', $text);
23 }
24
25
26 public function testLineSplitting()
27 {
28 $this->assertEquals(['one', 'two', 'three'], $this->splitLines("one\r\ntwo\r\nthree"));
29 $this->assertEquals(['one', 'two', 'three'], $this->splitLines("one\ntwo\nthree"));
30 $this->assertEquals(['one', 'two', 'three'], $this->splitLines("one\rtwo\rthree"));
31 $this->assertEquals(['one', '', 'two', 'three'], $this->splitLines("one\n\ntwo\nthree"));
32 $this->assertEquals(['one', '', 'two', '', 'three'], $this->splitLines("one\r\n\ntwo\n\r\nthree"));
33
34 // the unusual \n\r sequence
35 $this->assertEquals(['one', 'two', 'three'], $this->splitLines("one\n\rtwo\n\rthree"));
36 $this->assertEquals(['one', '', 'two', '', 'three'], $this->splitLines("one\n\r\ntwo\n\n\rthree"));
37 }
38
39 public function testLineSplittingNoEmpty()
40 {
41 $this->assertEquals(['one', 'two', 'three'], $this->splitLinesNoEmpty("one\r\ntwo\r\nthree"));
42 $this->assertEquals(['one', 'two', 'three'], $this->splitLinesNoEmpty("one\ntwo\nthree"));
43 $this->assertEquals(['one', 'two', 'three'], $this->splitLinesNoEmpty("one\rtwo\rthree"));
44 $this->assertEquals(['one', 'two', 'three'], $this->splitLinesNoEmpty("one\n\ntwo\nthree"));
45 $this->assertEquals(['one', 'two', 'three'], $this->splitLinesNoEmpty("one\r\n\ntwo\n\r\nthree"));
46
47 // the unusual \n\r sequence
48 $this->assertEquals(['one', 'two', 'three'], $this->splitLinesNoEmpty("one\n\rtwo\n\rthree"));
49 $this->assertEquals(['one', 'two', 'three'], $this->splitLinesNoEmpty("one\n\r\ntwo\n\n\rthree"));
50 }
51 }
52