Repository: prettier/plugin-php
Pull request #714 (2018-10-03 11:29:36)

test: require pragma with CRLF
Looks all fine, just tests

evilebottnawi: Feel free to feedback

Patch:
diff --git a/.gitattributes b/.gitattributes
index 47c3a7c..765db9d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,6 @@
 tests/newline/CRLF.php text eol=crlf
 tests/newline/html-CRLF.php text eol=crlf
 tests/newline/mixed-CRLF.php text eol=crlf
+tests/require-pragma/file-with-alt-pragma-CRLF.php text eol=crlf
+tests/require-pragma/file-with-pragma-CRLF.php text eol=crlf
+tests/require-pragma/file-without-pragma-CRLF.php text eol=crlf


Test patch:
diff --git a/tests/require-pragma/__snapshots__/jsfmt.spec.js.snap b/tests/require-pragma/__snapshots__/jsfmt.spec.js.snap
index 2bcae10..e4465f5 100644
--- a/tests/require-pragma/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/require-pragma/__snapshots__/jsfmt.spec.js.snap
@@ -1,6 +1,6 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
-exports[`file-with-alt-pragma.php - php-verify: file-with-alt-pragma.php 1`] = `
+exports[`file-with-alt-pragma-CRLF.php - php-verify: file-with-alt-pragma-CRLF.php 1`] = `
 <?php
 /**
  * This works too
@@ -31,7 +31,69 @@ echo 'This ' .
 
 `;
 
-exports[`file-with-pragma.php - php-verify: file-with-pragma.php 1`] = `
+exports[`file-with-alt-pragma-LF.php - php-verify: file-with-alt-pragma-LF.php 1`] = `
+<?php
+/**
+ * This works too
+ *
+ * @prettier
+ */
+
+echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\\n";
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<?php
+/**
+ * This works too
+ *
+ * @prettier
+ */
+
+echo 'This ' .
+    'string ' .
+    'was ' .
+    'made ' .
+    'with concatenation.' .
+    'This ' .
+    'string ' .
+    'was ' .
+    'made ' .
+    'with concatenation.' .
+    "\\n";
+
+`;
+
+exports[`file-with-pragma-CRLF.php - php-verify: file-with-pragma-CRLF.php 1`] = `
+<?php
+/**
+ * This turns on prettier formatting if --require-pragma is passed
+ *
+ * @format
+ */
+
+echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\\n";
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<?php
+/**
+ * This turns on prettier formatting if --require-pragma is passed
+ *
+ * @format
+ */
+
+echo 'This ' .
+    'string ' .
+    'was ' .
+    'made ' .
+    'with concatenation.' .
+    'This ' .
+    'string ' .
+    'was ' .
+    'made ' .
+    'with concatenation.' .
+    "\\n";
+
+`;
+
+exports[`file-with-pragma-LF.php - php-verify: file-with-pragma-LF.php 1`] = `
 <?php
 /**
  * This turns on prettier formatting if --require-pragma is passed
@@ -62,7 +124,24 @@ echo 'This ' .
 
 `;
 
-exports[`file-without-pragma.php - php-verify: file-without-pragma.php 1`] = `
+exports[`file-without-pragma-CRLF.php - php-verify: file-without-pragma-CRLF.php 1`] = `
+<?php
+/**
+ * No pragma, no prettier (assuming --require-pragma)
+ */
+
+echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\\n";
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<?php
+/**
+ * No pragma, no prettier (assuming --require-pragma)
+ */
+
+echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\\n";
+
+`;
+
+exports[`file-without-pragma-LF.php - php-verify: file-without-pragma-LF.php 1`] = `
 <?php
 /**
  * No pragma, no prettier (assuming --require-pragma)
diff --git a/tests/require-pragma/file-with-alt-pragma.php b/tests/require-pragma/file-with-alt-pragma-CRLF.php
similarity index 100%
rename from tests/require-pragma/file-with-alt-pragma.php
rename to tests/require-pragma/file-with-alt-pragma-CRLF.php
diff --git a/tests/require-pragma/file-with-alt-pragma-LF.php b/tests/require-pragma/file-with-alt-pragma-LF.php
new file mode 100644
index 0000000..8095d34
--- /dev/null
+++ b/tests/require-pragma/file-with-alt-pragma-LF.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * This works too
+ *
+ * @prettier
+ */
+
+echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n";
diff --git a/tests/require-pragma/file-with-pragma.php b/tests/require-pragma/file-with-pragma-CRLF.php
similarity index 100%
rename from tests/require-pragma/file-with-pragma.php
rename to tests/require-pragma/file-with-pragma-CRLF.php
diff --git a/tests/require-pragma/file-with-pragma-LF.php b/tests/require-pragma/file-with-pragma-LF.php
new file mode 100644
index 0000000..07f5c99
--- /dev/null
+++ b/tests/require-pragma/file-with-pragma-LF.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * This turns on prettier formatting if --require-pragma is passed
+ *
+ * @format
+ */
+
+echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n";
diff --git a/tests/require-pragma/file-without-pragma.php b/tests/require-pragma/file-without-pragma-CRLF.php
similarity index 100%
rename from tests/require-pragma/file-without-pragma.php
rename to tests/require-pragma/file-without-pragma-CRLF.php
diff --git a/tests/require-pragma/file-without-pragma-LF.php b/tests/require-pragma/file-without-pragma-LF.php
new file mode 100644
index 0000000..1256b82
--- /dev/null
+++ b/tests/require-pragma/file-without-pragma-LF.php
@@ -0,0 +1,6 @@
+<?php
+/**
+ * No pragma, no prettier (assuming --require-pragma)
+ */
+
+echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n";
diff --git a/tests/require-pragma/jsfmt.spec.js b/tests/require-pragma/jsfmt.spec.js
index f2b5512..45ec6fc 100644
--- a/tests/require-pragma/jsfmt.spec.js
+++ b/tests/require-pragma/jsfmt.spec.js
@@ -1,1 +1,1 @@
-run_spec(__dirname, ["php"], { requirePragma: true });
+run_spec(__dirname, ["php"], { requirePragma: true, keepEOL: true });