1
1
<?php
2
-
2
+ // @codingStandardsIgnoreStart
3
3
/**
4
4
* @file
5
- *
6
5
* Unit Tests.
7
6
*/
8
7
@@ -49,9 +48,10 @@ class PHPLib_TextFile_TestCase extends DrupalUnitTestCase {
49
48
*/
50
49
public function test_EOL() {
51
50
$this->writeToFile("a|b\nc\r\nd");
52
- // Test UNIX
51
+ // Test UNIX.
53
52
$file = new TextFile(fopen($this->filename, 'rb'), TextFile::UNIX);
54
- $values = array(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE); // Includes EOF delimiter
53
+ $values = array(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE);
54
+ // Includes EOF delimiter.
55
55
$successful = TRUE;
56
56
foreach ($values as $value) {
57
57
if ($file->EOL() !== $value) {
@@ -62,9 +62,10 @@ class PHPLib_TextFile_TestCase extends DrupalUnitTestCase {
62
62
$file->seek(1, SEEK_CUR);
63
63
}
64
64
$this->assert($successful, "TextFile::EOL() correctly identified all Unix EOL.");
65
- // Test DOS
65
+ // Test DOS.
66
66
$file = new TextFile(fopen($this->filename, 'rb'), TextFile::DOS);
67
- $values = array(FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE); // Includes EOF delimiter
67
+ $values = array(FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE);
68
+ // Includes EOF delimiter.
68
69
$successful = TRUE;
69
70
foreach ($values as $value) {
70
71
if ($file->EOL() !== $value) {
@@ -75,9 +76,10 @@ class PHPLib_TextFile_TestCase extends DrupalUnitTestCase {
75
76
$file->seek(1, SEEK_CUR);
76
77
}
77
78
$this->assert($successful, "TextFile::EOL() correctly identified all DOS EOL.");
78
- // Test MAC
79
+ // Test MAC.
79
80
$file = new TextFile(fopen($this->filename, 'rb'), TextFile::MAC);
80
- $values = array(FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE); // Includes EOF delimiter
81
+ $values = array(FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE);
82
+ // Includes EOF delimiter.
81
83
$successful = TRUE;
82
84
foreach ($values as $value) {
83
85
if ($file->EOL() !== $value) {
@@ -88,13 +90,15 @@ class PHPLib_TextFile_TestCase extends DrupalUnitTestCase {
88
90
$file->seek(1, SEEK_CUR);
89
91
}
90
92
$this->assert($successful, "TextFile::EOL() correctly identified all MAC EOL.");
91
- unset($file); // Destroy the reference to the file.
93
+ unset($file);
94
+ // Destroy the reference to the file.
92
95
}
93
96
94
97
public function test_seekBeforeEOL() {
95
98
$content = "a|b\nc\r\nd";
96
99
$this->writeToFile($content);
97
- $values = array(0, 1, 2, 2, 4, 5, 5, 7, 7); // Includes EOF delimiter
100
+ $values = array(0, 1, 2, 2, 4, 5, 5, 7, 7);
101
+ // Includes EOF delimiter.
98
102
$file = new TextFile(fopen($this->filename, 'rb'));
99
103
$successful = TRUE;
100
104
for ($i = 0; $i < strlen($content); $i++) {
@@ -109,13 +113,15 @@ class PHPLib_TextFile_TestCase extends DrupalUnitTestCase {
109
113
}
110
114
}
111
115
$this->assert($successful, "TextFile::seekBeforeEOL() correctly moved pointer to before all EOL.");
112
- unset($file); // Destroy the reference to the file.
116
+ unset($file);
117
+ // Destroy the reference to the file.
113
118
}
114
119
115
120
public function test_seekAfterEOL() {
116
121
$content = "a|b\nc\r\nd";
117
122
$this->writeToFile($content);
118
- $values = array(0, 1, 2, 4, 4, 5, 7, 7, 7); // Includes EOF delimiter
123
+ $values = array(0, 1, 2, 4, 4, 5, 7, 7, 7);
124
+ // Includes EOF delimiter.
119
125
$file = new TextFile(fopen($this->filename, 'rb'));
120
126
$successful = TRUE;
121
127
for ($i = 0; $i < strlen($content); $i++) {
@@ -130,13 +136,15 @@ class PHPLib_TextFile_TestCase extends DrupalUnitTestCase {
130
136
}
131
137
}
132
138
$this->assert($successful, "TextFile::seekAfterEOL() Correctly moved pointer to after all EOL.");
133
- unset($file); // Destroy the reference to the file.
139
+ unset($file);
140
+ // Destroy the reference to the file.
134
141
}
135
142
136
143
public function test_seekLineStart() {
137
144
$content = "a|b\nc\r\nd";
138
145
$this->writeToFile($content);
139
- $values = array(0, 0, 0, 0, 4, 4, 4, 7, 7); // Includes EOF delimiter
146
+ $values = array(0, 0, 0, 0, 4, 4, 4, 7, 7);
147
+ // Includes EOF delimiter.
140
148
$file = new TextFile(fopen($this->filename, 'rb'));
141
149
$successful = TRUE;
142
150
for ($i = 0; $i < strlen($content); $i++) {
@@ -151,13 +159,15 @@ class PHPLib_TextFile_TestCase extends DrupalUnitTestCase {
151
159
}
152
160
}
153
161
$this->assert($successful, "TextFile::seekLineStart() correctly moved pointer to the start of each line.");
154
- unset($file); // Destroy the reference to the file.
162
+ unset($file);
163
+ // Destroy the reference to the file.
155
164
}
156
165
157
166
public function test_seekLineEnd() {
158
167
$content = "a|b\nc\r\nd";
159
168
$this->writeToFile($content);
160
- $values = array(3, 3, 3, 3, 6, 6, 6, 8, 8); // Includes EOF delimiter
169
+ $values = array(3, 3, 3, 3, 6, 6, 6, 8, 8);
170
+ // Includes EOF delimiter.
161
171
$file = new TextFile(fopen($this->filename, 'rb'));
162
172
$successful = TRUE;
163
173
for ($i = 0; $i < strlen($content); $i++) {
@@ -172,13 +182,15 @@ class PHPLib_TextFile_TestCase extends DrupalUnitTestCase {
172
182
}
173
183
}
174
184
$this->assert($successful, "TextFile::seekLineEnd() correctly moved pointer to after all EOL.");
175
- unset($file); // Destroy the reference to the file.
185
+ unset($file);
186
+ // Destroy the reference to the file.
176
187
}
177
188
178
189
public function test_seekPrevLineEnd() {
179
190
$content = "a|b\nc\r\nd";
180
191
$this->writeToFile($content);
181
- $values = array(3, 3, 3, 3, 6, 6, 6, 8, 8); // Includes EOF delimiter
192
+ $values = array(3, 3, 3, 3, 6, 6, 6, 8, 8);
193
+ // Includes EOF delimiter.
182
194
$file = new TextFile(fopen($this->filename, 'rb'));
183
195
$successful = TRUE;
184
196
for ($i = 0; $i < strlen($content); $i++) {
@@ -193,7 +205,9 @@ class PHPLib_TextFile_TestCase extends DrupalUnitTestCase {
193
205
}
194
206
}
195
207
$this->assert($successful, "TextFile::seekLineEnd() correctly moved pointer to after all EOL.");
196
- unset($file); // Destroy the reference to the file.
208
+ unset($file);
209
+ // Destroy the reference to the file.
197
210
}
198
211
199
212
}
213
+ // @codingStandardsIgnoreStart
0 commit comments