Skip to content

test reading multivalue property with the same reference twice #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions fixtures/general/base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@
</sv:property>
</sv:node>

<sv:node sv:name="weakreference_repeated">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
<sv:property sv:name="other_ref" sv:type="WeakReference">
<sv:value>13543fc6-1abf-4708-bfcc-e49511754b40</sv:value>
<sv:value>13543fc6-1abf-4708-bfcc-e49511754b40</sv:value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbu can confirm that the doctrine-dbal tests are failing because of this... any clues or shall I look into it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</sv:property>
</sv:node>

</sv:node>
</sv:node>

Expand Down
19 changes: 16 additions & 3 deletions tests/05_Reading/NodeReadMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,17 @@ public function testGetPropertiesValuesGlob()
}
}

public function testGetReferencePropertyRepeated()
{
$node = $this->session->getNode('/tests_general_base/idExample/jcr:content/weakreference_repeated');
$refs = $node->getPropertyValue('other_ref');
$this->assertInternalType('array', (array) $refs);
$this->assertCount(2, $refs);
foreach ($refs as $node) {
$this->assertInstanceOf('PHPCR\NodeInterface', $node);
}
}

/**
* @group getPrimaryItem
*/
Expand Down Expand Up @@ -526,11 +537,13 @@ public function testGetWeakReferencesAll()
$target = $this->rootNode->getNode('tests_general_base/idExample/jcr:content/weakreference_target');
$source[] = $this->rootNode->getProperty('tests_general_base/idExample/jcr:content/weakreference_source1/ref1');
$source[] = $this->rootNode->getProperty('tests_general_base/idExample/jcr:content/weakreference_source2/ref2');
$source[] = $this->rootNode->getProperty('tests_general_base/idExample/jcr:content/weakreference_repeated/other_ref');

$iterator = $target->getWeakReferences();
$this->assertInstanceOf('Iterator', $iterator);

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

/**
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
*/
public function testHasNodeAbsolutePathException()
{
Expand Down Expand Up @@ -642,7 +655,7 @@ public function testHasPropertyFalse()
}

/**
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
*/
public function testHasPropertyAbsolutePathException()
{
Expand Down
12 changes: 6 additions & 6 deletions tests/06_Query/QuerySql2OperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public function testQueryFieldSomeNull()
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
}
$this->assertContains('bar', $vals);
$this->assertCount(9, $vals);
$this->assertCount(10, $vals);

$vals = array();
foreach ($result->getRows() as $row) {
$vals[] = $row->getValue('foo');
}
$this->assertContains('bar', $vals);
$this->assertCount(9, $vals);
$this->assertCount(10, $vals);
}

public function testQueryFieldSelector()
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testQueryLeftJoin()
}

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

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

public function testQueryMultiValuedProperty()
Expand Down
6 changes: 3 additions & 3 deletions tests/06_Query/Sql1/QueryOperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public function testQueryFieldSomenull()
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
}
$this->assertContains('bar', $vals);
$this->assertCount(9, $vals);
$this->assertCount(10, $vals);

$vals = array();
foreach ($result->getRows() as $row) {
$vals[] = $row->getValue('foo');
}
$this->assertContains('bar', $vals);
$this->assertCount(9, $vals);
$this->assertCount(10, $vals);
}

public function testQueryOrder()
Expand All @@ -82,7 +82,7 @@ public function testQueryOrder()
$vals[] = $row->getValue('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, null, null, 0), $vals);
}

}
6 changes: 3 additions & 3 deletions tests/06_Query/XPath/QueryOperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public function testQueryFieldSomenull()
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
}
$this->assertContains('bar', $vals);
$this->assertCount(9, $vals);
$this->assertCount(10, $vals);

$vals = array();
foreach ($result->getRows() as $row) {
$vals[] = $row->getValue('foo');
}
$this->assertContains('bar', $vals);
$this->assertCount(9, $vals);
$this->assertCount(10, $vals);
}

public function testQueryOrder()
Expand All @@ -76,7 +76,7 @@ public function testQueryOrder()
$vals[] = $row->getValue('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, null, null, 0), $vals);
}

}