diff --git a/composer.json b/composer.json
index fe89f1a..4bb7262 100644
--- a/composer.json
+++ b/composer.json
@@ -50,7 +50,8 @@
"psr-4": {
"Inpsyde\\CodingStandard\\Tests\\": [
"tests/src/",
- "tests/cases/"
+ "tests/cases/",
+ "tests/e2e/"
]
}
},
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 826c5fa..0be95d0 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -16,5 +16,8 @@
tests/cases/Helpers
+
+ tests/e2e/E2eTest.php
+
diff --git a/tests/e2e/E2eTest.php b/tests/e2e/E2eTest.php
new file mode 100644
index 0000000..9c1d8b5
--- /dev/null
+++ b/tests/e2e/E2eTest.php
@@ -0,0 +1,97 @@
+testPackagePath = $libPath . '/tests/e2e/test-package';
+ $this->phpCsBinary = $libPath . '/vendor/bin/phpcs';
+ }
+
+ public function testInpsydeAndTemplatesRulesets(): void
+ {
+ $output = [];
+ exec(
+ sprintf(
+ 'cd %s && %s',
+ $this->testPackagePath,
+ $this->phpCsBinary
+ ),
+ $output
+ );
+
+ /** @var array $output> */
+ if ($output[0] !== 'EE 2 / 2 (100%)') {
+ throw new RuntimeException(implode("\n", $output));
+ }
+
+ $json = end($output);
+
+ self::assertSame([
+ 'index.php' => [
+ [
+ 'source' => 'Inpsyde.CodeQuality.NoElse.ElseFound',
+ 'line' => 12,
+ ],
+ [
+ 'source' => 'WordPress.Security.EscapeOutput.OutputNotEscaped',
+ 'line' => 13,
+ ],
+ ],
+ 'template.php' => [
+
+ [
+ 'source' => 'WordPress.Security.EscapeOutput.OutputNotEscaped',
+ 'line' => 12,
+ ],
+ [
+ 'source' => 'InpsydeTemplates.Formatting.TrailingSemicolon.Found',
+ 'line' => 12,
+ ],
+ [
+ 'source' => 'Inpsyde.CodeQuality.DisableCallUserFunc.call_user_func_call_user_func',
+ 'line' => 15,
+ ],
+
+ ],
+ ], $this->phpCsNormalizedOutput($json));
+ }
+
+ /**
+ * @psalm-return array>
+ */
+ private function phpCsNormalizedOutput(string $json): array
+ {
+ /** @var array{
+ * files: array
+ * }>
+ * } $data */
+ $data = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
+
+ $result = [];
+ foreach ($data['files'] as $fileName => $fileData) {
+ $baseName = basename($fileName);
+ $result[$baseName] = [];
+ foreach ($fileData['messages'] as ['source' => $source, 'line' => $line]) {
+ $result[$baseName][] = ['source' => $source, 'line' => $line];
+ }
+ }
+
+ return $result;
+ }
+}
diff --git a/tests/e2e/test-package/index.php b/tests/e2e/test-package/index.php
new file mode 100644
index 0000000..9193c39
--- /dev/null
+++ b/tests/e2e/test-package/index.php
@@ -0,0 +1,14 @@
+ 0.5) {
+ echo esc_html($successMessage);
+} else {
+ echo $errorMessage;
+}
diff --git a/tests/e2e/test-package/phpcs.xml b/tests/e2e/test-package/phpcs.xml
new file mode 100644
index 0000000..70eccce
--- /dev/null
+++ b/tests/e2e/test-package/phpcs.xml
@@ -0,0 +1,20 @@
+
+
+
+ ./index.php
+ ./templates
+
+
+
+
+
+
+
+ */templates/*
+
+
+
+ */templates/*
+
+
+
diff --git a/tests/e2e/test-package/templates/template.php b/tests/e2e/test-package/templates/template.php
new file mode 100644
index 0000000..2ebddc0
--- /dev/null
+++ b/tests/e2e/test-package/templates/template.php
@@ -0,0 +1,15 @@
+
+
+ 0.5) : ?>
+ = esc_html($successMessage) ?>
+
+ = $errorMessage; ?>
+