From c8840a5712d9810602741f833d9fc312c09b01f7 Mon Sep 17 00:00:00 2001 From: Willem-Jan Zijderveld Date: Sat, 9 Feb 2013 17:17:01 +0100 Subject: [PATCH 1/5] Added a multi-valued test. Failing for Jackaplope Doctrine Dbal transport --- fixtures/general/base.xml | 4 ++++ tests/06_Query/QuerySql2OperationsTest.php | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/fixtures/general/base.xml b/fixtures/general/base.xml index 0cb61cfd..b2eb3065 100644 --- a/fixtures/general/base.xml +++ b/fixtures/general/base.xml @@ -180,6 +180,10 @@ 14e18ef3-be20-4985-bee9-7bb4763b31de + + foo + bar + diff --git a/tests/06_Query/QuerySql2OperationsTest.php b/tests/06_Query/QuerySql2OperationsTest.php index 13acae83..b4cafb89 100644 --- a/tests/06_Query/QuerySql2OperationsTest.php +++ b/tests/06_Query/QuerySql2OperationsTest.php @@ -138,4 +138,26 @@ public function testQueryOrder() $this->assertEquals(array(null, null, null, null, null, null, null, 0), $vals); } + public function testQueryMultiValuedProperty() + { + /** @var $query \PHPCR\Query\QueryInterface */ + $query = $this->sharedFixture['qm']->createQuery( + 'SELECT data.tags + FROM [nt:folder] AS data + WHERE data.tags = "foo" + AND data.tags="bar" + ', + \PHPCR\Query\QueryInterface::JCR_SQL2 + ); + + $this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query); + $result = $query->execute(); + $this->assertInstanceOf('\PHPCR\Query\QueryResultInterface', $result); + + $rows = $result->getRows(); + + $this->assertSame(1, count($rows), 'Expected one row with both tags present'); + $this->assertSame(array('foo', 'bar'), $rows->current()->getValue('tags')); + } + } From 5a88ec084049880fe4dd10a502e3ae650a9dd227 Mon Sep 17 00:00:00 2001 From: Willem-Jan Zijderveld Date: Sat, 9 Feb 2013 21:08:34 +0100 Subject: [PATCH 2/5] Improved unittest + fixture --- fixtures/general/base.xml | 2 +- tests/06_Query/QuerySql2OperationsTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fixtures/general/base.xml b/fixtures/general/base.xml index b2eb3065..1cec4c90 100644 --- a/fixtures/general/base.xml +++ b/fixtures/general/base.xml @@ -180,7 +180,7 @@ 14e18ef3-be20-4985-bee9-7bb4763b31de - + foo bar diff --git a/tests/06_Query/QuerySql2OperationsTest.php b/tests/06_Query/QuerySql2OperationsTest.php index b4cafb89..1940c94b 100644 --- a/tests/06_Query/QuerySql2OperationsTest.php +++ b/tests/06_Query/QuerySql2OperationsTest.php @@ -145,7 +145,7 @@ public function testQueryMultiValuedProperty() 'SELECT data.tags FROM [nt:folder] AS data WHERE data.tags = "foo" - AND data.tags="bar" + AND data.tags = "bar" ', \PHPCR\Query\QueryInterface::JCR_SQL2 ); @@ -156,7 +156,7 @@ public function testQueryMultiValuedProperty() $rows = $result->getRows(); - $this->assertSame(1, count($rows), 'Expected one row with both tags present'); + $this->assertCount(1, $rows, 'Expected one row with both tags present'); $this->assertSame(array('foo', 'bar'), $rows->current()->getValue('tags')); } From 904e95ad94ea92abae19be5da4a4cc9d9d636a2f Mon Sep 17 00:00:00 2001 From: Willem-Jan Zijderveld Date: Sat, 9 Feb 2013 21:30:35 +0100 Subject: [PATCH 3/5] Moved tags property to a jcr:content node + fixed other tests for that change --- fixtures/general/base.xml | 14 ++++++++++---- tests/06_Query/QuerySql2OperationsTest.php | 8 ++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/fixtures/general/base.xml b/fixtures/general/base.xml index 1cec4c90..6e785bc4 100644 --- a/fixtures/general/base.xml +++ b/fixtures/general/base.xml @@ -180,10 +180,16 @@ 14e18ef3-be20-4985-bee9-7bb4763b31de - - foo - bar - + + + + nt:unstructured + + + foo + bar + + diff --git a/tests/06_Query/QuerySql2OperationsTest.php b/tests/06_Query/QuerySql2OperationsTest.php index 1940c94b..ac3fd719 100644 --- a/tests/06_Query/QuerySql2OperationsTest.php +++ b/tests/06_Query/QuerySql2OperationsTest.php @@ -46,14 +46,14 @@ public function testQueryFieldSomenull() $vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null); } $this->assertContains('bar', $vals); - $this->assertEquals(8, count($vals)); + $this->assertEquals(9, count($vals)); $vals = array(); foreach ($result->getRows() as $row) { $vals[] = $row->getValue('foo'); } $this->assertContains('bar', $vals); - $this->assertEquals(8, count($vals)); + $this->assertEquals(9, count($vals)); } public function testQueryFieldSelector() @@ -135,7 +135,7 @@ public function testQueryOrder() $vals[] = $row->getValue('data.zeronumber'); } // rows that do not have that field are null. empty is before fields with values - $this->assertEquals(array(null, null, null, null, null, null, null, 0), $vals); + $this->assertEquals(array(null, null, null, null, null, null, null, null, 0), $vals); } public function testQueryMultiValuedProperty() @@ -143,7 +143,7 @@ public function testQueryMultiValuedProperty() /** @var $query \PHPCR\Query\QueryInterface */ $query = $this->sharedFixture['qm']->createQuery( 'SELECT data.tags - FROM [nt:folder] AS data + FROM [nt:unstructured] AS data WHERE data.tags = "foo" AND data.tags = "bar" ', From aa911cd33828f33ef5bf67fc89cadb7e61cd932d Mon Sep 17 00:00:00 2001 From: Willem-Jan Zijderveld Date: Sat, 9 Feb 2013 21:59:41 +0100 Subject: [PATCH 4/5] Reverted/Refactored some uses of the fixtures + changed the second assert to expect a scalar value instead of an array --- fixtures/general/base.xml | 15 +++++---------- tests/06_Query/QuerySql2OperationsTest.php | 8 ++++---- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/fixtures/general/base.xml b/fixtures/general/base.xml index 6e785bc4..2ad0c931 100644 --- a/fixtures/general/base.xml +++ b/fixtures/general/base.xml @@ -143,6 +143,11 @@ + + foo + bar + + @@ -181,16 +186,6 @@ 14e18ef3-be20-4985-bee9-7bb4763b31de - - - nt:unstructured - - - foo - bar - - - diff --git a/tests/06_Query/QuerySql2OperationsTest.php b/tests/06_Query/QuerySql2OperationsTest.php index ac3fd719..01215d87 100644 --- a/tests/06_Query/QuerySql2OperationsTest.php +++ b/tests/06_Query/QuerySql2OperationsTest.php @@ -46,14 +46,14 @@ public function testQueryFieldSomenull() $vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null); } $this->assertContains('bar', $vals); - $this->assertEquals(9, count($vals)); + $this->assertEquals(8, count($vals)); $vals = array(); foreach ($result->getRows() as $row) { $vals[] = $row->getValue('foo'); } $this->assertContains('bar', $vals); - $this->assertEquals(9, count($vals)); + $this->assertEquals(8, count($vals)); } public function testQueryFieldSelector() @@ -135,7 +135,7 @@ public function testQueryOrder() $vals[] = $row->getValue('data.zeronumber'); } // rows that do not have that field are null. empty is before fields with values - $this->assertEquals(array(null, null, null, null, null, null, null, null, 0), $vals); + $this->assertEquals(array(null, null, null, null, null, null, null, 0), $vals); } public function testQueryMultiValuedProperty() @@ -157,7 +157,7 @@ public function testQueryMultiValuedProperty() $rows = $result->getRows(); $this->assertCount(1, $rows, 'Expected one row with both tags present'); - $this->assertSame(array('foo', 'bar'), $rows->current()->getValue('tags')); + $this->assertSame('foo bar', $rows->current()->getValue('tags')); } } From 91606df860b580fac41dc4dadef88fd46fbc1c7b Mon Sep 17 00:00:00 2001 From: Willem-Jan Zijderveld Date: Sat, 9 Feb 2013 22:48:08 +0100 Subject: [PATCH 5/5] Moved the property up, so its before the nodes --- fixtures/general/base.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fixtures/general/base.xml b/fixtures/general/base.xml index 2ad0c931..cb02b339 100644 --- a/fixtures/general/base.xml +++ b/fixtures/general/base.xml @@ -104,6 +104,11 @@ text/plain + + foo + bar + + nt:unstructured @@ -143,11 +148,6 @@ - - foo - bar - -