A practice project from https://course.testdrivenlaravel.com
Using a tool like Selenium or PhantomJS to simulate the user's actions inside the browser.
$this->type('#title','My first blog post');
$this->type('#body','Lorem ipsum');
$this->submitForm('Add post');
- Simulates exactly how a user would interact with the application
- Gives you complete confidence that the application is working end-to-end
- Need to introduce a new tool to our stack(Selenium, PhantomJS, etc) if you need to execute JavaScript
- Slower
- More brittle, can often break due to important changes in the UI
- Complex to setup
- Often can't interact with core directly, need to make assertions through the UI
Making HTTP requests directly to an endpoint, simulating how the browser would interact with our server instead of how the user would interact with our app.
$this->post('/posts', [
'title' => 'My first post',
'body' => 'Lorem ipsum',
]);
- Faster
- Doesn't require any addtional tooling
- Interacting with more stable data structures, won't break with change are made for aesthetic reasons
- Can interact directly with code, more flexible assertions
- Untested gap between front-end and back-end
- Confidence that the system works
- Reliable, don't break for unimportant reasons
- Fast, so I run them often
- Simple, as few tools as possible, easy to recreate test environment
- Tests are fast
- Tests can run without internet access
- Tests will pass even if we aren't using Stripe's SDK correctly
- Tests can't be used to confirm our integration still works if Stripe makes an update to their SDK or API
- Tests are coupled to a specific implementation; can't refactor to use Guzzle or another Stripe library
- Tests will fail if we use Stripe's libray incorrectly
- Tests will fail if Stripe makes a breaking change to their SDK or API that would require us to change our code
- Tests are still valid even if we change our implementation to use Guzzle or an unoffical Stripe package
- Tests are slow
- Tests can't run without internet access
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
},
"classmap": [
"tests"
]
}
and don't forget to use composer dump-autoload
- It makes feature tests depending on network calls to some externe servers, and that's something we try to aviod.
class ConcertsController
{
// ...
}
Drawback:
not restful
use update method
class ConcertsController
{
public function update($id) {
// ...
if (request('published')) {
$concert->publish();
}
}
}
Drawback:
in the user interface, the act of editing the concert's details is disagreed the act of publishing a concert. when u click publish button, we are not passing to all the other information of updating(title, description...), all we try to say, is to publish the concert. which also means, u need to check and validtion the inputs again, when u publish.
use create or store method of restful
class ConcertsController
{
public function store()
{
$concert = Concert::find(request('concert_id'));
$concert->publish();
return redirect;
}
}
Stripe helps you create any type of payments flow—from e-commerce to recurring billing and everything in between.
Stripe enables you to accept payments in minutes. Collect your customers' payment information easily and securely on web or mobile, and create charges server-side in 135+ currencies. Users in Germany can accept Visa Mastercard American Express credit and debit cards.
Stripe also supports a range of additional payment methods, including 3D Secure, ACH debits, Apple Pay, and Google Pay.
Stripe makes recurring and subscription-based billing easy. Explore the quickstart to get going quickly and subscribe your first customer to a plan.