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

Fixes custom type comment regex #2905

Merged
merged 2 commits into from
Nov 19, 2017

Conversation

jeremy-smith-maco
Copy link
Contributor

This is the same fix as #2679 which fixes the issue #2596 but this PR has tests for the change.

Copy link
Member

@lcobucci lcobucci left a comment

Choose a reason for hiding this comment

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

Some small changes, thanks for your contribution

@@ -1146,4 +1146,27 @@ public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys()
$this->assertArrayHasKey('explicit_fk1_idx', $indexes);
$this->assertArrayHasKey('idx_3d6c147fdc58d6c', $indexes);
}

public function testExtractDoctrineTypeFromComment()
Copy link
Member

Choose a reason for hiding this comment

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

Please add : void

$currentType = 'current type';

$result = $this->_sm->extractDoctrineTypeFromComment('(DC2Type:type.should.return)', $currentType);
self::assertEquals('type.should.return', $result);
Copy link
Member

Choose a reason for hiding this comment

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

assertSame() is more appropriated here

{
$currentType = 'current type';

$result = $this->_sm->extractDoctrineTypeFromComment('(DC2Type:type.should.return)', $currentType);
Copy link
Member

Choose a reason for hiding this comment

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

Could you use a data provider for this test? It would become much simpler 😄

@jeremy-smith-maco
Copy link
Contributor Author

Done @lcobucci

Copy link
Member

@lcobucci lcobucci left a comment

Choose a reason for hiding this comment

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

Nice job, just some more small things 😄

}

/**
* @return array
Copy link
Member

Choose a reason for hiding this comment

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

Please drop this

/**
* @dataProvider commentsProvider
*
* @param string $comment
Copy link
Member

Choose a reason for hiding this comment

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

Please drop the @param and @return annotations

* @param string $currentType
* @return void
*/
public function testExtractDoctrineTypeFromComment($comment, $expected, $currentType) : void
Copy link
Member

Choose a reason for hiding this comment

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

Please add the type declarations for the parameters

{
$currentType = 'current type';

return array(
Copy link
Member

Choose a reason for hiding this comment

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

Please use short-array syntax

Copy link
Member

Choose a reason for hiding this comment

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

Please define the indexes of the array with a short description of what the set of parameters is about, in order to improve PHPUnit's messages. Like:

return [
    'invalid custom type comments' => ['should.return.current.type', $currentType, $currentType],
    'valid custom type with dots'  => ['(DC2Type:type.should.return)', 'type.should.return', $currentType],
];

@jeremy-smith-maco
Copy link
Contributor Author

Done @lcobucci

@lcobucci lcobucci changed the base branch from develop to master November 19, 2017 00:22
@lcobucci lcobucci added this to the 2.6.3 milestone Nov 19, 2017
@lcobucci lcobucci self-assigned this Nov 19, 2017
@lcobucci lcobucci merged commit ea968df into doctrine:master Nov 19, 2017
lcobucci added a commit to lcobucci/dbal that referenced this pull request Nov 19, 2017
@lcobucci
Copy link
Member

@jeremy-smith-maco merged (with some minor changes - specially to also give credit to @PedroTroller) and backported. Thanks for your contribution!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants