|
64 | 64 | $writer->write('test guidelines content'); |
65 | 65 |
|
66 | 66 | $content = file_get_contents($tempFile); |
67 | | - expect($content)->toBe("<laravel-boost-guidelines>\ntest guidelines content\n</laravel-boost-guidelines>\n"); |
| 67 | + expect($content)->toBe("<laravel-boost-guidelines>\ntest guidelines content\n\n</laravel-boost-guidelines>\n"); |
68 | 68 |
|
69 | 69 | unlink($tempFile); |
70 | 70 | }); |
|
82 | 82 | $writer->write('new guidelines'); |
83 | 83 |
|
84 | 84 | $content = file_get_contents($tempFile); |
85 | | - expect($content)->toBe("# Existing content\n\nSome text here.\n\n===\n\n<laravel-boost-guidelines>\nnew guidelines\n</laravel-boost-guidelines>\n"); |
| 85 | + expect($content)->toBe("# Existing content\n\nSome text here.\n\n===\n\n<laravel-boost-guidelines>\nnew guidelines\n\n</laravel-boost-guidelines>\n"); |
86 | 86 |
|
87 | 87 | unlink($tempFile); |
88 | 88 | }); |
|
101 | 101 | $writer->write('updated guidelines'); |
102 | 102 |
|
103 | 103 | $content = file_get_contents($tempFile); |
104 | | - expect($content)->toBe("# Header\n\n<laravel-boost-guidelines>\nupdated guidelines\n</laravel-boost-guidelines>\n\n# Footer\n"); |
| 104 | + expect($content)->toBe("# Header\n\n<laravel-boost-guidelines>\nupdated guidelines\n\n</laravel-boost-guidelines>\n\n# Footer\n"); |
105 | 105 |
|
106 | 106 | unlink($tempFile); |
107 | 107 | }); |
|
120 | 120 | $writer->write('updated guidelines'); |
121 | 121 |
|
122 | 122 | $content = file_get_contents($tempFile); |
123 | | - expect($content)->toBe("# Header\n\n<laravel-boost-guidelines>\nupdated guidelines\n</laravel-boost-guidelines>\n\n# Footer\n"); |
| 123 | + expect($content)->toBe("# Header\n\n<laravel-boost-guidelines>\nupdated guidelines\n\n</laravel-boost-guidelines>\n\n# Footer\n"); |
124 | 124 |
|
125 | 125 | // Assert no double newline at the end |
126 | 126 | expect(substr($content, -2))->not->toBe("\n\n"); |
|
145 | 145 |
|
146 | 146 | $content = file_get_contents($tempFile); |
147 | 147 | // Should replace in-place, preserving structure |
148 | | - expect($content)->toBe("Start\n<laravel-boost-guidelines>\nsingle line\n</laravel-boost-guidelines>\nEnd\n"); |
| 148 | + expect($content)->toBe("Start\n<laravel-boost-guidelines>\nsingle line\n\n</laravel-boost-guidelines>\nEnd\n"); |
149 | 149 |
|
150 | 150 | unlink($tempFile); |
151 | 151 | }); |
|
165 | 165 |
|
166 | 166 | $content = file_get_contents($tempFile); |
167 | 167 | // Should replace first occurrence, second block remains untouched due to non-greedy matching |
168 | | - expect($content)->toBe("Start\n<laravel-boost-guidelines>\nreplacement\n</laravel-boost-guidelines>\nMiddle\n<laravel-boost-guidelines>\nsecond\n</laravel-boost-guidelines>\nEnd\n"); |
| 168 | + expect($content)->toBe("Start\n<laravel-boost-guidelines>\nreplacement\n\n</laravel-boost-guidelines>\nMiddle\n<laravel-boost-guidelines>\nsecond\n</laravel-boost-guidelines>\nEnd\n"); |
169 | 169 |
|
170 | 170 | unlink($tempFile); |
171 | 171 | }); |
|
199 | 199 | $writer->write('my guidelines'); |
200 | 200 |
|
201 | 201 | $content = file_get_contents($tempFile); |
202 | | - expect($content)->toBe("# Title\n\nParagraph 1\n\nParagraph 2\n\n===\n\n<laravel-boost-guidelines>\nmy guidelines\n</laravel-boost-guidelines>\n"); |
| 202 | + expect($content)->toBe("# Title\n\nParagraph 1\n\nParagraph 2\n\n===\n\n<laravel-boost-guidelines>\nmy guidelines\n\n</laravel-boost-guidelines>\n"); |
203 | 203 |
|
204 | 204 | unlink($tempFile); |
205 | 205 | }); |
|
217 | 217 | $writer->write('first guidelines'); |
218 | 218 |
|
219 | 219 | $content = file_get_contents($tempFile); |
220 | | - expect($content)->toBe("<laravel-boost-guidelines>\nfirst guidelines\n</laravel-boost-guidelines>\n"); |
| 220 | + expect($content)->toBe("<laravel-boost-guidelines>\nfirst guidelines\n\n</laravel-boost-guidelines>\n"); |
221 | 221 |
|
222 | 222 | unlink($tempFile); |
223 | 223 | }); |
|
235 | 235 | $writer->write('clean guidelines'); |
236 | 236 |
|
237 | 237 | $content = file_get_contents($tempFile); |
238 | | - expect($content)->toBe("<laravel-boost-guidelines>\nclean guidelines\n</laravel-boost-guidelines>\n"); |
| 238 | + expect($content)->toBe("<laravel-boost-guidelines>\nclean guidelines\n\n</laravel-boost-guidelines>\n"); |
239 | 239 |
|
240 | 240 | unlink($tempFile); |
241 | 241 | }); |
|
255 | 255 |
|
256 | 256 | expect($result)->toBe(GuidelineWriter::REPLACED); |
257 | 257 | $content = file_get_contents($tempFile); |
258 | | - expect($content)->toBe("# Title\n\n<other-rules>\nShould not be touched\n</other-rules>\n\n<laravel-boost-guidelines>\nnew guidelines\n</laravel-boost-guidelines>\n\n<custom-config>\nAlso untouched\n</custom-config>\n"); |
| 258 | + expect($content)->toBe("# Title\n\n<other-rules>\nShould not be touched\n</other-rules>\n\n<laravel-boost-guidelines>\nnew guidelines\n\n</laravel-boost-guidelines>\n\n<custom-config>\nAlso untouched\n</custom-config>\n"); |
259 | 259 |
|
260 | 260 | unlink($tempFile); |
261 | 261 | }); |
|
288 | 288 | ); |
289 | 289 |
|
290 | 290 | // Verify exact structure |
291 | | - expect($content)->toBe("# My Project\n\n<laravel-boost-guidelines>\nupdated guidelines from boost\n</laravel-boost-guidelines>\n\n# User Added Section\nThis content was added by the user after the guidelines.\n\n## Another user section\nMore content here.\n"); |
| 291 | + expect($content)->toBe("# My Project\n\n<laravel-boost-guidelines>\nupdated guidelines from boost\n\n</laravel-boost-guidelines>\n\n# User Added Section\nThis content was added by the user after the guidelines.\n\n## Another user section\nMore content here.\n"); |
292 | 292 |
|
293 | 293 | unlink($tempFile); |
294 | 294 | }); |
|
310 | 310 | $writer->write('new guidelines'); |
311 | 311 |
|
312 | 312 | $content = file_get_contents($tempFile); |
313 | | - expect($content)->toBe("---\nalwaysApply: true\n---\n# Existing content\n\nSome text here.\n\n===\n\n<laravel-boost-guidelines>\nnew guidelines\n</laravel-boost-guidelines>\n"); |
| 313 | + expect($content)->toBe("---\nalwaysApply: true\n---\n# Existing content\n\nSome text here.\n\n===\n\n<laravel-boost-guidelines>\nnew guidelines\n\n</laravel-boost-guidelines>\n"); |
314 | 314 |
|
315 | 315 | unlink($tempFile); |
316 | 316 | }); |
|
328 | 328 | $writer->write('new guidelines'); |
329 | 329 |
|
330 | 330 | $content = file_get_contents($tempFile); |
331 | | - expect($content)->toBe("---\ncustomOption: true\n---\n# Existing content\n\nSome text here.\n\n===\n\n<laravel-boost-guidelines>\nnew guidelines\n</laravel-boost-guidelines>\n"); |
| 331 | + expect($content)->toBe("---\ncustomOption: true\n---\n# Existing content\n\nSome text here.\n\n===\n\n<laravel-boost-guidelines>\nnew guidelines\n\n</laravel-boost-guidelines>\n"); |
332 | 332 |
|
333 | 333 | unlink($tempFile); |
334 | 334 | }); |
|
347 | 347 |
|
348 | 348 | expect($result)->toBe(GuidelineWriter::NEW); |
349 | 349 | $content = file_get_contents($tempFile); |
350 | | - expect($content)->toBe("# Existing content\n\nSome text here.\n\n===\n\n<laravel-boost-guidelines>\nnew guidelines\n</laravel-boost-guidelines>\n"); |
| 350 | + expect($content)->toBe("# Existing content\n\nSome text here.\n\n===\n\n<laravel-boost-guidelines>\nnew guidelines\n\n</laravel-boost-guidelines>\n"); |
351 | 351 |
|
352 | 352 | unlink($tempFile); |
353 | 353 | }); |
0 commit comments