-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Replacing self:: with static:: in Http\Client::setAuth #6301
Replacing self:: with static:: in Http\Client::setAuth #6301
Conversation
…in extending classes
I have a unit test for this if it is wanted. However, as there isn't any way to test for an exception NOT being thrown, I don't think it adds much that the current coverage on setAuth doesn't already provide. |
When you create a test asset it is possible to test if an exception is not thrown. Examples of this approach can be found in other parts: https://github.com/zendframework/zf2/tree/master/tests/ZendTest/Json/TestAsset |
@tklever The most easy way for test an exception is try {
$method->call();
$this->fail('Expected exception');
} catch (The\Expected\Exception $e) {
} |
@Maks3w no, the easiest is the following ;)… $this->setExpectedException('ExceptionName', 'String within exception message'); @tklever But as you said, you want to test that an exception is not thrown. Well, simply don't assert anything, the test will fail when an exception is thrown. Although in case you have no assertions, make a comment that it will fail based on an exception. |
@DASPRiD, you just perfectly described the test I have. It asserts nothing. On paper it seemed kind of useless, so I didn't originally include it. I'll add some comments that explain its reason for existing and push them into this PR. |
@tklever manually rebased, merged and fixed the test so that there is an assertion. A bit risky, but I prefer it to adding a getter, which would be worse. |
…-static-for-constants' into develop Close zendframework/zendframework#6301
This becomes an issue if you want to create a custom authentication method in a class extending Http\Client
The self:: check only allows for the included constants (AUTH_BASIC and AUTH_DIGEST), and will throw an exception on AUTH_XXXX constants in extending classes.