Skip to content
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

Fix collectionClass not working with the Yaml or Xml drivers. #1458

Closed

Conversation

trq
Copy link
Contributor

@trq trq commented Jul 14, 2016

The custom collections recently implemented in #1385 looks like it was never working with the Yaml (or Xml) drivers.

This PR addresses that issue.

'type' => $type,
'embedded' => true,
'targetDocument' => isset($attributes['target-document']) ? (string) $attributes['target-document'] : null,
'collectionClass' => isset($attributes['collectionClass']) ? (string) $attributes['collectionClass'] : null,
Copy link
Member

Choose a reason for hiding this comment

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

Should we use collection-class to be consistent?

@malarzm malarzm added the Bug label Jul 14, 2016
@malarzm malarzm added this to the 1.1.1 milestone Jul 14, 2016
@malarzm
Copy link
Member

malarzm commented Jul 14, 2016

@trq thanks a bunch for catching this! I have no idea why have I forgotten about them... Apart from my 2 comments above could you also please

  1. Update (XSD)[https://github.com/doctrine/mongodb-odm/blob/master/doctrine-mongo-mapping.xsd] file if we agree on using hyphens
  2. Add mapping tests to ensure the attribute is in fact set
  3. Fix failing tests (don't bother with PHPUnit warning, I can fix them later unless you want to)

@trq
Copy link
Contributor Author

trq commented Jul 14, 2016

No worries, thanks for the feedback. I'll make these changes and update shortly.

@trq
Copy link
Contributor Author

trq commented Jul 14, 2016

I'm a little lost with how/where to test the mapping on the XmlDriver. Any advice much appreciated. Thanks.

@@ -109,6 +109,7 @@
<xs:element name="default-discriminator-value" type="odm:default-discriminator-value" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="target-document" type="xs:string" />
<xs:attribute name="collection-class" type="xs:string" />
Copy link
Member

Choose a reason for hiding this comment

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

There seem to be collectionClass in line 115/116 (and 168/170) on which I can't comment, could you remove that?

@malarzm
Copy link
Member

malarzm commented Jul 14, 2016

As for XML tests you could tweak this AbstractMappingDriverTest which is extended by each driver type we have, here's XML mapping used by the test: https://github.com/doctrine/mongodb-odm/blob/master/tests/Doctrine/ODM/MongoDB/Tests/Mapping/xml/Doctrine.ODM.MongoDB.Tests.Mapping.AbstractMappingDriverUser.dcm.xml and probably you'll need to update tested YAML and annotation one too :)

@trq
Copy link
Contributor Author

trq commented Jul 15, 2016

I've added some more tests, hopefully not making too much mess.

I still have one failing test that I'll look at, but I would appreciate some help if anyone want's to take a look.

$this->assertArrayHasKey($key, $class->fieldMappings[$embeddedField]);
}
}
}

public function testGetAssociationCollectionClass()
{
$className = __NAMESPACE__.'\AbstractMappingDriverAlternateUser';
Copy link
Member

Choose a reason for hiding this comment

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

I think you wanted to use AbstractMappingDriverUser as that's the class you changed mapping for

Copy link
Member

Choose a reason for hiding this comment

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

P.S. sorry for such long break :)

@malarzm
Copy link
Member

malarzm commented Jul 22, 2016

@trq thanks for making tests green again! I should start merging stuff on Monday/Tuesday as I'm off for the weekend :)

@trq
Copy link
Contributor Author

trq commented Jul 23, 2016

No worries, thanks for your help.

Do you want me to squash this PR into a single commit or is there anything
else that it needs before merging ?

On Saturday, 23 July 2016, Maciej Malarz notifications@github.com wrote:

@trq https://github.com/trq thanks for making tests green again! I
should start merging stuff on Monday/Tuesday as I'm off for the weekend :)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1458 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAB_qx1mAeU817Gg3WrW4WAp7UEquGT7ks5qYNpwgaJpZM4JMLmg
.

@malarzm
Copy link
Member

malarzm commented Jul 25, 2016

I can squash commits and merge manually, no worries :)

malarzm added a commit that referenced this pull request Jul 26, 2016
@malarzm
Copy link
Member

malarzm commented Jul 26, 2016

Merged manually in 0a9caac - thanks @trq!

@malarzm malarzm closed this Jul 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants