-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
#6129 Added unit test for boolean option values. #6130
Conversation
It fail now. In `XmlDriver::_parseOptions` we need somehow to maintain a list of options, that are supposed to be boolean, and then call `$this->evaluateBoolean()` on them.
Ref: #6129 |
* @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'. | ||
*/ | ||
public function testInvalidMappingFileException() | ||
{ | ||
$this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel'); | ||
} | ||
|
||
public function testBooleanValuesForOptionIsSetCorrectly() | ||
{ | ||
$class = $this->createClassMetadata('Doctrine\Tests\ORM\Mapping\User'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use ::class
for new code
* @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'. | ||
*/ | ||
public function testInvalidMappingFileException() | ||
{ | ||
$this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel'); | ||
} | ||
|
||
public function testBooleanValuesForOptionIsSetCorrectly() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add an /** @group #6129 */
or similar?
@kalimatas thanks for converting it into an actual failing scenario! |
@@ -653,6 +653,8 @@ private function _parseOptions(SimpleXMLElement $options) | |||
{ | |||
$array = array(); | |||
|
|||
$booleanOptions = ['unsigned', 'fixed']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this constant is not used anywhere else, it can be inlined into the in_array()
call
@@ -664,7 +666,10 @@ private function _parseOptions(SimpleXMLElement $options) | |||
$attr = $option->attributes(); | |||
|
|||
if (isset($attr->name)) { | |||
$array[(string) $attr->name] = $value; | |||
$attrName = (string) $attr->name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't abbreviate. I know the previous code did, but we should really call it $attributeName
or such
@@ -245,6 +248,26 @@ public function testIdentifier($class) | |||
} | |||
|
|||
/** | |||
* @group #6129 | |||
* | |||
* @depends testIdentifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need @depends
@Ocramius fixed |
@kalimatas thanks! This looks good, merging! 👍 |
It fails now. In
XmlDriver::_parseOptions
we need somehow to maintain a list of options, that are supposed to be boolean, and then call$this->evaluateBoolean()
on them.