From da53f30ceed0c39d8a36143f25d1bc9c805f9f7c Mon Sep 17 00:00:00 2001
From: David Buchmann <david.buchmann@liip.ch>
Date: Sat, 30 Apr 2016 09:49:53 +0200
Subject: [PATCH] reproduce encoding bug with ischildnode query paths

---
 fixtures/06_Query/characters.xml | 19 +++++++++++++++++++
 tests/Query/CharacterTest.php    | 18 ++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/fixtures/06_Query/characters.xml b/fixtures/06_Query/characters.xml
index 5fd5f796..a5448d43 100644
--- a/fixtures/06_Query/characters.xml
+++ b/fixtures/06_Query/characters.xml
@@ -65,4 +65,23 @@
             </sv:node>
         </sv:node>
     </sv:node>
+
+    <sv:node sv:name="test-2e">
+        <sv:property sv:name="jcr:primaryType" sv:type="Name">
+            <sv:value>nt:unstructured</sv:value>
+        </sv:property>
+
+        <sv:node sv:name="child">
+            <sv:property sv:name="jcr:primaryType" sv:type="Name">
+                <sv:value>nt:unstructured</sv:value>
+            </sv:property>
+
+            <sv:property sv:name="jcr:mixinTypes" sv:type="Name">
+                <sv:value>mix:referenceable</sv:value>
+            </sv:property>
+            <sv:property sv:name="jcr:uuid" sv:type="String">
+                <sv:value>123e61c0-09ab-42a9-87c0-123ccc90e6f4</sv:value>
+            </sv:property>
+        </sv:node>
+    </sv:node>
 </sv:node>
diff --git a/tests/Query/CharacterTest.php b/tests/Query/CharacterTest.php
index 9ab20423..22b662d5 100644
--- a/tests/Query/CharacterTest.php
+++ b/tests/Query/CharacterTest.php
@@ -138,4 +138,22 @@ public function testQueryWithAmpersand()
         $this->assertCount(1, $rows);
         $this->assertEquals('foo & bar&baz', $rows->current()->getValue('ampersand'));
     }
+
+    public function testNodeNameWithMinus()
+    {
+        /** @var QueryManagerInterface $queryManager */
+        $queryManager = $this->sharedFixture['qm'];
+        $query = $queryManager->createQuery('
+            SELECT node.[jcr:uuid] AS uuid
+            FROM [nt:unstructured] AS node
+            WHERE ISCHILDNODE(node, [/tests_query_encoding/test-2e])',
+            QueryInterface::JCR_SQL2
+        );
+
+        $result = $query->execute();
+
+        $rows = $result->getRows();
+        $this->assertCount(1, $rows);
+        $this->assertEquals('PHPCR\Query\QueryInterface', $rows->current()->getValue('class'));
+    }
 }