つらい
This commit is contained in:
parent
1c6959bfcb
commit
8cde943cf8
@ -17,6 +17,13 @@ class CheckinWebhookTest extends TestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->seed();
|
$this->seed();
|
||||||
|
Carbon::setTestNow('2020-07-21 19:19:19');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown(): void
|
||||||
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
Carbon::setTestNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSuccessful()
|
public function testSuccessful()
|
||||||
@ -25,8 +32,12 @@ class CheckinWebhookTest extends TestCase
|
|||||||
$webhook = factory(CheckinWebhook::class)->create(['user_id' => $user->id]);
|
$webhook = factory(CheckinWebhook::class)->create(['user_id' => $user->id]);
|
||||||
|
|
||||||
$response = $this->postJson('/api/webhooks/checkin/' . $webhook->id, [
|
$response = $this->postJson('/api/webhooks/checkin/' . $webhook->id, [
|
||||||
|
'checked_in_at' => Carbon::create(2019, 7, 21, 19, 19, 19)->toIso8601String(),
|
||||||
|
'note' => 'test test test',
|
||||||
'link' => 'http://example.com',
|
'link' => 'http://example.com',
|
||||||
'tags' => ['foo', 'bar']
|
'tags' => ['foo', 'bar'],
|
||||||
|
'is_private' => false,
|
||||||
|
'is_too_sensitive' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertStatus(200)
|
$response->assertStatus(200)
|
||||||
@ -34,8 +45,55 @@ class CheckinWebhookTest extends TestCase
|
|||||||
|
|
||||||
$checkinId = $response->json('checkin.id');
|
$checkinId = $response->json('checkin.id');
|
||||||
$ejaculation = Ejaculation::find($checkinId);
|
$ejaculation = Ejaculation::find($checkinId);
|
||||||
|
$this->assertEquals(Carbon::create(2019, 7, 21, 19, 19, 0), $ejaculation->ejaculated_date);
|
||||||
|
$this->assertSame('test test test', $ejaculation->note);
|
||||||
$this->assertSame('http://example.com', $ejaculation->link);
|
$this->assertSame('http://example.com', $ejaculation->link);
|
||||||
$this->assertCount(2, $ejaculation->tags);
|
$this->assertCount(2, $ejaculation->tags);
|
||||||
|
$this->assertFalse($ejaculation->is_private);
|
||||||
|
$this->assertFalse($ejaculation->is_too_sensitive);
|
||||||
|
$this->assertSame(Ejaculation::SOURCE_WEBHOOK, $ejaculation->source);
|
||||||
|
$this->assertNotEmpty($ejaculation->checkin_webhook_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSuccessfulPrivateAndSensitive()
|
||||||
|
{
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
$webhook = factory(CheckinWebhook::class)->create(['user_id' => $user->id]);
|
||||||
|
|
||||||
|
$response = $this->postJson('/api/webhooks/checkin/' . $webhook->id, [
|
||||||
|
'is_private' => true,
|
||||||
|
'is_too_sensitive' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertStatus(200)
|
||||||
|
->assertJsonPath('status', 200);
|
||||||
|
|
||||||
|
$checkinId = $response->json('checkin.id');
|
||||||
|
$ejaculation = Ejaculation::find($checkinId);
|
||||||
|
$this->assertTrue($ejaculation->is_private);
|
||||||
|
$this->assertTrue($ejaculation->is_too_sensitive);
|
||||||
|
$this->assertSame(Ejaculation::SOURCE_WEBHOOK, $ejaculation->source);
|
||||||
|
$this->assertNotEmpty($ejaculation->checkin_webhook_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSuccessfulAllDefault()
|
||||||
|
{
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
$webhook = factory(CheckinWebhook::class)->create(['user_id' => $user->id]);
|
||||||
|
|
||||||
|
$response = $this->postJson('/api/webhooks/checkin/' . $webhook->id);
|
||||||
|
|
||||||
|
$response->assertStatus(200)
|
||||||
|
->assertJsonPath('status', 200);
|
||||||
|
|
||||||
|
$checkinId = $response->json('checkin.id');
|
||||||
|
$ejaculation = Ejaculation::find($checkinId);
|
||||||
|
$this->assertEquals(Carbon::create(2020, 7, 21, 19, 19, 0), $ejaculation->ejaculated_date);
|
||||||
|
$this->assertEmpty($ejaculation->note);
|
||||||
|
$this->assertEmpty($ejaculation->link);
|
||||||
|
$this->assertEmpty($ejaculation->tags);
|
||||||
|
$this->assertFalse($ejaculation->is_private);
|
||||||
|
$this->assertFalse($ejaculation->is_too_sensitive);
|
||||||
$this->assertSame(Ejaculation::SOURCE_WEBHOOK, $ejaculation->source);
|
$this->assertSame(Ejaculation::SOURCE_WEBHOOK, $ejaculation->source);
|
||||||
$this->assertNotEmpty($ejaculation->checkin_webhook_id);
|
$this->assertNotEmpty($ejaculation->checkin_webhook_id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user