-
Notifications
You must be signed in to change notification settings - Fork 21
Refactoring tests #188
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
Refactoring tests #188
Conversation
@@ -185,13 +185,13 @@ public function testCreateValueBoolean() | |||
$this->assertInstanceOf(PropertyInterface::class, $value); | |||
$this->assertEquals(PropertyType::BOOLEAN, $value->getType(), 'wrong type'); | |||
$this->assertTrue($value->getBoolean(), 'boolean not true'); | |||
$this->assertTrue($value->getString() == true, 'wrong string value'); //boolean converted to string must be true | |||
$this->assertEquals($value->getString(), true, 'wrong string value'); //boolean converted to string must be true |
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.
i think this should be the other way round, with true
being the first value. i guess assertTrue would check that the string is a boolean, which is not the case.
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.
Yep, you're right. In assertEquals
, the first parameter is the $expected
, in our case true
, and the second one is the $actual
, in our case $value->getString()
. Gonna change it and search for similars.
uh, i did not merge that. looks like i missed the update when you fixed my comment. any chance that you can reopen the repository so i can merge this cleanup? |
does rector have rules for phpunit that detect when a more specific assertion can be used? |
extremely cool, i have some company project where this is direly needed \o/ |
So please contact @TomasVotruba, he'll help you, as he's the creator and founder of Rector. I'm opening this PR again... |
I've refactored some tests, using:
assertCount
instead ofcount
function;assertSame
instead of strict comparisons===
;assertArrayHasKey
instead ofisset
function;assertContains
instead ofin_array
function;assertInternalType
andassertNotInternalType
instead ofis_*
functions;assertGreaterThan
andassertGreaterThanOrEqual
for mathematical comparisons;assertEquals
instead of comparisons==
.