-
Notifications
You must be signed in to change notification settings - Fork 61
Provide test functionality in traits #218
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
Conversation
/** | ||
* Provides a HTTP client for getting responses from your application | ||
*/ | ||
trait AppClient |
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.
Is this a good name? Perhaps just HttpClient
or AppHttpClient
or HttpAdapter
? I think the name should show that this is not a client for your proxy, but a client to simulate requests to your application.
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 wonder if it makes sense that all of this is a trait. could we have something like a client provider instead?
* | ||
* @var HttpClient | ||
*/ | ||
protected $client; |
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.
can this be private? what does it mean exactly when a trait has a private property, is it hidden from the class that uses the trait? and what if a class already has a non-private $client? then the user would need to remap the property?
from @stof in https://github.com/FriendsOfSymfony/FOSHttpCache/pull/224/files#r33294271
@ddeboer can you wrap this one up? make things private where possible and update the testing doc? otherwise looks good to me. |
d32188f
to
f3c59e6
Compare
Docs updated. |
~~~~~~~~~~~~~~~~ | ||
|
||
Provides your tests with a ``getResponse`` method, which retrieves a URI from | ||
your application through the HTTP cache:: |
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.
maybe "through a real HTTP call to go through the HTTP cache" to be more clear?
afc78e7
to
0ccd131
Compare
this does not fix #213, right? can we wrap this one up and then work on 213? |
} | ||
|
||
The ``UNDETERMINED`` state should never happen. If it does, it means that your | ||
HttpCache is not correctly set into debug mode. |
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.
HttpCache? also, should we make this into another subscriber that one can simply activate in app_test.php?
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’m not sure about this; we already had this in the docs and I just moved it. 👍 on a DebugSubscriber
, but let’s do that in a separate PR.
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.
created #238 for that
*/ | ||
abstract class VarnishTestCase extends ProxyTestCase | ||
abstract class VarnishTestCase |
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.
this is broken. It needs to extend from the PHPUnit_Framework_TestCase
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.
it seems to not be needed, at least the travis tests did run through without. oh, or maybe phpunit now ignores classes called Test if they dont extend the phpunit TestCase class.
but anyways i added it back to avoid confusion.
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.
well, if it does not extend the base testcase class, it won't run as it won't be a PHPUnit testcase.
https://travis-ci.org/FriendsOfSymfony/FOSHttpCache/jobs/74553567 was running 78 tests while https://travis-ci.org/FriendsOfSymfony/FOSHttpCache/jobs/74556258 ran 112 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.
Fix #202. separate http client from trait Make property and methods private Add traits to docs Reduce levels of inheritance
@ddeboer i rebased and did some cleanup only open point from my side is #218 (comment) - but i think we should just clean up the text to make it better understandable. providing a trait can happen in a separate PR. |
Provide test functionality in traits
Fix #202.
Advantage: users no longer have to extend our test classes, so they are free to extend their own (or their framework’s). Optionally, they can continue to extend
SymfonyTestCase
/VarnishTestCase
/NginxTest
: these classes are there now purely for convenience, as they contain no logic but just collect the appropriate traits.Disadvantage: we have some code duplication in the getters, e.g.
getHostName()
,getCachingProxyPort()
.Todo (if accepted):