jonnybarnes.uk/tests/Feature/OwnYourGramTest.php

52 lines
1.7 KiB
PHP
Raw Normal View History

2017-06-11 20:54:10 +01:00
<?php
2021-03-17 18:38:18 +00:00
declare(strict_types=1);
2017-06-11 20:54:10 +01:00
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
2021-03-17 18:38:18 +00:00
use Illuminate\Support\Carbon;
2017-06-11 20:54:10 +01:00
use Tests\TestCase;
use Tests\TestToken;
2017-06-11 20:54:10 +01:00
class OwnYourGramTest extends TestCase
{
use RefreshDatabase;
2021-03-17 18:38:18 +00:00
use TestToken;
2017-06-11 20:54:10 +01:00
2021-03-17 18:38:18 +00:00
/** @test */
public function postingInstagramUrlSavesMediaPath(): void
2017-06-11 20:54:10 +01:00
{
$response = $this->json(
'POST',
'/api/post',
[
'type' => ['h-entry'],
'properties' => [
'content' => ['How beautiful are the plates and chopsticks'],
2021-03-17 18:38:18 +00:00
'published' => [Carbon::now()->toIso8601String()],
2017-06-11 20:54:10 +01:00
'location' => ['geo:53.802419075834,-1.5431942917637'],
'syndication' => ['https://www.instagram.com/p/BVC_nVTBFfi/'],
2021-03-17 18:38:18 +00:00
'photo' => [
// phpcs:ignore Generic.Files.LineLength.TooLong
'https://scontent-sjc2-1.cdninstagram.com/t51.2885-15/e35/18888604_425332491185600_326487281944756224_n.jpg'
],
2017-06-11 20:54:10 +01:00
],
],
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
);
$response->assertStatus(201)->assertJson([
'response' => 'created'
]);
$this->assertDatabaseHas('media_endpoint', [
2021-03-17 18:38:18 +00:00
// phpcs:ignore Generic.Files.LineLength.TooLong
2017-06-11 20:54:10 +01:00
'path' => 'https://scontent-sjc2-1.cdninstagram.com/t51.2885-15/e35/18888604_425332491185600_326487281944756224_n.jpg'
]);
$this->assertDatabaseHas('notes', [
'note' => 'How beautiful are the plates and chopsticks',
'instagram_url' => 'https://www.instagram.com/p/BVC_nVTBFfi/'
]);
}
}