May 2, 2017
0
Level 1
How to Accept Payments: Testing Stripe Webhooks : 2nd Test failed?
First test was fine, but why is it failing when
$ phpunit --filter test_it_deactivates_a_users_subscription_if_deleted_on_stripes_end PHPUnit 6.1.3 by Sebastian Bergmann and contributors.
F 1 / 1 (100%)
Time: 200 ms, Memory: 18.00MB
There was 1 failure:
- Tests\Feature\WebhooksControllerTest::test_it_deactivates_a_users_subscription_if_deleted_on_stripes_end Failed asserting that true is false.
/Users/seb/laravel-projects/laracasts/billing/tests/Feature/WebhooksControllerTest.php:58
<?php
namespace Tests\Feature;
use App\Http\Controllers\WebhooksController;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class WebhooksControllerTest extends TestCase
{
use DatabaseTransactions;
public function test_it_converts_a_stripe_event_name_to_a_method_name()
{
$name = (new WebhooksController)->eventToMethod('customer.subscription.deleted');
$this->assertEquals('whenCustomerSubscriptionDeleted', $name);
}
public function test_it_deactivates_a_users_subscription_if_deleted_on_stripes_end()
{
$user = factory('App\User')->create([
'stripe_active' => 1,
'stripe_id' => 'fake_stripe_id'
]);
$this->post('stripe/webhook', [
'type' => 'customer.subscription.deleted',
'data' => [
'object' => [
'customer' => $user->stripe_id
]
]
]);
$this->assertFalse(!!$user->fresh()->stripe_active); <-- Failed?
}
}
Please or to participate in this conversation.