jolicode / asynit Goto Github PK
View Code? Open in Web Editor NEW:stars: Asynchronous HTTP Request Testing Library for API or more...
License: MIT License
:stars: Asynchronous HTTP Request Testing Library for API or more...
License: MIT License
Right now:
php bin/asynit src/OrganizationRoleAdminTest.php
[InvalidArgumentException]
The "src/OrganizationRoleAdminTest.php" directory does not exist.
Hello and thank you for this great repo :-)
Is it possible to work with a database out of the box? Or it would require some tricks like transactional tests?
When I use composer install
on this repository, I get following message:
Package amphp/artax is abandoned, you should avoid using it. Use amphp/http-client instead.
Currently there's only status
, but there could also be body
, body_contains
, header_exists
/ has_header
, ...
If you write:
public function testFoobar()
{
$response = yield $this->get('http://something-is-not-reachable');
}
you get this:
โ Argument 1 passed to Asynit\HttpClient\PromiseAdapter::reject() must be an instance of Http\Client\Exception, instance of Amp\Socket\ConnectException given, called in /PROJECT/tests/vendor/jolicode/asynit/src/HttpClient/PromiseAdapter.php on line 35
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Asynit\HttpClient\PromiseAdapter::reject() must be an instance of Http\Client\Exception, instance of Amp\Socket\ConnectException given, called in /PROJECT/tests/vendor/jolicode/asynit/src/HttpClient/PromiseAdapter.php on line 35 and defined in /PROJECT/tests/vendor/jolicode/asynit/src/HttpClient/PromiseAdapter.php:92
Stack trace:
#0 /PROJECT/tests/vendor/jolicode/asynit/src/HttpClient/PromiseAdapter.php(35): Asynit\HttpClient\PromiseAdapter->reject(Object(Amp\Socket\ConnectException))
#1 /PROJECT/tests/vendor/amphp/amp/lib/Internal/ResolutionQueue.php(51): Asynit\HttpClient\PromiseAdapter->Asynit\HttpClient\{closure}(Object(Amp\Socket\ConnectException), NULL)
#2 /PROJECT/tests/vendor/amphp/amp/lib/Failure.php(26): Amp\Internal\ResolutionQueue->__invoke(Object(Amp\Socket\ConnectException), NULL)
#3 /PROJECT/tests/vendor/amphp/amp/lib/Internal/Placeholder.php(118): Amp\Failure->onResolve(Object(Amp\Internal\ResolutionQueue))
#4 /PROJECT in /PROJECT/tests/vendor/jolicode/asynit/src/HttpClient/PromiseAdapter.php on line 92
My test suite has became big (23 files, 3500 LOC) and I would like to refactor it a bit.
All my tests extends a WebTestCase
class.
I would like to put some shortcut / helper in it, but ATM it's not possible because the callback in @Depend
should be a test. (For recall, a test is a callback that start with the test
keywork)
IMHO, It could be any valid callback.
You could argue I can easily transform my callback to a test, but in this case asynit will run the same test each time a class extends WebTestCase
. It's a waste of resource.
Do you think we could allow any callback in @Depend
?
Goal of this change would be to allow a better API for writing test, instead of writing
$this->get('http://test.com')->shouldResolve(function ($response) {
// Write test here
});
It would be written as
$response = yield $this->get('http://test.com');
// Write test here
WDYT ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.