-
Notifications
You must be signed in to change notification settings - Fork 56
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
QueryBus testing #157
Comments
This happens because you tell phpunit to expect an exception thrown, but what actually happens is that the promise returns an Exception instance, not a 'thrown' one... however, since you would normally get the result of either method and do something with it I recommend this which works also;
or
|
Thanks for the code samples! Your suggestions are clear. I understand that this is more the issue from I managed to find another way to properly fail the test (by calling <?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Prooph\ServiceBus\QueryBus;
final class QueryTest extends TestCase
{
function test_query()
{
$queryBus = new QueryBus();
$queryBus->dispatch('anyname')
->then(function () {
//....
}, function (Throwable $e) {
$this->fail($e->getMessage());
})
->done(); // <--- THIS IS THE KEY HERE
}
} |
Can this issue be closed now? |
should we add that done() thing? |
maybe add some documentation? PR's are welcome :) |
We should refer to the promise package instead of document how promises works by our own. |
Guys, can you take a look at this issue as well, as it is relatively the same to this issue. Documentations says nothing about how to resolve |
I managed to reproduce the error in a simple test: Results:
|
Open a new issue. Definitly a problem i would think |
Hi!
I am currently finding my way around with QueryBus. And I got confused with testing it. I created an empty project, pulled up just a few things:
and then run this test:
And it is green.
I get control in second callable, but PHPUnit did not respect the
fail()
call at all.Do you have any suggestions on how to test queries / how to fix that test?
P.s. I browsed through the proophessor-do but did not find query tests there.
The text was updated successfully, but these errors were encountered: