Skip to content

Commit 5c91dab

Browse files
committed
test reading multivalue property with the same reference twice
1 parent f1a0b4c commit 5c91dab

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

fixtures/general/base.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@
158158
</sv:property>
159159
</sv:node>
160160

161+
<sv:node sv:name="weakreference_repeated">
162+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
163+
<sv:value>nt:unstructured</sv:value>
164+
</sv:property>
165+
<sv:property sv:name="other_ref" sv:type="WeakReference">
166+
<sv:value>13543fc6-1abf-4708-bfcc-e49511754b40</sv:value>
167+
<sv:value>13543fc6-1abf-4708-bfcc-e49511754b40</sv:value>
168+
</sv:property>
169+
</sv:node>
170+
161171
</sv:node>
162172
</sv:node>
163173

tests/05_Reading/NodeReadMethodsTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,17 @@ public function testGetPropertiesValuesGlob()
396396
}
397397
}
398398

399+
public function testGetReferencePropertyRepeated()
400+
{
401+
$node = $this->session->getNode('/tests_general_base/idExample/jcr:content/weakreference_repeated');
402+
$refs = $node->getPropertyValue('other_ref');
403+
$this->assertInternalType('array', (array) $refs);
404+
$this->assertCount(2, $refs);
405+
foreach ($refs as $node) {
406+
$this->assertInstanceOf('PHPCR\NodeInterface', $node);
407+
}
408+
}
409+
399410
/**
400411
* @group getPrimaryItem
401412
*/
@@ -530,7 +541,8 @@ public function testGetWeakReferencesAll()
530541
$iterator = $target->getWeakReferences();
531542
$this->assertInstanceOf('Iterator', $iterator);
532543

533-
$this->assertCount(2, $iterator, "Wrong number of weak references to weakreference_target");
544+
// there are 4 different references, but 2 come from the same property so should only count once.
545+
$this->assertCount(3, $iterator, "Wrong number of weak references to weakreference_target");
534546
foreach ($iterator as $prop) {
535547
$this->assertInstanceOf('\PHPCR\PropertyInterface', $prop);
536548
$this->assertTrue(in_array($prop, $source, true));
@@ -608,7 +620,7 @@ public function testHasNodePathTrue()
608620
}
609621

610622
/**
611-
* @expectedException InvalidArgumentException
623+
* @expectedException \InvalidArgumentException
612624
*/
613625
public function testHasNodeAbsolutePathException()
614626
{
@@ -642,7 +654,7 @@ public function testHasPropertyFalse()
642654
}
643655

644656
/**
645-
* @expectedException InvalidArgumentException
657+
* @expectedException \InvalidArgumentException
646658
*/
647659
public function testHasPropertyAbsolutePathException()
648660
{

tests/06_Query/QuerySql2OperationsTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public function testQueryFieldSomeNull()
5757
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
5858
}
5959
$this->assertContains('bar', $vals);
60-
$this->assertCount(9, $vals);
60+
$this->assertCount(10, $vals);
6161

6262
$vals = array();
6363
foreach ($result->getRows() as $row) {
6464
$vals[] = $row->getValue('foo');
6565
}
6666
$this->assertContains('bar', $vals);
67-
$this->assertCount(9, $vals);
67+
$this->assertCount(10, $vals);
6868
}
6969

7070
public function testQueryFieldSelector()
@@ -182,7 +182,7 @@ public function testQueryLeftJoin()
182182
}
183183

184184
// We get 9 results (idExample comes back multiple times because of the join)
185-
$this->assertCount(9, $result->getRows());
185+
$this->assertCount(10, $result->getRows());
186186
$this->assertEquals(array(
187187
'index.txt' => null,
188188
'idExample' => null,
@@ -212,8 +212,8 @@ public function testQueryRightJoin()
212212
$vals[basename($row->getPath('file'))] = $row->getValue('target.stringToCompare');
213213
}
214214

215-
// We get 9 results (idExample comes back multiple times because of the join)
216-
$this->assertCount(9, $result->getRows());
215+
// We get 10 results (idExample comes back multiple times because of the join)
216+
$this->assertCount(10, $result->getRows());
217217
$this->assertEquals(array(
218218
'index.txt' => null,
219219
'idExample' => null,
@@ -315,7 +315,7 @@ public function testQueryOrderWithMissingProperty()
315315
$vals[] = $row->getValue('data.zeronumber');
316316
}
317317
// rows that do not have that field are empty string. empty is before fields with values
318-
$this->assertEquals(array('', '', '', '', '', '', '', '', 0), $vals);
318+
$this->assertEquals(array('', '', '', '', '', '', '', '', '', 0), $vals);
319319
}
320320

321321
public function testQueryMultiValuedProperty()

tests/06_Query/Sql1/QueryOperationsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public function testQueryFieldSomenull()
5353
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
5454
}
5555
$this->assertContains('bar', $vals);
56-
$this->assertCount(9, $vals);
56+
$this->assertCount(10, $vals);
5757

5858
$vals = array();
5959
foreach ($result->getRows() as $row) {
6060
$vals[] = $row->getValue('foo');
6161
}
6262
$this->assertContains('bar', $vals);
63-
$this->assertCount(9, $vals);
63+
$this->assertCount(10, $vals);
6464
}
6565

6666
public function testQueryOrder()
@@ -82,7 +82,7 @@ public function testQueryOrder()
8282
$vals[] = $row->getValue('zeronumber');
8383
}
8484
// rows that do not have that field are null. empty is before fields with values
85-
$this->assertEquals(array(null, null, null, null, null, null, null, null, 0), $vals);
85+
$this->assertEquals(array(null, null, null, null, null, null, null, null, null, 0), $vals);
8686
}
8787

8888
}

tests/06_Query/XPath/QueryOperationsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ public function testQueryFieldSomenull()
5050
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
5151
}
5252
$this->assertContains('bar', $vals);
53-
$this->assertCount(9, $vals);
53+
$this->assertCount(10, $vals);
5454

5555
$vals = array();
5656
foreach ($result->getRows() as $row) {
5757
$vals[] = $row->getValue('foo');
5858
}
5959
$this->assertContains('bar', $vals);
60-
$this->assertCount(9, $vals);
60+
$this->assertCount(10, $vals);
6161
}
6262

6363
public function testQueryOrder()
@@ -76,7 +76,7 @@ public function testQueryOrder()
7676
$vals[] = $row->getValue('zeronumber');
7777
}
7878
// rows that do not have that field are null. empty is before fields with values
79-
$this->assertEquals(array(null, null, null, null, null, null, null, null, 0), $vals);
79+
$this->assertEquals(array(null, null, null, null, null, null, null, null, null, 0), $vals);
8080
}
8181

8282
}

0 commit comments

Comments
 (0)