-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Remove deprecated assertion usage #54
Remove deprecated assertion usage #54
Conversation
0c47f26
to
c3d4646
Compare
c3d4646
to
1407dd2
Compare
test/BetweenTest.php
Outdated
$messageTemplates = [ | ||
'notBetween' => "The input is not between '%min%' and '%max%', inclusively", | ||
'notBetweenStrict' => "The input is not strictly between '%min%' and '%max%'", | ||
'valueNotNumeric' => "The min ('%min%') and max ('%max%') values are numeric, but the input is not", |
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 with this type of test only duplicates are created.
For instance: the message text of Between::VALUE_NOT_NUMERIC
is already tested in
BetweenTest ::testStringValidatedAgainstNumericMinAndMaxIsInvalidAndReturnsAFailureMessage
.
laminas-validator/test/BetweenTest.php
Lines 292 to 301 in 7d81900
public function testStringValidatedAgainstNumericMinAndMaxIsInvalidAndReturnsAFailureMessage() | |
{ | |
$validator = new Between(['min' => 1, 'max' => 10]); | |
$this->assertFalse($validator->isValid('a')); | |
$messages = $validator->getMessages(); | |
$this->assertContains( | |
'The min (\'1\') and max (\'10\') values are numeric, but the input is not', | |
$messages | |
); | |
} |
If the messages are to be compared then maybe test only for the keys by using the class constants.
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.
Hello @froschdesign
The tests that I have replaced focused only on the error messages configuration. To be able to remove the most of the usage of assertAttributeEquals
, I tought it best to keep for now the same intention of these olds tests. The only change that I have made is to use the real strings instead of the keys in order to not couple the tests with the classes that they test.
To be honest, I don't see a lot of value with these tests. I would prefer to create the case where these message are used. I propose to amend my PR to remove the test methods for the test classes where all the messages are already tested. What do you think ?
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.
@codisart
The content of the messages should not be tested in all testEqualsMessageTemplates
tests. But there is another option if you do not want to throw out the tests:
public function testEqualsMessageTemplates()
{
$validator = new Between(['min' => 1, 'max' => 10]);
$this->assertSame(
[
Between::NOT_BETWEEN,
Between::NOT_BETWEEN_STRICT,
Between::VALUE_NOT_NUMERIC,
Between::VALUE_NOT_STRING,
],
array_keys($validator->getMessageTemplates())
);
}
Please feel free add your own proposal to find the best solution.
(Other improvements of the tests should be done in a separate pull requests because we should stay on the topic "Prepare update to phpunit 9".)
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.
@froschdesign
Don't you think that to use directly the class constants add coupling between the test and the tested class ?
I am more and more inclined to just throw these tests.
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 used the class constants for the tests as you suggested.
af0b04d
to
655503b
Compare
Hello @froschdesign, are my last changes ok with your recommendations ? |
test/DateTest.php
Outdated
); | ||
} | ||
|
||
public function testConstructorWithFormatParameter() |
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.
any reason why this test has been removed?
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 it is an error. I will put it back.
655503b
to
debf38c
Compare
Hello @michalbundyra, Do I need to change things for this PR ? |
Oh snap... I wasn't aware of this PR. @codisart Could you compare your changes with those from #75? If you have additional changes for better support of phpunit 9, I'd suggest to rebase against that branch as it will likely be merged in favor of your PR due to the adoption of PHP 8.0. |
7993e1d
to
8b7995a
Compare
8b7995a
to
dfb2843
Compare
@boesing Everything is up to date ! |
@codisart #75 adds PHP 8 support... and, to do so, bumps PHPUnit to 9.3. From what I can see, we're seill using some deprecated assertions currently (though they are not raising notices, from what I can see). As such:
Once those changes are in place, please don't forget to to hit the "Ready for review" button so we can review and merge! Thanks! |
ok let's go ! |
dfb2843
to
0ddcdf4
Compare
Signed-off-by: codisart <louis.celier@gmail.com>
0ddcdf4
to
10df593
Compare
Description
Remove some deprecated phpunit assertions that test non public attribute