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

Cleanup: move to correct phpunit assertions #111

Merged
merged 32 commits into from
Dec 30, 2016

Conversation

Ocramius
Copy link
Member

As discussed in #110

@Ocramius Ocramius added this to the v1.4.0 milestone Dec 30, 2016
@lcobucci
Copy link
Member

Should we also change $this->assert* to self::assert* here or on a different PR?

@Ocramius
Copy link
Member Author

@lcobucci good point - will apply that change too :-)

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.

LGTM just some minor stuff. Great clean up 😉

@@ -9,5 +9,5 @@
/**
* @Secure
*/
function foo();
public function foo();
}
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 have the newline at the end?

@@ -653,15 +653,15 @@ public function testAnnotationWithRequiredAttributes()

$docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value")';
try {
$result = $parser->parse($docblock,$context);
$parser->parse($docblock,$context);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we have a space after the comma?

$this->fail();
} catch (AnnotationException $exc) {
$this->assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes declared on property SomeClassName::invalidProperty. expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage());
}

$docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)';
try {
$result = $parser->parse($docblock,$context);
$parser->parse($docblock,$context);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we have a space after the comma?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't apply any CS fixes

@@ -687,15 +687,15 @@ public function testAnnotationWithRequiredAttributesWithoutConstructor()

$docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor("Some Value")';
try {
$result = $parser->parse($docblock,$context);
$parser->parse($docblock,$context);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we have a space after the comma?

$this->fail();
} catch (AnnotationException $exc) {
$this->assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor declared on property SomeClassName::invalidProperty. expects a(n) \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage());
}

$docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)';
try {
$result = $parser->parse($docblock,$context);
$parser->parse($docblock,$context);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we have a space after the comma?

@Ocramius Ocramius assigned lcobucci and unassigned mikeSimonson Dec 30, 2016
@Ocramius
Copy link
Member Author

@lcobucci if you think it's good to go, go on and 🚢

@lcobucci lcobucci merged commit c26cb71 into master Dec 30, 2016
@lcobucci lcobucci deleted the cleanup/move-to-correct-phpunit-assertions branch December 30, 2016 15:22
$this->assertCount(1, $reader->getClassAnnotations($class));
$this->assertInstanceOf($annotName = DummyAnnotation::class, $annot = $reader->getClassAnnotation($class, $annotName));
$this->assertEquals('hello', $annot->dummyValue);
self::assertCount(1, $reader->getClassAnnotations($class));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you point to the reasoning for this change or explain it ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't it equivalent?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it is (as far as I know) that why I want to know why you @lcobucci preferer this version.

Copy link
Member Author

Choose a reason for hiding this comment

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

Better semantics and error messages, usually

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait I was talking about the change from $this->assertCount to $self::assertCount not the change from assertTrue( , count()) to assertCount(). Or it's the same answer ?

@@ -192,7 +192,7 @@ private function updateFieldAceProperty($name, array $changes)

$aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
$aceIdProperty->setAccessible(true);
$aceIdProperty->setValue($ace, intval($aceId));
$aceIdProperty->setValue($ace, (int) $aceId);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for the preference ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Intval is generally to be replaced with simpler to look up casts

@mikeSimonson
Copy link
Contributor

Also how am I suppose to validate mark the review as being positive (without requiring change)? I can't find any button 😢 .

@Ocramius
Copy link
Member Author

Ocramius commented Jan 1, 2017

Only while the PR is still open

@mikeSimonson
Copy link
Contributor

Thanks 👍 anyway

@Ocramius
Copy link
Member Author

Ocramius commented Jan 1, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants