dredd-hooks-php
dredd-hooks-php copied to clipboard
Use data objects that are documented for the transaction object.
When writing hooks, I noticed it was hard to figure out what I could modify and what I had access to, without digging through the Dredd docs.
While you can't get everything (you don't know what the body looks like, or what headers exist, for example), it helps a lot to have some static analyzability and documentation in editor.
This doesn't change any behaviour in the hooks, it just allows hooks to be read as documented objects.
This will mean, if you do $transaction->
in PHPStorm or VSCode, you can see what values (and types) exist on the transaction object from in your editor.
This should be backwards compatible as well, since, the internal data structure hasn't changed.
All values are public properties, so that json_serialize can still read them, and so that they are accessed the same way.
Now, when writing hooks, if you write:
<?php
use Dredd\Hooks;
use Dredd\DataObjects\Transaction;
Hooks::afterEach(function(Transaction &$transaction) {
});
You will now have full readability.
@m50 sorry for getting back to you late on this and I really appreciate your contribution! I haven't had a chance to look into why the build is failing. I won't have time to dig into that until Friday but I will be reviewing this soon.
Making the experience of writing hooks easier through enhanced static analyzability is awesome, so I'm open to accepting this change. I just want to spend some time fixing the build before I do a more thorough review.
@m50 please rebase on master now that I've fixed the majority of the issues with the test suite. The build still won't pass but I'll be able to do any additional verification now that master is in a much better state. More details on #46.
Once your change is rebased I'll be able to quickly review this.
@ddelnano sorry for the delay, been taking a break from the computer on the first week of my vacation, so just got to it now.
I rebased and re-pushed. Cucumber checks are still failing, as you said, but it's now matching master.
Ok, I'm out of town atm, so I'll make some cucumber tests when I get back. 👍
@ddelnano I added a phpunit test as well as a cucumber test.
Oddly, the cucumber test fails in the docker container, but not locally or in Travis. It complains about port already in use. Unsure what could be causing that, but figured I'd let you know.
Additionally, the docker container didn't have dredd installed in it, so to get the tests to run, I had to install dredd inside of it.
Any update on this?
Any update on this?
Mostly just waiting for a response from @ddelnano.
Dunno why it says that all checks have failed, considering last time I looked at this back in June, it was passing.