Update Laravel to v12
This commit is contained in:
parent
f2025b801b
commit
1dfa17abca
83 changed files with 1324 additions and 2323 deletions
|
@ -12,7 +12,9 @@ APP_FALLBACK_LOCALE=en
|
|||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
APP_MAINTENANCE_STORE=database
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
|
@ -39,7 +41,7 @@ FILESYSTEM_DISK=local
|
|||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
CACHE_PREFIX=
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
|
@ -49,6 +51,7 @@ REDIS_PASSWORD=null
|
|||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
|
|
|
@ -37,7 +37,7 @@ class ParseCachedWebMentions extends Command
|
|||
{
|
||||
$htmlFiles = $filesystem->allFiles(storage_path() . '/HTML');
|
||||
foreach ($htmlFiles as $file) {
|
||||
if ($file->getExtension() !== 'backup') { //we don’t want to parse `.backup` files
|
||||
if ($file->getExtension() !== 'backup') { // we don’t want to parse `.backup` files
|
||||
$filepath = $file->getPathname();
|
||||
$this->info('Loading HTML from: ' . $filepath);
|
||||
$html = $filesystem->get($filepath);
|
||||
|
|
|
@ -6,5 +6,5 @@ use Exception;
|
|||
|
||||
class RemoteContentNotFoundException extends Exception
|
||||
{
|
||||
//used when guzzle can’t find the remote content
|
||||
// used when guzzle can’t find the remote content
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class ArticlesController extends Controller
|
|||
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
//if a `.md` is attached use that for the main content.
|
||||
// if a `.md` is attached use that for the main content.
|
||||
if (request()->hasFile('article')) {
|
||||
$file = request()->file('article')->openFile();
|
||||
$content = $file->fread($file->getSize());
|
||||
|
|
|
@ -67,7 +67,7 @@ class NotesController extends Controller
|
|||
*/
|
||||
public function update(int $noteId): RedirectResponse
|
||||
{
|
||||
//update note data
|
||||
// update note data
|
||||
$note = Note::findOrFail($noteId);
|
||||
$note->note = request()->input('content');
|
||||
$note->in_reply_to = request()->input('in-reply-to');
|
||||
|
|
|
@ -26,8 +26,8 @@ class IndieAuthController extends Controller
|
|||
'authorization_endpoint' => route('indieauth.start'),
|
||||
'token_endpoint' => route('indieauth.token'),
|
||||
'code_challenge_methods_supported' => ['S256'],
|
||||
//'introspection_endpoint' => route('indieauth.introspection'),
|
||||
//'introspection_endpoint_auth_methods_supported' => ['none'],
|
||||
// 'introspection_endpoint' => route('indieauth.introspection'),
|
||||
// 'introspection_endpoint_auth_methods_supported' => ['none'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ class MicropubMediaController extends Controller
|
|||
*/
|
||||
private function getFileTypeFromMimeType(string $mimeType): string
|
||||
{
|
||||
//try known images
|
||||
// try known images
|
||||
$imageMimeTypes = [
|
||||
'image/gif',
|
||||
'image/jpeg',
|
||||
|
@ -203,7 +203,7 @@ class MicropubMediaController extends Controller
|
|||
if (in_array($mimeType, $imageMimeTypes)) {
|
||||
return 'image';
|
||||
}
|
||||
//try known video
|
||||
// try known video
|
||||
$videoMimeTypes = [
|
||||
'video/mp4',
|
||||
'video/mpeg',
|
||||
|
@ -214,7 +214,7 @@ class MicropubMediaController extends Controller
|
|||
if (in_array($mimeType, $videoMimeTypes)) {
|
||||
return 'video';
|
||||
}
|
||||
//try known audio types
|
||||
// try known audio types
|
||||
$audioMimeTypes = [
|
||||
'audio/midi',
|
||||
'audio/mpeg',
|
||||
|
|
|
@ -33,7 +33,7 @@ class WebMentionsController extends Controller
|
|||
*/
|
||||
public function receive(Request $request): Response
|
||||
{
|
||||
//first we trivially reject requests that lack all required inputs
|
||||
// first we trivially reject requests that lack all required inputs
|
||||
if (($request->has('target') !== true) || ($request->has('source') !== true)) {
|
||||
return response(
|
||||
'You need both the target and source parameters',
|
||||
|
@ -41,12 +41,12 @@ class WebMentionsController extends Controller
|
|||
);
|
||||
}
|
||||
|
||||
//next check the $target is valid
|
||||
// next check the $target is valid
|
||||
$path = parse_url($request->input('target'), PHP_URL_PATH);
|
||||
$pathParts = explode('/', $path);
|
||||
|
||||
if ($pathParts[1] === 'notes') {
|
||||
//we have a note
|
||||
// we have a note
|
||||
$noteId = $pathParts[2];
|
||||
try {
|
||||
$note = Note::findOrFail(resolve(Numbers::class)->b60tonum($noteId));
|
||||
|
|
|
@ -35,30 +35,30 @@ class DownloadWebMention implements ShouldQueue
|
|||
public function handle(Client $guzzle): void
|
||||
{
|
||||
$response = $guzzle->request('GET', $this->source);
|
||||
//4XX and 5XX responses should get Guzzle to throw an exception,
|
||||
//Laravel should catch and retry these automatically.
|
||||
// 4XX and 5XX responses should get Guzzle to throw an exception,
|
||||
// Laravel should catch and retry these automatically.
|
||||
if ($response->getStatusCode() === 200) {
|
||||
$filesystem = new FileSystem;
|
||||
$filename = storage_path('HTML') . '/' . $this->createFilenameFromURL($this->source);
|
||||
//backup file first
|
||||
// backup file first
|
||||
$filenameBackup = $filename . '.' . date('Y-m-d') . '.backup';
|
||||
if ($filesystem->exists($filename)) {
|
||||
$filesystem->copy($filename, $filenameBackup);
|
||||
}
|
||||
//check if base directory exists
|
||||
// check if base directory exists
|
||||
if (! $filesystem->exists($filesystem->dirname($filename))) {
|
||||
$filesystem->makeDirectory(
|
||||
$filesystem->dirname($filename),
|
||||
0755, //mode
|
||||
true //recursive
|
||||
0755, // mode
|
||||
true // recursive
|
||||
);
|
||||
}
|
||||
//save new HTML
|
||||
// save new HTML
|
||||
$filesystem->put(
|
||||
$filename,
|
||||
(string) $response->getBody()
|
||||
);
|
||||
//remove backup if the same
|
||||
// remove backup if the same
|
||||
if ($filesystem->exists($filenameBackup)) {
|
||||
if ($filesystem->get($filename) === $filesystem->get($filenameBackup)) {
|
||||
$filesystem->delete($filenameBackup);
|
||||
|
|
|
@ -49,7 +49,7 @@ class ProcessLike implements ShouldQueue
|
|||
$this->like->content = $tweet->html;
|
||||
$this->like->save();
|
||||
|
||||
//POSSE like
|
||||
// POSSE like
|
||||
try {
|
||||
$client->request(
|
||||
'POST',
|
||||
|
|
|
@ -32,18 +32,21 @@ class ProcessMedia implements ShouldQueue
|
|||
*/
|
||||
public function handle(ImageManager $manager): void
|
||||
{
|
||||
// Load file
|
||||
$file = Storage::disk('local')->get('media/' . $this->filename);
|
||||
|
||||
// Open file
|
||||
try {
|
||||
$image = $manager->read(storage_path('app/media/') . $this->filename);
|
||||
$image = $manager->read($file);
|
||||
} catch (DecoderException) {
|
||||
// not an image; delete file and end job
|
||||
unlink(storage_path('app/media/') . $this->filename);
|
||||
Storage::disk('local')->delete('media/' . $this->filename);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Save the file publicly
|
||||
Storage::disk('local')->copy('media/' . $this->filename, 'public/media/' . $this->filename);
|
||||
Storage::disk('public')->put('media/' . $this->filename, $file);
|
||||
|
||||
// Create smaller versions if necessary
|
||||
if ($image->width() > 1000) {
|
||||
|
@ -54,13 +57,13 @@ class ProcessMedia implements ShouldQueue
|
|||
$basename = trim(implode('.', $filenameParts), '.');
|
||||
|
||||
$medium = $image->resize(width: 1000);
|
||||
Storage::disk('local')->put('public/media/' . $basename . '-medium.' . $extension, (string) $medium->encode());
|
||||
Storage::disk('public')->put('media/' . $basename . '-medium.' . $extension, (string) $medium->encode());
|
||||
|
||||
$small = $image->resize(width: 500);
|
||||
Storage::disk('local')->put('public/media/' . $basename . '-small.' . $extension, (string) $small->encode());
|
||||
Storage::disk('public')->put('media/' . $basename . '-small.' . $extension, (string) $small->encode());
|
||||
}
|
||||
|
||||
// Now we can delete the locally saved image
|
||||
unlink(storage_path('app/media/') . $this->filename);
|
||||
Storage::disk('local')->delete('media/' . $this->filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class SaveProfileImage implements ShouldQueue
|
|||
$home = array_shift($home);
|
||||
}
|
||||
|
||||
//dont save pbs.twimg.com links
|
||||
// dont save pbs.twimg.com links
|
||||
if (
|
||||
$photo
|
||||
&& parse_url($photo, PHP_URL_HOST) !== 'pbs.twimg.com'
|
||||
|
|
|
@ -72,7 +72,7 @@ class SendWebMentions implements ShouldQueue
|
|||
|
||||
$guzzle = resolve(Client::class);
|
||||
$response = $guzzle->get($url);
|
||||
//check HTTP Headers for webmention endpoint
|
||||
// check HTTP Headers for webmention endpoint
|
||||
$links = Header::parse($response->getHeader('Link'));
|
||||
foreach ($links as $link) {
|
||||
if (array_key_exists('rel', $link) && mb_stristr($link['rel'], 'webmention')) {
|
||||
|
@ -80,7 +80,7 @@ class SendWebMentions implements ShouldQueue
|
|||
}
|
||||
}
|
||||
|
||||
//failed to find a header so parse HTML
|
||||
// failed to find a header so parse HTML
|
||||
$html = (string) $response->getBody();
|
||||
|
||||
$mf2 = new \Mf2\Parser($html, $url);
|
||||
|
|
|
@ -111,7 +111,7 @@ class Note extends Model
|
|||
{
|
||||
if ($value !== null) {
|
||||
$normalized = normalizer_normalize($value, Normalizer::FORM_C);
|
||||
if ($normalized === '') { //we don’t want to save empty strings to the db
|
||||
if ($normalized === '') { // we don’t want to save empty strings to the db
|
||||
$normalized = null;
|
||||
}
|
||||
$this->attributes['note'] = $normalized;
|
||||
|
|
|
@ -59,7 +59,7 @@ class Place extends Model
|
|||
* sin(radians(places.latitude))))";
|
||||
|
||||
return $query
|
||||
->select() //pick the columns you want here.
|
||||
->select() // pick the columns you want here.
|
||||
->selectRaw("{$haversine} AS distance")
|
||||
->whereRaw("{$haversine} < ?", [$distance]);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ class WebMention extends Model
|
|||
$host = parse_url($url, PHP_URL_HOST);
|
||||
|
||||
if ($host === 'pbs.twimg.com') {
|
||||
//make sure we use HTTPS, we know twitter supports it
|
||||
// make sure we use HTTPS, we know twitter supports it
|
||||
return str_replace('http://', 'https://', $url);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ class WebMention extends Model
|
|||
$codebird = resolve(Codebird::class);
|
||||
$info = $codebird->users_show(['screen_name' => $username]);
|
||||
$profile_image = $info->profile_image_url_https;
|
||||
Cache::put($url, $profile_image, 10080); //1 week
|
||||
Cache::put($url, $profile_image, 10080); // 1 week
|
||||
|
||||
return $profile_image;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class BookmarkService extends Service
|
|||
public function create(array $request, ?string $client = null): Bookmark
|
||||
{
|
||||
if (Arr::get($request, 'properties.bookmark-of.0')) {
|
||||
//micropub request
|
||||
// micropub request
|
||||
$url = normalize_url(Arr::get($request, 'properties.bookmark-of.0'));
|
||||
$name = Arr::get($request, 'properties.name.0');
|
||||
$content = Arr::get($request, 'properties.content.0');
|
||||
|
@ -61,7 +61,7 @@ class BookmarkService extends Service
|
|||
try {
|
||||
$response = $client->request('GET', 'https://web.archive.org/save/' . $url);
|
||||
} catch (ClientException $e) {
|
||||
//throw an exception to be caught
|
||||
// throw an exception to be caught
|
||||
throw new InternetArchiveException;
|
||||
}
|
||||
if ($response->hasHeader('Content-Location')) {
|
||||
|
@ -70,7 +70,7 @@ class BookmarkService extends Service
|
|||
}
|
||||
}
|
||||
|
||||
//throw an exception to be caught
|
||||
// throw an exception to be caught
|
||||
throw new InternetArchiveException;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class LikeService extends Service
|
|||
public function create(array $request, ?string $client = null): Like
|
||||
{
|
||||
if (Arr::get($request, 'properties.like-of.0')) {
|
||||
//micropub request
|
||||
// micropub request
|
||||
$url = normalize_url(Arr::get($request, 'properties.like-of.0'));
|
||||
}
|
||||
if (Arr::get($request, 'like-of')) {
|
||||
|
|
|
@ -20,7 +20,7 @@ class UpdateService
|
|||
{
|
||||
$urlPath = parse_url(Arr::get($request, 'url'), PHP_URL_PATH);
|
||||
|
||||
//is it a note we are updating?
|
||||
// is it a note we are updating?
|
||||
if (mb_substr($urlPath, 1, 5) !== 'notes') {
|
||||
return response()->json([
|
||||
'error' => 'invalid',
|
||||
|
@ -37,7 +37,7 @@ class UpdateService
|
|||
], 404);
|
||||
}
|
||||
|
||||
//got the note, are we dealing with a “replace” request?
|
||||
// got the note, are we dealing with a “replace” request?
|
||||
if (Arr::get($request, 'replace')) {
|
||||
foreach (Arr::get($request, 'replace') as $property => $value) {
|
||||
if ($property === 'content') {
|
||||
|
@ -64,7 +64,7 @@ class UpdateService
|
|||
]);
|
||||
}
|
||||
|
||||
//how about “add”
|
||||
// how about “add”
|
||||
if (Arr::get($request, 'add')) {
|
||||
foreach (Arr::get($request, 'add') as $property => $value) {
|
||||
if ($property === 'syndication') {
|
||||
|
|
|
@ -14,8 +14,8 @@ class PlaceService
|
|||
*/
|
||||
public function createPlace(array $data): Place
|
||||
{
|
||||
//obviously a place needs a lat/lng, but this could be sent in a geo-url
|
||||
//if no geo array key, we assume the array already has lat/lng values
|
||||
// obviously a place needs a lat/lng, but this could be sent in a geo-url
|
||||
// if no geo array key, we assume the array already has lat/lng values
|
||||
if (array_key_exists('geo', $data) && $data['geo'] !== null) {
|
||||
preg_match_all(
|
||||
'/([0-9\.\-]+)/',
|
||||
|
@ -40,7 +40,7 @@ class PlaceService
|
|||
*/
|
||||
public function createPlaceFromCheckin(array $checkin): Place
|
||||
{
|
||||
//check if the place exists if from swarm
|
||||
// check if the place exists if from swarm
|
||||
if (Arr::has($checkin, 'properties.url')) {
|
||||
$place = Place::whereExternalURL(Arr::get($checkin, 'properties.url.0'))->get();
|
||||
if (count($place) === 1) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "jonnybarnes/jonnybarnes.uk",
|
||||
"type": "project",
|
||||
"description": "The code for jonnybarnes.uk, based on Laravel 11",
|
||||
|
@ -11,14 +12,14 @@
|
|||
"ext-json": "*",
|
||||
"ext-pgsql": "*",
|
||||
"ext-sodium": "*",
|
||||
"cviebrock/eloquent-sluggable": "^11.0",
|
||||
"cviebrock/eloquent-sluggable": "^12.0",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"indieauth/client": "^1.1",
|
||||
"intervention/image": "^3",
|
||||
"jonnybarnes/indieweb": "~0.2",
|
||||
"jonnybarnes/webmentions-parser": "~0.5",
|
||||
"jublonet/codebird-php": "4.0.0-beta.1",
|
||||
"laravel/framework": "^11.0",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/horizon": "^5.0",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/scout": "^10.1",
|
||||
|
@ -46,11 +47,9 @@
|
|||
"mockery/mockery": "^1.4.4",
|
||||
"nunomaduro/collision": "^8.1",
|
||||
"openai-php/client": "^0.10.1",
|
||||
"phpunit/php-code-coverage": "^10.0",
|
||||
"phpunit/phpunit": "^10.1",
|
||||
"psalm/plugin-laravel": "^2.8",
|
||||
"spatie/laravel-ray": "^1.12",
|
||||
"vimeo/psalm": "^5.0"
|
||||
"phpunit/php-code-coverage": "^11.0",
|
||||
"phpunit/phpunit": "^11.0",
|
||||
"spatie/laravel-ray": "^1.12"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -79,7 +78,13 @@
|
|||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi"
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
],
|
||||
"dev": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
|
|
2712
composer.lock
generated
2712
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -65,7 +65,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'timezone' => env('APP_TIMEZONE', 'UTC'),
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -37,6 +37,9 @@ return [
|
|||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'busy_timeout' => null,
|
||||
'journal_mode' => null,
|
||||
'synchronous' => null,
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
|
@ -145,6 +148,7 @@ return [
|
|||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
|
|
|
@ -119,7 +119,7 @@ return [
|
|||
'full_log' => false,
|
||||
],
|
||||
'views' => [
|
||||
'data' => false, //Note: Can slow down the application, because the data can be quite large..
|
||||
'data' => false, // Note: Can slow down the application, because the data can be quite large..
|
||||
],
|
||||
'route' => [
|
||||
'label' => true, // show complete route on bar
|
||||
|
|
|
@ -32,8 +32,10 @@ return [
|
|||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app'),
|
||||
'root' => storage_path('app/private'),
|
||||
'serve' => true,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
|
@ -42,6 +44,7 @@ return [
|
|||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
|
@ -54,6 +57,7 @@ return [
|
|||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
|
|
@ -38,14 +38,14 @@ return [
|
|||
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN'),
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
|
|
|
@ -32,7 +32,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class NotesTableSeeder extends Seeder
|
|||
->where('id', $noteWithoutContact->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
//copy aaron’s profile pic in place
|
||||
// copy aaron’s profile pic in place
|
||||
$spl = new SplFileInfo(public_path() . '/assets/profile-images/aaronparecki.com');
|
||||
if ($spl->isDir() === false) {
|
||||
mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755);
|
||||
|
|
|
@ -138,7 +138,7 @@ if (! function_exists('normalize_url')) {
|
|||
$url['query'] = '';
|
||||
sort($queries);
|
||||
foreach ($queries as $query) {
|
||||
//lets drop query params we don’t want
|
||||
// lets drop query params we don’t want
|
||||
$key = stristr($query, '=', true);
|
||||
if (queryKeyIsBanned($key) === false) {
|
||||
$url['query'] .= "{$query}&";
|
||||
|
@ -197,7 +197,7 @@ if (! function_exists('prettyPrintJson')) {
|
|||
case '{':
|
||||
case '[':
|
||||
$level++;
|
||||
//no break
|
||||
// no break
|
||||
case ',':
|
||||
$ends_line_level = $level;
|
||||
break;
|
||||
|
|
|
@ -1,55 +1,20 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Contracts\Http\Kernel;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Check If The Application Is Under Maintenance
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If the application is in maintenance / demo mode via the "down" command
|
||||
| we will load this file so that any pre-rendered content can be shown
|
||||
| instead of starting the framework, which could cause an exception.
|
||||
|
|
||||
*/
|
||||
|
||||
// Determine if the application is in maintenance mode...
|
||||
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
|
||||
require $maintenance;
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader for
|
||||
| this application. We just need to utilize it! We'll simply require it
|
||||
| into the script here so we don't need to manually load our classes.
|
||||
|
|
||||
*/
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Run The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Once we have the application, we can handle the incoming request using
|
||||
| the application's HTTP kernel. Then, we will send the response back
|
||||
| to this client's browser, allowing them to enjoy our application.
|
||||
|
|
||||
*/
|
||||
|
||||
// Bootstrap Laravel and handle the request...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$kernel = $app->make(Kernel::class);
|
||||
|
||||
$response = $kernel->handle(
|
||||
$request = Request::capture()
|
||||
)->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
||||
$app->handleRequest(Request::capture());
|
||||
|
|
|
@ -64,7 +64,7 @@ Route::domain(config('url.longurl'))->group(function () {
|
|||
Route::middleware(MyAuthMiddleware::class)->prefix('admin')->group(function () {
|
||||
Route::get('/', [HomeController::class, 'welcome']);
|
||||
|
||||
//Articles
|
||||
// Articles
|
||||
Route::prefix('blog')->group(function () {
|
||||
Route::get('/', [AdminArticlesController::class, 'index']);
|
||||
Route::get('/create', [AdminArticlesController::class, 'create']);
|
||||
|
|
|
@ -12,7 +12,7 @@ class ExampleTest extends DuskTestCase
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicExample()
|
||||
public function test_basic_example()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->visit('/')
|
||||
|
|
|
@ -6,13 +6,14 @@ namespace Tests\Feature\Admin;
|
|||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminHomeControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminHomepageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
|
|
@ -5,25 +5,26 @@ declare(strict_types=1);
|
|||
namespace Tests\Feature\Admin;
|
||||
|
||||
use App\Models\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminPageRedirectsUnauthorisedUsersToLoginPage(): void
|
||||
{
|
||||
$response = $this->get('/admin');
|
||||
$response->assertRedirect('/login');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function loginPageLoads(): void
|
||||
{
|
||||
$response = $this->get('/login');
|
||||
$response->assertViewIs('login');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function loginAttemptWithBadCredentialsFails(): void
|
||||
{
|
||||
$response = $this->post('/login', [
|
||||
|
@ -33,7 +34,7 @@ class AdminTest extends TestCase
|
|||
$response->assertRedirect('/login');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function loginSucceeds(): void
|
||||
{
|
||||
User::factory([
|
||||
|
@ -49,7 +50,7 @@ class AdminTest extends TestCase
|
|||
$response->assertRedirect('/admin');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function whenLoggedInRedirectsToAdminPage(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
@ -57,14 +58,14 @@ class AdminTest extends TestCase
|
|||
$response->assertRedirect('/');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function loggedOutUsersSimplyRedirected(): void
|
||||
{
|
||||
$response = $this->get('/logout');
|
||||
$response->assertRedirect('/');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function loggedInUsersShownLogoutForm(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
@ -72,7 +73,7 @@ class AdminTest extends TestCase
|
|||
$response->assertViewIs('logout');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function loggedInUsersCanLogout(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
|
|
@ -9,13 +9,14 @@ use App\Models\User;
|
|||
use Faker\Factory;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ArticlesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminArticlesPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -25,7 +26,7 @@ class ArticlesTest extends TestCase
|
|||
$response->assertSeeText('Select article to edit:');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanLoadFormToCreateArticle(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -35,7 +36,7 @@ class ArticlesTest extends TestCase
|
|||
$response->assertSeeText('Title (URL)');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function admiNCanCreateNewArticle(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -48,7 +49,7 @@ class ArticlesTest extends TestCase
|
|||
$this->assertDatabaseHas('articles', ['title' => 'Test Title']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanCreateNewArticleWithFile(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -73,7 +74,7 @@ class ArticlesTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function articleCanLoadFormToEditArticle(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -86,7 +87,7 @@ class ArticlesTest extends TestCase
|
|||
$response->assertSeeText('This is *my* new blog. It uses `Markdown`.');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanEditArticle(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -104,7 +105,7 @@ class ArticlesTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanDeleteArticle(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
|
|
@ -7,13 +7,14 @@ namespace Tests\Feature\Admin;
|
|||
use App\Models\Bio;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BioTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminBiosPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -23,7 +24,7 @@ class BioTest extends TestCase
|
|||
$response->assertSeeText('Edit bio');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanCreateBio(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -36,7 +37,7 @@ class BioTest extends TestCase
|
|||
$this->assertDatabaseHas('bios', ['content' => 'Bio content']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanLoadExistingBio(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -49,7 +50,7 @@ class BioTest extends TestCase
|
|||
$response->assertSeeText('This is <em>my</em> bio. It uses <strong>HTML</strong>.');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanEditBio(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
|
|
@ -7,13 +7,14 @@ namespace Tests\Feature\Admin;
|
|||
use App\Models\MicropubClient;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ClientsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function clientsPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -23,7 +24,7 @@ class ClientsTest extends TestCase
|
|||
$response->assertSeeText('Clients');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanLoadFormToCreateClient(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -33,7 +34,7 @@ class ClientsTest extends TestCase
|
|||
$response->assertSeeText('New Client');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanCreateNewClient(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -49,7 +50,7 @@ class ClientsTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanLoadEditFormForClient(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -62,7 +63,7 @@ class ClientsTest extends TestCase
|
|||
$response->assertSee('https://jbl5.dev/notes/new');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanEditClient(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -80,7 +81,7 @@ class ClientsTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanDeleteClient(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
|
|
@ -12,6 +12,7 @@ use GuzzleHttp\HandlerStack;
|
|||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ContactsTest extends TestCase
|
||||
|
@ -27,7 +28,7 @@ class ContactsTest extends TestCase
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function contactIndexPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -36,7 +37,7 @@ class ContactsTest extends TestCase
|
|||
$response->assertViewIs('admin.contacts.index');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function contactCreatePageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -45,7 +46,7 @@ class ContactsTest extends TestCase
|
|||
$response->assertViewIs('admin.contacts.create');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanCreateNewContact(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -62,7 +63,7 @@ class ContactsTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanSeeFormToEditContact(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -72,7 +73,7 @@ class ContactsTest extends TestCase
|
|||
$response->assertViewIs('admin.contacts.edit');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanUpdateContact(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -91,7 +92,7 @@ class ContactsTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanEditContactAndUploadAvatar(): void
|
||||
{
|
||||
copy(__DIR__ . '/../../aaron.png', sys_get_temp_dir() . '/tantek.png');
|
||||
|
@ -114,7 +115,7 @@ class ContactsTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanDeleteContact(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -132,7 +133,7 @@ class ContactsTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanTriggerRetrievalOfRemoteAvatar(): void
|
||||
{
|
||||
$html = <<<'HTML'
|
||||
|
@ -161,7 +162,7 @@ class ContactsTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function gettingRemoteAvatarFailsGracefullyWithRemoteNotFound(): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
|
@ -178,7 +179,7 @@ class ContactsTest extends TestCase
|
|||
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function gettingRemoteAvatarFailsGracefullyWithRemoteError(): void
|
||||
{
|
||||
$html = <<<'HTML'
|
||||
|
@ -201,7 +202,7 @@ class ContactsTest extends TestCase
|
|||
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function gettingRemoteAvatarFailsGracefullyForContactWithNoHompage(): void
|
||||
{
|
||||
$contact = Contact::create([
|
||||
|
|
|
@ -9,13 +9,14 @@ use App\Models\Like;
|
|||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LikesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function likesPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -25,7 +26,7 @@ class LikesTest extends TestCase
|
|||
$response->assertSeeText('Likes');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function likeCreateFormLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -35,7 +36,7 @@ class LikesTest extends TestCase
|
|||
$response->assertSeeText('New Like');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanCreateLike(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -51,7 +52,7 @@ class LikesTest extends TestCase
|
|||
Queue::assertPushed(ProcessLike::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function likeEditFormLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -62,7 +63,7 @@ class LikesTest extends TestCase
|
|||
$response->assertSee('Edit Like');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanEditLike(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -80,7 +81,7 @@ class LikesTest extends TestCase
|
|||
Queue::assertPushed(ProcessLike::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanDeleteLike(): void
|
||||
{
|
||||
$like = Like::factory()->create();
|
||||
|
|
|
@ -9,13 +9,14 @@ use App\Models\Note;
|
|||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class NotesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function notesPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -24,7 +25,7 @@ class NotesTest extends TestCase
|
|||
$response->assertViewIs('admin.notes.index');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function noteCreatePageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -33,7 +34,7 @@ class NotesTest extends TestCase
|
|||
$response->assertViewIs('admin.notes.create');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanCreateNewNote(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -47,7 +48,7 @@ class NotesTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function noteEditFormLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -57,7 +58,7 @@ class NotesTest extends TestCase
|
|||
$response->assertViewIs('admin.notes.edit');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanEditNote(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -76,7 +77,7 @@ class NotesTest extends TestCase
|
|||
Queue::assertPushed(SendWebMentions::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanDeleteNote(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
|
|
@ -7,13 +7,14 @@ namespace Tests\Feature\Admin;
|
|||
use App\Models\Place;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PlacesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function placesPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -22,7 +23,7 @@ class PlacesTest extends TestCase
|
|||
$response->assertViewIs('admin.places.index');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function createPlacePageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -31,7 +32,7 @@ class PlacesTest extends TestCase
|
|||
$response->assertViewIs('admin.places.create');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanCreateNewPlace(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -48,7 +49,7 @@ class PlacesTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function editPlacePageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
@ -58,7 +59,7 @@ class PlacesTest extends TestCase
|
|||
$response->assertViewIs('admin.places.edit');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function adminCanUpdatePlace(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
|
|
@ -7,20 +7,21 @@ namespace Tests\Feature;
|
|||
use App\Models\Article;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Jonnybarnes\IndieWeb\Numbers;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ArticlesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function articlesPageLoads(): void
|
||||
{
|
||||
$response = $this->get('/blog');
|
||||
$response->assertViewIs('articles.index');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function singleArticlePageLoads()
|
||||
{
|
||||
$article = Article::factory()->create();
|
||||
|
@ -28,7 +29,7 @@ class ArticlesTest extends TestCase
|
|||
$response->assertViewIs('articles.show');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function wrongDateInUrlRedirectsToCorrectDate()
|
||||
{
|
||||
$article = Article::factory()->create();
|
||||
|
@ -36,7 +37,7 @@ class ArticlesTest extends TestCase
|
|||
$response->assertRedirect('/blog/' . date('Y') . '/' . date('m') . '/' . $article->titleurl);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function oldUrlsWithIdAreRedirected()
|
||||
{
|
||||
$article = Article::factory()->create();
|
||||
|
@ -45,21 +46,21 @@ class ArticlesTest extends TestCase
|
|||
$response->assertRedirect($article->link);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function unknownSlugGetsNotFoundResponse()
|
||||
{
|
||||
$response = $this->get('/blog/' . date('Y') . '/' . date('m') . '/unknown-slug');
|
||||
$response->assertNotFound();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function unknownArticleIdGetsNotFoundResponse()
|
||||
{
|
||||
$response = $this->get('/blog/s/22');
|
||||
$response->assertNotFound();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function someUrlsDoNotParseCorrectly(): void
|
||||
{
|
||||
$response = $this->get('/blog/feed.js');
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Jobs\ProcessBookmark;
|
|||
use App\Models\Bookmark;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
use Tests\TestToken;
|
||||
|
||||
|
@ -15,14 +16,14 @@ class BookmarksTest extends TestCase
|
|||
{
|
||||
use RefreshDatabase, TestToken;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function bookmarksPageLoadsWithoutError(): void
|
||||
{
|
||||
$response = $this->get('/bookmarks');
|
||||
$response->assertViewIs('bookmarks.index');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function singleBookmarkPageLoadsWithoutError(): void
|
||||
{
|
||||
$bookmark = Bookmark::factory()->create();
|
||||
|
@ -30,7 +31,7 @@ class BookmarksTest extends TestCase
|
|||
$response->assertViewIs('bookmarks.show');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function whenBookmarkIsAddedUsingHttpSyntaxCheckJobToTakeScreenshotIsInvoked(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -48,7 +49,7 @@ class BookmarksTest extends TestCase
|
|||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function whenBookmarkIsAddedUsingJsonSyntaxCheckJobToTakeScreenshotIsInvoked(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -68,7 +69,7 @@ class BookmarksTest extends TestCase
|
|||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function whenTheBookmarkIsCreatedCheckNecessaryTagsAreAlsoCreated(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Tests\Feature;
|
|||
|
||||
use App\Models\Contact;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ContactsTest extends TestCase
|
||||
|
@ -14,9 +15,8 @@ class ContactsTest extends TestCase
|
|||
|
||||
/**
|
||||
* Check the `/contacts` page gives a good response.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function contactsPageLoadsWithoutError(): void
|
||||
{
|
||||
$response = $this->get('/contacts');
|
||||
|
@ -25,9 +25,8 @@ class ContactsTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test an individual contact page with default profile image.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function contactPageShouldFallbackToDefaultProfilePic(): void
|
||||
{
|
||||
Contact::factory()->create([
|
||||
|
@ -39,9 +38,8 @@ class ContactsTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test an individual contact page with a specific profile image.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function contactPageShouldUseSpecificProfilePicIfPresent(): void
|
||||
{
|
||||
Contact::factory()->create([
|
||||
|
@ -52,7 +50,7 @@ class ContactsTest extends TestCase
|
|||
$response->assertViewHas('image', '/assets/profile-images/aaronparecki.com/image');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function unknownContactReturnsNotFoundResponse(): void
|
||||
{
|
||||
$response = $this->get('/contacts/unknown');
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
use Tests\TestToken;
|
||||
|
||||
|
@ -11,7 +12,7 @@ class CorsHeadersTest extends TestCase
|
|||
{
|
||||
use TestToken;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function checkCorsHeadersOnMediaEndpoint(): void
|
||||
{
|
||||
$response = $this->call(
|
||||
|
@ -25,7 +26,7 @@ class CorsHeadersTest extends TestCase
|
|||
$response->assertHeader('Access-Control-Allow-Origin', '*');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function checkForNoCorsHeaderOnNonMediaEndpointLinks(): void
|
||||
{
|
||||
$response = $this->get('/blog');
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Models\Article;
|
|||
use App\Models\Note;
|
||||
use App\Models\Place;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FeedsTest extends TestCase
|
||||
|
@ -16,9 +17,8 @@ class FeedsTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test the blog RSS feed.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function blogRssFeedIsPresent(): void
|
||||
{
|
||||
Article::factory()->count(3)->create();
|
||||
|
@ -29,9 +29,8 @@ class FeedsTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test the notes RSS feed.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notesRssFeedIsPresent(): void
|
||||
{
|
||||
Note::factory()->count(3)->create();
|
||||
|
@ -42,9 +41,8 @@ class FeedsTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test the blog RSS feed.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function blogAtomFeedIsPresent(): void
|
||||
{
|
||||
Article::factory()->count(3)->create();
|
||||
|
@ -53,7 +51,7 @@ class FeedsTest extends TestCase
|
|||
$response->assertOk();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function blogJf2FeedIsPresent(): void
|
||||
{
|
||||
Article::factory()->count(3)->create();
|
||||
|
@ -77,9 +75,8 @@ class FeedsTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test the notes RSS feed.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notesAtomFeedIsPresent(): void
|
||||
{
|
||||
Note::factory()->count(3)->create();
|
||||
|
@ -90,9 +87,8 @@ class FeedsTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test the blog JSON feed.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function blogJsonFeedIsPresent(): void
|
||||
{
|
||||
Article::factory()->count(3)->create();
|
||||
|
@ -103,9 +99,8 @@ class FeedsTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test the notes JSON feed.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notesJsonFeedIsPresent(): void
|
||||
{
|
||||
Note::factory()->count(3)->create();
|
||||
|
@ -114,7 +109,7 @@ class FeedsTest extends TestCase
|
|||
$response->assertOk();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function notesJf2FeedIsPresent(): void
|
||||
{
|
||||
Note::factory()->count(3)->create();
|
||||
|
@ -139,9 +134,8 @@ class FeedsTest extends TestCase
|
|||
/**
|
||||
* Each JSON feed item must have one of `content_text` or `content_html`,
|
||||
* and whichever one they have can’t be `null`.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function jsonFeedsHaveRequiredAttributes(): void
|
||||
{
|
||||
Note::factory()->count(3)->create();
|
||||
|
@ -161,7 +155,7 @@ class FeedsTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function jsonNoteFeedLoadsPlaceDataWithoutLazyLoading(): void
|
||||
{
|
||||
$place = Place::factory()->create();
|
||||
|
|
|
@ -7,13 +7,14 @@ use App\Models\Bookmark;
|
|||
use App\Models\Like;
|
||||
use App\Models\Note;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FrontPageTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function frontPageLoadsAllContent(): void
|
||||
{
|
||||
Note::factory()->create(['note' => 'Note 1']);
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HorizonTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Horizon has its own test suite, here we just test it has been installed successfully.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function horizonIsInstalled(): void
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
|
|
|
@ -31,8 +31,8 @@ class IndieAuthTest extends TestCase
|
|||
'authorization_endpoint' => route('indieauth.start'),
|
||||
'token_endpoint' => route('indieauth.token'),
|
||||
'code_challenge_methods_supported' => ['S256'],
|
||||
//'introspection_endpoint' => 'introspection_endpoint',
|
||||
//'introspection_endpoint_auth_methods_supported' => ['none'],
|
||||
// 'introspection_endpoint' => 'introspection_endpoint',
|
||||
// 'introspection_endpoint_auth_methods_supported' => ['none'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ use GuzzleHttp\Psr7\Response;
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Jonnybarnes\WebmentionsParser\Authorship;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
use Tests\TestToken;
|
||||
|
||||
|
@ -22,14 +23,14 @@ class LikesTest extends TestCase
|
|||
use RefreshDatabase;
|
||||
use TestToken;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function likesPageHasCorrectView(): void
|
||||
{
|
||||
$response = $this->get('/likes');
|
||||
$response->assertViewIs('likes.index');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function singleLikePageHasCorrectView(): void
|
||||
{
|
||||
$like = Like::factory()->create();
|
||||
|
@ -37,7 +38,7 @@ class LikesTest extends TestCase
|
|||
$response->assertViewIs('likes.show');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function checkLikeCreatedFromMicropubApiRequests(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -57,7 +58,7 @@ class LikesTest extends TestCase
|
|||
$this->assertDatabaseHas('likes', ['url' => 'https://example.org/blog-post']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function checkLikeCreatedFromMicropubWebRequests(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -75,7 +76,7 @@ class LikesTest extends TestCase
|
|||
$this->assertDatabaseHas('likes', ['url' => 'https://example.org/blog-post']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function likeWithSimpleAuthor(): void
|
||||
{
|
||||
$like = new Like;
|
||||
|
@ -114,7 +115,7 @@ class LikesTest extends TestCase
|
|||
$this->assertEquals('Fred Bloggs', Like::find($id)->author_name);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function likeWithHCard(): void
|
||||
{
|
||||
$like = new Like;
|
||||
|
@ -157,7 +158,7 @@ class LikesTest extends TestCase
|
|||
$this->assertEquals('Fred Bloggs', Like::find($id)->author_name);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function likeWithoutMicroformats(): void
|
||||
{
|
||||
$like = new Like;
|
||||
|
@ -193,7 +194,7 @@ class LikesTest extends TestCase
|
|||
$this->assertNull(Like::find($id)->author_name);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function likeThatIsATweet(): void
|
||||
{
|
||||
$like = new Like;
|
||||
|
@ -219,10 +220,9 @@ class LikesTest extends TestCase
|
|||
'author_url' => 'https://twitter.com/jonnybarnes',
|
||||
'html' => '<div>HTML of the tweet embed</div>',
|
||||
];
|
||||
$codebirdMock = $this->getMockBuilder(Codebird::class)
|
||||
->addMethods(['statuses_oembed'])
|
||||
->getMock();
|
||||
$codebirdMock->method('statuses_oembed')
|
||||
$codebirdMock = $this->createPartialMock(Codebird::class, ['__call']);
|
||||
$codebirdMock->method('__call')
|
||||
->with('statuses_oembed', $this->anything())
|
||||
->willReturn($info);
|
||||
$this->app->instance(Codebird::class, $codebirdMock);
|
||||
|
||||
|
@ -233,7 +233,7 @@ class LikesTest extends TestCase
|
|||
$this->assertEquals('Jonny Barnes', Like::find($id)->author_name);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function noErrorForFailureToPosseWithBridgy(): void
|
||||
{
|
||||
$like = new Like;
|
||||
|
@ -257,10 +257,9 @@ class LikesTest extends TestCase
|
|||
'author_url' => 'https://twitter.com/jonnybarnes',
|
||||
'html' => '<div>HTML of the tweet embed</div>',
|
||||
];
|
||||
$codebirdMock = $this->getMockBuilder(Codebird::class)
|
||||
->addMethods(['statuses_oembed'])
|
||||
->getMock();
|
||||
$codebirdMock->method('statuses_oembed')
|
||||
$codebirdMock = $this->createPartialMock(Codebird::class, ['__call']);
|
||||
$codebirdMock->method('__call')
|
||||
->with('statuses_oembed', $this->anything())
|
||||
->willReturn($info);
|
||||
$this->app->instance(Codebird::class, $codebirdMock);
|
||||
|
||||
|
@ -271,7 +270,7 @@ class LikesTest extends TestCase
|
|||
$this->assertEquals('Jonny Barnes', Like::find($id)->author_name);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function unknownLikeGivesNotFoundResponse(): void
|
||||
{
|
||||
$response = $this->get('/likes/202');
|
||||
|
|
|
@ -15,6 +15,7 @@ use Carbon\Carbon;
|
|||
use Faker\Factory;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
use Tests\TestToken;
|
||||
|
||||
|
@ -23,7 +24,7 @@ class MicropubControllerTest extends TestCase
|
|||
use RefreshDatabase;
|
||||
use TestToken;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubGetRequestWithoutTokenReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->get('/api/post');
|
||||
|
@ -31,7 +32,7 @@ class MicropubControllerTest extends TestCase
|
|||
$response->assertJsonFragment(['error_description' => 'No access token was provided in the request']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubGetRequestWithoutValidTokenReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->get('/api/post', ['HTTP_Authorization' => 'Bearer abc123']);
|
||||
|
@ -42,9 +43,8 @@ class MicropubControllerTest extends TestCase
|
|||
/**
|
||||
* Test a GET request for the micropub endpoint with a valid token gives a
|
||||
* 200 response. Check token information is also returned in the response.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function micropubGetRequestWithValidTokenReturnsOkResponse(): void
|
||||
{
|
||||
$response = $this->get('/api/post', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
|
@ -52,14 +52,14 @@ class MicropubControllerTest extends TestCase
|
|||
$response->assertJsonFragment(['response' => 'token']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientsCanRequestSyndicationTargetsCanBeEmpty(): void
|
||||
{
|
||||
$response = $this->get('/api/post?q=syndicate-to', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$response->assertJsonFragment(['syndicate-to' => []]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientsCanRequestSyndicationTargetsPopulatesFromModel(): void
|
||||
{
|
||||
$syndicationTarget = SyndicationTarget::factory()->create();
|
||||
|
@ -67,7 +67,7 @@ class MicropubControllerTest extends TestCase
|
|||
$response->assertJsonFragment(['uid' => $syndicationTarget->uid]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientsCanRequestKnownNearbyPlaces(): void
|
||||
{
|
||||
Place::factory()->create([
|
||||
|
@ -80,8 +80,6 @@ class MicropubControllerTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @todo Add uncertainty parameter
|
||||
*
|
||||
public function micropubClientsCanRequestKnownNearbyPlacesWithUncertaintyParameter(): void
|
||||
|
@ -89,22 +87,21 @@ class MicropubControllerTest extends TestCase
|
|||
$response = $this->get('/api/post?q=geo:53.5,-2.38', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$response->assertJson(['places' => [['slug' => 'the-bridgewater-pub']]]);
|
||||
}*/
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function returnEmptyResultWhenMicropubClientRequestsKnownNearbyPlaces(): void
|
||||
{
|
||||
$response = $this->get('/api/post?q=geo:1.23,4.56', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$response->assertJson(['places' => []]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientCanRequestEndpointConfig(): void
|
||||
{
|
||||
$response = $this->get('/api/post?q=config', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$response->assertJsonFragment(['media-endpoint' => route('media-endpoint')]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientCanCreateNewNote(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
|
@ -123,7 +120,7 @@ class MicropubControllerTest extends TestCase
|
|||
$this->assertDatabaseHas('notes', ['note' => $note]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientCanRequestTheNewNoteIsSyndicatedToMastodonAndBluesky(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -157,7 +154,7 @@ class MicropubControllerTest extends TestCase
|
|||
Queue::assertPushed(SyndicateNoteToBluesky::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientsCanCreateNewPlaces(): void
|
||||
{
|
||||
$response = $this->post(
|
||||
|
@ -173,7 +170,7 @@ class MicropubControllerTest extends TestCase
|
|||
$this->assertDatabaseHas('places', ['slug' => 'the-barton-arms']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientsCanCreateNewPlacesWithOldLocationSyntax(): void
|
||||
{
|
||||
$response = $this->post(
|
||||
|
@ -190,7 +187,7 @@ class MicropubControllerTest extends TestCase
|
|||
$this->assertDatabaseHas('places', ['slug' => 'the-barton-arms']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientWebRequestWithInvalidTokenReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->post(
|
||||
|
@ -205,7 +202,7 @@ class MicropubControllerTest extends TestCase
|
|||
$response->assertJson(['error' => 'invalid_token']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientWebRequestWithTokenWithoutAnyScopesReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->post(
|
||||
|
@ -220,7 +217,7 @@ class MicropubControllerTest extends TestCase
|
|||
$response->assertJson(['error_description' => 'The provided token has no scopes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientWebRequestWithTokenWithoutCreateScopesReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->post(
|
||||
|
@ -238,9 +235,8 @@ class MicropubControllerTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test a valid micropub requests using JSON syntax creates a new note.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function micropubClientApiRequestCreatesNewNote(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -286,9 +282,8 @@ class MicropubControllerTest extends TestCase
|
|||
/**
|
||||
* Test a valid micropub requests using JSON syntax creates a new note with
|
||||
* existing self-created place.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function micropubClientApiRequestCreatesNewNoteWithExistingPlaceInLocationData(): void
|
||||
{
|
||||
$place = new Place;
|
||||
|
@ -317,9 +312,8 @@ class MicropubControllerTest extends TestCase
|
|||
/**
|
||||
* Test a valid micropub requests using JSON syntax creates a new note with
|
||||
* a new place defined in the location block.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function micropubClientApiRequestCreatesNewNoteWithNewPlaceInLocationData(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
|
@ -353,9 +347,8 @@ class MicropubControllerTest extends TestCase
|
|||
/**
|
||||
* Test a valid micropub requests using JSON syntax creates a new note without
|
||||
* a new place defined in the location block if there is missing data.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function micropubClientApiRequestCreatesNewNoteWithoutNewPlaceInLocationData(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
|
@ -387,9 +380,8 @@ class MicropubControllerTest extends TestCase
|
|||
/**
|
||||
* Test a micropub requests using JSON syntax without a token returns an
|
||||
* error. Also check the message.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function micropubClientApiRequestWithoutTokenReturnsError(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
|
@ -414,9 +406,8 @@ class MicropubControllerTest extends TestCase
|
|||
/**
|
||||
* Test a micropub requests using JSON syntax without a valid token returns
|
||||
* an error. Also check the message.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function micropubClientApiRequestWithTokenWithInsufficientPermissionReturnsError(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
|
@ -439,7 +430,7 @@ class MicropubControllerTest extends TestCase
|
|||
->assertStatus(401);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestForUnsupportedPostTypeReturnsError(): void
|
||||
{
|
||||
$response = $this->postJson(
|
||||
|
@ -460,7 +451,7 @@ class MicropubControllerTest extends TestCase
|
|||
->assertStatus(500);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestCreatesNewPlace(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
|
@ -480,7 +471,7 @@ class MicropubControllerTest extends TestCase
|
|||
->assertStatus(201);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestCreatesNewPlaceWithUncertaintyParameter(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
|
@ -500,7 +491,7 @@ class MicropubControllerTest extends TestCase
|
|||
->assertStatus(201);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestUpdatesExistingNote(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -520,7 +511,7 @@ class MicropubControllerTest extends TestCase
|
|||
->assertStatus(200);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestUpdatesNoteSyndicationLinks(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -547,7 +538,7 @@ class MicropubControllerTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestAddsImageToNote(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -570,7 +561,7 @@ class MicropubControllerTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestReturnsErrorTryingToUpdateNonNoteModel(): void
|
||||
{
|
||||
$response = $this->postJson(
|
||||
|
@ -589,7 +580,7 @@ class MicropubControllerTest extends TestCase
|
|||
->assertStatus(500);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestReturnsErrorTryingToUpdateNonExistingNote(): void
|
||||
{
|
||||
$response = $this->postJson(
|
||||
|
@ -608,7 +599,7 @@ class MicropubControllerTest extends TestCase
|
|||
->assertStatus(404);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestReturnsErrorWhenTryingToUpdateUnsupportedProperty(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -628,7 +619,7 @@ class MicropubControllerTest extends TestCase
|
|||
->assertStatus(500);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestWithTokenWithInsufficientScopeReturnsError(): void
|
||||
{
|
||||
$response = $this->postJson(
|
||||
|
@ -647,7 +638,7 @@ class MicropubControllerTest extends TestCase
|
|||
->assertJson(['error' => 'insufficient_scope']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestCanReplaceNoteSyndicationTargets(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -674,7 +665,7 @@ class MicropubControllerTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientWebRequestCanEncodeTokenWithinTheForm(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
|
@ -692,7 +683,7 @@ class MicropubControllerTest extends TestCase
|
|||
$this->assertDatabaseHas('notes', ['note' => $note]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function micropubClientApiRequestCreatesArticlesWhenItIncludesTheNameProperty(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
|
|
|
@ -11,6 +11,7 @@ use Illuminate\Http\UploadedFile;
|
|||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
use Tests\TestToken;
|
||||
|
||||
|
@ -19,7 +20,7 @@ class MicropubMediaTest extends TestCase
|
|||
use RefreshDatabase;
|
||||
use TestToken;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function emptyResponseForLastUploadWhenNoneFound(): void
|
||||
{
|
||||
// Make sure there’s no media
|
||||
|
@ -33,7 +34,7 @@ class MicropubMediaTest extends TestCase
|
|||
$response->assertJson(['url' => null]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function getRequestWithInvalidTokenReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->get(
|
||||
|
@ -44,7 +45,7 @@ class MicropubMediaTest extends TestCase
|
|||
$response->assertJsonFragment(['error_description' => 'The provided token did not pass validation']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function getRequestWithTokenWithoutScopeReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->get(
|
||||
|
@ -55,7 +56,7 @@ class MicropubMediaTest extends TestCase
|
|||
$response->assertJsonFragment(['error_description' => 'The provided token has no scopes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function getRequestWithTokenWithInsufficientScopeReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->get(
|
||||
|
@ -66,7 +67,7 @@ class MicropubMediaTest extends TestCase
|
|||
$response->assertJsonFragment(['error_description' => 'The token’s scope does not have the necessary requirements.']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function emptyGetRequestWithTokenReceivesOkResponse(): void
|
||||
{
|
||||
$response = $this->get(
|
||||
|
@ -77,7 +78,7 @@ class MicropubMediaTest extends TestCase
|
|||
$response->assertJson(['status' => 'OK']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function clientCanListLastUpload(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -102,11 +103,11 @@ class MicropubMediaTest extends TestCase
|
|||
$lastUploadResponse->assertJson(['url' => $response->headers->get('Location')]);
|
||||
|
||||
// now remove file
|
||||
unlink(storage_path('app/media/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/media'));
|
||||
unlink(storage_path('app/private/media/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function clientCanSourceUploads(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -134,11 +135,11 @@ class MicropubMediaTest extends TestCase
|
|||
]]]);
|
||||
|
||||
// now remove file
|
||||
unlink(storage_path('app/media/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/media'));
|
||||
unlink(storage_path('app/private/media/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function clientCanSourceUploadsWithLimit(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -168,11 +169,11 @@ class MicropubMediaTest extends TestCase
|
|||
$this->assertCount(1, json_decode($sourceUploadResponse->getContent(), true)['items']);
|
||||
|
||||
// now remove file
|
||||
unlink(storage_path('app/media/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/media'));
|
||||
unlink(storage_path('app/private/media/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mediaEndpointUploadRequiresFile(): void
|
||||
{
|
||||
$response = $this->post(
|
||||
|
@ -188,7 +189,7 @@ class MicropubMediaTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function errorResponseForUnknownQValue(): void
|
||||
{
|
||||
$response = $this->get(
|
||||
|
@ -199,7 +200,7 @@ class MicropubMediaTest extends TestCase
|
|||
$response->assertJson(['error' => 'invalid_request']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function optionsRequestReturnsCorsResponse(): void
|
||||
{
|
||||
$response = $this->options('/api/media');
|
||||
|
@ -208,7 +209,7 @@ class MicropubMediaTest extends TestCase
|
|||
$response->assertHeader('access-control-allow-origin', '*');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mediaEndpointRequestWithInvalidTokenReturns400Response(): void
|
||||
{
|
||||
$response = $this->post(
|
||||
|
@ -220,7 +221,7 @@ class MicropubMediaTest extends TestCase
|
|||
$response->assertJsonFragment(['error_description' => 'The provided token did not pass validation']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mediaEndpointRequestWithTokenWithNoScopeReturns400Response(): void
|
||||
{
|
||||
$response = $this->post(
|
||||
|
@ -232,7 +233,7 @@ class MicropubMediaTest extends TestCase
|
|||
$response->assertJsonFragment(['error_description' => 'The provided token has no scopes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mediaEndpointRequestWithInsufficientTokenScopesReturns401Response(): void
|
||||
{
|
||||
$response = $this->post(
|
||||
|
@ -246,7 +247,7 @@ class MicropubMediaTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mediaEndpointUploadFile(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -265,11 +266,11 @@ class MicropubMediaTest extends TestCase
|
|||
Queue::assertPushed(ProcessMedia::class);
|
||||
Storage::disk('local')->assertExists($filename);
|
||||
// now remove file
|
||||
unlink(storage_path('app/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/media'));
|
||||
unlink(storage_path('app/private/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mediaEndpointUploadAudioFile(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -288,11 +289,11 @@ class MicropubMediaTest extends TestCase
|
|||
Queue::assertPushed(ProcessMedia::class);
|
||||
Storage::disk('local')->assertExists($filename);
|
||||
// now remove file
|
||||
unlink(storage_path('app/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/media'));
|
||||
unlink(storage_path('app/private/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mediaEndpointUploadVideoFile(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -311,11 +312,11 @@ class MicropubMediaTest extends TestCase
|
|||
Queue::assertPushed(ProcessMedia::class);
|
||||
Storage::disk('local')->assertExists($filename);
|
||||
// now remove file
|
||||
unlink(storage_path('app/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/media'));
|
||||
unlink(storage_path('app/private/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mediaEndpointUploadDocumentFile(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -333,11 +334,11 @@ class MicropubMediaTest extends TestCase
|
|||
Queue::assertPushed(ProcessMedia::class);
|
||||
Storage::disk('local')->assertExists($filename);
|
||||
// now remove file
|
||||
unlink(storage_path('app/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/media'));
|
||||
unlink(storage_path('app/private/') . $filename);
|
||||
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mediaEndpointUploadInvalidFileReturnsError(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Tests\Feature;
|
|||
|
||||
use App\Models\Note;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class NotesControllerTest extends TestCase
|
||||
|
@ -15,9 +16,8 @@ class NotesControllerTest extends TestCase
|
|||
/**
|
||||
* Test the `/notes` page returns 200, this should
|
||||
* mean the database is being hit.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notesPageLoads(): void
|
||||
{
|
||||
$response = $this->get('/notes');
|
||||
|
@ -26,9 +26,8 @@ class NotesControllerTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test a specific note.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function specificNotePageLoads(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -46,9 +45,8 @@ class NotesControllerTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test that `/note/{decID}` redirects to `/notes/{nb60id}`.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function oldNoteUrlsRedirect(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -58,23 +56,22 @@ class NotesControllerTest extends TestCase
|
|||
|
||||
/**
|
||||
* Visit the tagged page and check the tag view data.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function taggedNotesPageLoads(): void
|
||||
{
|
||||
$response = $this->get('/notes/tagged/beer');
|
||||
$response->assertViewHas('tag', 'beer');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function unknownNoteGives404(): void
|
||||
{
|
||||
$response = $this->get('/notes/112233');
|
||||
$response->assertNotFound();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function checkNoteIdNotOutOfRange(): void
|
||||
{
|
||||
$response = $this->get('/notes/photou-photologo');
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Tests\Feature;
|
|||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
use Tests\TestToken;
|
||||
|
||||
|
@ -14,7 +15,7 @@ class OwnYourGramTest extends TestCase
|
|||
use RefreshDatabase;
|
||||
use TestToken;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function postingInstagramUrlSavesMediaPath(): void
|
||||
{
|
||||
$response = $this->json(
|
||||
|
|
|
@ -9,6 +9,7 @@ use Illuminate\FileSystem\FileSystem;
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ParseCachedWebMentionsTest extends TestCase
|
||||
|
@ -25,7 +26,7 @@ class ParseCachedWebMentionsTest extends TestCase
|
|||
copy(__DIR__ . '/../tantek.html', storage_path('HTML') . '/http/tantek.com/index.html');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function parseWebmentionHtml(): void
|
||||
{
|
||||
$webmentionAaron = WebMention::factory()->create([
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Tests\Feature;
|
|||
|
||||
use App\Models\Place;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PlacesTest extends TestCase
|
||||
|
@ -14,9 +15,8 @@ class PlacesTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test the `/places` page for OK response.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function placesPageLoads(): void
|
||||
{
|
||||
$response = $this->get('/places');
|
||||
|
@ -25,9 +25,8 @@ class PlacesTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test a specific place.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function singlePlacePageLoads(): void
|
||||
{
|
||||
$place = Place::factory()->create();
|
||||
|
@ -35,7 +34,7 @@ class PlacesTest extends TestCase
|
|||
$response->assertViewHas('place', $place);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function unknownPlaceGives404()
|
||||
{
|
||||
$response = $this->get('/places/unknown');
|
||||
|
|
|
@ -9,13 +9,14 @@ use App\Models\WebMention;
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ReDownloadWebMentionsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function downloadJobGetsQueued(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
|
|
@ -5,11 +5,12 @@ declare(strict_types=1);
|
|||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Note;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SearchTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function searchEndpointReturnsResults(): void
|
||||
{
|
||||
Note::factory(10)->create();
|
||||
|
|
|
@ -4,32 +4,33 @@ declare(strict_types=1);
|
|||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ShortURLsControllerTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function shortDomainRedirectsToLongDomain(): void
|
||||
{
|
||||
$response = $this->get('https://' . config('url.shorturl'));
|
||||
$response->assertRedirect(config('app.url'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function shortDomainSlashAtRedirectsToTwitter(): void
|
||||
{
|
||||
$response = $this->get('https://' . config('url.shorturl') . '/@');
|
||||
$response->assertRedirect('https://twitter.com/jonnybarnes');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function shortDomainSlashTRedirectsToLongDomainSlashNotes(): void
|
||||
{
|
||||
$response = $this->get('https://' . config('url.shorturl') . '/t/E');
|
||||
$response->assertRedirect(config('app.url') . '/notes/E');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function shortDomainSlashBRedirectsToLongDomainSlashBlog(): void
|
||||
{
|
||||
$response = $this->get('https://' . config('url.shorturl') . '/b/1');
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Jobs\SendWebMentions;
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
use Tests\TestToken;
|
||||
|
||||
|
@ -18,9 +19,8 @@ class SwarmTest extends TestCase
|
|||
|
||||
/**
|
||||
* Given a check in to Foursquare, this is the content Ownyourswarm will post to us.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function mockedOwnyourswarmRequestWithFoursquare(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -66,9 +66,8 @@ class SwarmTest extends TestCase
|
|||
/**
|
||||
* This request would actually come from another client than OwnYourSwarm, but we’re testing
|
||||
* OpenStreetMap data.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function mockedOwnyourswarmRequestWithOsm(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -109,9 +108,8 @@ class SwarmTest extends TestCase
|
|||
|
||||
/**
|
||||
* This request would actually come from another client than OwnYourSwarm, as that would include a Foursquare URL
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function mockedOwnyourswarmRequestWithoutKnownExternalUrl(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -150,7 +148,7 @@ class SwarmTest extends TestCase
|
|||
Queue::assertPushed(SendWebMentions::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mockedOwnyourswarmRequestWithNoTextContent(): void
|
||||
{
|
||||
$response = $this->json(
|
||||
|
@ -187,7 +185,7 @@ class SwarmTest extends TestCase
|
|||
$this->get($response->__get('headers')->get('location'))->assertSee('📍');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mockedOwnyourswarmRequestSavesJustThePostWhenAnErrorOccursInTheCheckinData(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -225,7 +223,7 @@ class SwarmTest extends TestCase
|
|||
Queue::assertPushed(SendWebMentions::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mockedOwnyourswarmRequestWithHAdrLocation(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -271,7 +269,7 @@ class SwarmTest extends TestCase
|
|||
Queue::assertPushed(SendWebMentions::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function ownyourswarmCheckinTestUsingRealData(): void
|
||||
{
|
||||
$response = $this->json(
|
||||
|
|
|
@ -9,6 +9,7 @@ use DateTimeImmutable;
|
|||
use Lcobucci\JWT\Configuration;
|
||||
use Lcobucci\JWT\Signer\Key\InMemory;
|
||||
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TokenServiceTest extends TestCase
|
||||
|
@ -16,9 +17,8 @@ class TokenServiceTest extends TestCase
|
|||
/**
|
||||
* Given the token is dependent on a random nonce, the time of creation and
|
||||
* the APP_KEY, to test, we shall create a token, and then verify it.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function tokenserviceCreatesAndValidatesTokens(): void
|
||||
{
|
||||
$tokenService = new TokenService;
|
||||
|
@ -37,11 +37,7 @@ class TokenServiceTest extends TestCase
|
|||
$this->assertSame($data, $validData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
#[Test]
|
||||
public function tokensWithDifferentSigningKeyThrowsException(): void
|
||||
{
|
||||
$this->expectException(RequiredConstraintsViolated::class);
|
||||
|
|
|
@ -8,13 +8,14 @@ use App\Jobs\ProcessWebMention;
|
|||
use App\Models\Note;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WebMentionsControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function webmentionEndpointCanServeBrowserRequest(): void
|
||||
{
|
||||
$response = $this->get('/webmention');
|
||||
|
@ -23,9 +24,8 @@ class WebMentionsControllerTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test webmentions without source and target are rejected.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function webmentionsWithoutSourceAndTargetAreRejected(): void
|
||||
{
|
||||
$response = $this->call('POST', '/webmention', ['source' => 'https://example.org/post/123']);
|
||||
|
@ -36,9 +36,8 @@ class WebMentionsControllerTest extends TestCase
|
|||
* Test invalid target gives a 400 response.
|
||||
*
|
||||
* In this case an invalid target is a URL that doesn’t exist on our domain.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function invalidTargetReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->call('POST', '/webmention', [
|
||||
|
@ -50,9 +49,8 @@ class WebMentionsControllerTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test blog target gets a 501 response due to our not supporting it.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function blogTargetReturns501Response(): void
|
||||
{
|
||||
$response = $this->call('POST', '/webmention', [
|
||||
|
@ -64,9 +62,8 @@ class WebMentionsControllerTest extends TestCase
|
|||
|
||||
/**
|
||||
* Test that a non-existent note gives a 400 response.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function nonexistentNoteReturnsErrorResponse(): void
|
||||
{
|
||||
$response = $this->call('POST', '/webmention', [
|
||||
|
@ -76,7 +73,7 @@ class WebMentionsControllerTest extends TestCase
|
|||
$response->assertStatus(400);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function legitimateWebmentionTriggersProcessWebmentionJob(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
|
|
@ -7,13 +7,14 @@ namespace Tests\Unit;
|
|||
use App\Models\Article;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ArticlesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function titleSlugIsGeneratedAutomatically(): void
|
||||
{
|
||||
$article = new Article;
|
||||
|
@ -24,7 +25,7 @@ class ArticlesTest extends TestCase
|
|||
$this->assertEquals('my-title', $article->titleurl);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function markdownContentIsConverted(): void
|
||||
{
|
||||
$article = new Article;
|
||||
|
@ -33,7 +34,7 @@ class ArticlesTest extends TestCase
|
|||
$this->assertEquals('<p>Some <em>markdown</em></p>' . PHP_EOL, $article->html);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weGenerateTheDifferentTimeAttributes(): void
|
||||
{
|
||||
$article = Article::create([
|
||||
|
@ -47,7 +48,7 @@ class ArticlesTest extends TestCase
|
|||
$this->assertEquals($article->pubdate, $article->updated_at->toRSSString());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weGenerateTheArticleLinkFromTheSlug(): void
|
||||
{
|
||||
$article = Article::create([
|
||||
|
@ -62,7 +63,7 @@ class ArticlesTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function dateScopeReturnsExpectedArticles(): void
|
||||
{
|
||||
Article::factory()->create([
|
||||
|
@ -81,7 +82,7 @@ class ArticlesTest extends TestCase
|
|||
$this->assertCount(2, $emptyScope);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function dateScopeReturnsExpectedArticlesForDecember(): void
|
||||
{
|
||||
Article::factory()->create([
|
||||
|
|
|
@ -10,14 +10,15 @@ use GuzzleHttp\Client;
|
|||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BookmarksTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
/*
|
||||
* @\test
|
||||
*
|
||||
* @group puppeteer
|
||||
* @\group puppeteer
|
||||
*
|
||||
public function takeScreenshotOfDuckDuckGo()
|
||||
{
|
||||
|
@ -25,7 +26,7 @@ class BookmarksTest extends TestCase
|
|||
$this->assertTrue(file_exists(public_path() . '/assets/img/bookmarks/' . $uuid . '.png'));
|
||||
}*/
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function archiveLinkMethodCallsArchiveService(): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
|
@ -38,7 +39,7 @@ class BookmarksTest extends TestCase
|
|||
$this->assertEquals('/web/1234/example.org', $url);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function archiveLinkMethodThrowsAnExceptionOnError(): void
|
||||
{
|
||||
$this->expectException(InternetArchiveException::class);
|
||||
|
@ -52,7 +53,7 @@ class BookmarksTest extends TestCase
|
|||
(new BookmarkService)->getArchiveLink('https://example.org');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function archiveLinkMethodThrowsAnExceptionIfNoLocationReturned(): void
|
||||
{
|
||||
$this->expectException(InternetArchiveException::class);
|
||||
|
|
|
@ -4,28 +4,27 @@ declare(strict_types=1);
|
|||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HelpersTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function normalizeUrlIsIdempotent(): void
|
||||
{
|
||||
$input = 'http://example.org:80/index.php?foo=bar&baz=1';
|
||||
$this->assertEquals(normalize_url(normalize_url($input)), normalize_url($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @dataProvider urlProvider
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('urlProvider')]
|
||||
public function normalizeUrlOnDataProvider(string $input, string $output): void
|
||||
{
|
||||
$this->assertEquals($output, normalize_url($input));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function prettyPrintJson(): void
|
||||
{
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
|
|
|
@ -6,13 +6,14 @@ namespace Tests\Unit\Jobs;
|
|||
|
||||
use App\Jobs\AddClientToDatabase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AddClientToDatabaseJobTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function clientIsAddedToDatabaseByJob(): void
|
||||
{
|
||||
$job = new AddClientToDatabase('https://example.org/client');
|
||||
|
|
|
@ -10,6 +10,7 @@ use GuzzleHttp\Handler\MockHandler;
|
|||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\FileSystem\FileSystem;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DownloadWebMentionJobTest extends TestCase
|
||||
|
@ -23,7 +24,7 @@ class DownloadWebMentionJobTest extends TestCase
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function htmlIsSavedByJob(): void
|
||||
{
|
||||
$this->assertFileDoesNotExist(storage_path('HTML/https'));
|
||||
|
@ -51,7 +52,7 @@ class DownloadWebMentionJobTest extends TestCase
|
|||
$this->assertFileDoesNotExist(storage_path('HTML/https/example.org/reply') . '/1.' . date('Y-m-d') . '.backup');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function htmlAndBackupSavedByJob(): void
|
||||
{
|
||||
$this->assertFileDoesNotExist(storage_path('HTML/https'));
|
||||
|
@ -86,7 +87,7 @@ class DownloadWebMentionJobTest extends TestCase
|
|||
$this->assertFileExists(storage_path('HTML/https/example.org/reply') . '/1.' . date('Y-m-d') . '.backup');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function indexHtmlFileIsSavedByJobForUrlsEndingWithSlash(): void
|
||||
{
|
||||
$this->assertFileDoesNotExist(storage_path('HTML/https'));
|
||||
|
|
|
@ -11,13 +11,14 @@ use App\Models\Bookmark;
|
|||
use App\Services\BookmarkService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProcessBookmarkJobTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function archiveLinkIsSavedByJobAndScreenshotJobIsQueued(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -38,7 +39,7 @@ class ProcessBookmarkJobTest extends TestCase
|
|||
Queue::assertPushed(SaveScreenshot::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function archiveLinkSavedAsNullWhenExceptionThrown(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
|
|
@ -7,11 +7,12 @@ namespace Tests\Unit\Jobs;
|
|||
use App\Jobs\ProcessMedia;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\ImageManager;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProcessMediaJobTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function nonMediaFilesAreNotSaved(): void
|
||||
{
|
||||
$manager = app()->make(ImageManager::class);
|
||||
|
@ -22,7 +23,7 @@ class ProcessMediaJobTest extends TestCase
|
|||
$this->assertFileDoesNotExist(storage_path('app/media/') . 'file.txt');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function smallImagesAreNotResized(): void
|
||||
{
|
||||
$manager = app()->make(ImageManager::class);
|
||||
|
@ -37,7 +38,7 @@ class ProcessMediaJobTest extends TestCase
|
|||
Storage::disk('local')->delete('public/media');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function largeImagesHaveSmallerImagesCreated(): void
|
||||
{
|
||||
$manager = app()->make(ImageManager::class);
|
||||
|
@ -45,16 +46,17 @@ class ProcessMediaJobTest extends TestCase
|
|||
$job = new ProcessMedia('test-image.jpg');
|
||||
$job->handle($manager);
|
||||
|
||||
Storage::disk('local')->assertExists('public/media/test-image.jpg');
|
||||
Storage::disk('local')->assertExists('public/media/test-image-small.jpg');
|
||||
Storage::disk('local')->assertExists('public/media/test-image-medium.jpg');
|
||||
// These need to look in public disk
|
||||
Storage::disk('public')->assertExists('media/test-image.jpg');
|
||||
Storage::disk('public')->assertExists('media/test-image-small.jpg');
|
||||
Storage::disk('public')->assertExists('media/test-image-medium.jpg');
|
||||
|
||||
$this->assertFileDoesNotExist(storage_path('app/media/') . 'test-image.jpg');
|
||||
|
||||
// Tidy up files created by the job
|
||||
Storage::disk('local')->delete('public/media/test-image.jpg');
|
||||
Storage::disk('local')->delete('public/media/test-image-small.jpg');
|
||||
Storage::disk('local')->delete('public/media/test-image-medium.jpg');
|
||||
Storage::disk('public')->delete('media/test-image.jpg');
|
||||
Storage::disk('public')->delete('media/test-image-small.jpg');
|
||||
Storage::disk('public')->delete('media/test-image-medium.jpg');
|
||||
$this->removeDirIfEmpty(storage_path('app/public/media'));
|
||||
$this->removeDirIfEmpty(storage_path('app/media'));
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ use Illuminate\FileSystem\FileSystem;
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Jonnybarnes\WebmentionsParser\Parser;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProcessWebMentionJobTest extends TestCase
|
||||
|
@ -32,7 +33,7 @@ class ProcessWebMentionJobTest extends TestCase
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function failureGettingWebmentionThrowsAnException(): void
|
||||
{
|
||||
$this->expectException(RemoteContentNotFoundException::class);
|
||||
|
@ -51,7 +52,7 @@ class ProcessWebMentionJobTest extends TestCase
|
|||
$job->handle($parser, $client);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function newWebmentionGetsSavedByJob(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -83,7 +84,7 @@ class ProcessWebMentionJobTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function existingWebmentionGetsUpdatedByJob(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
@ -120,7 +121,7 @@ class ProcessWebMentionJobTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function webmentionReplyGetsDeletedWhenReplyToValueChanges(): void
|
||||
{
|
||||
$parser = new Parser;
|
||||
|
@ -157,7 +158,7 @@ class ProcessWebMentionJobTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function webmentionLikeGetsDeletedWhenLikeOfValueChanges(): void
|
||||
{
|
||||
$parser = new Parser;
|
||||
|
@ -194,7 +195,7 @@ class ProcessWebMentionJobTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function webmentionRepostGetsDeletedWhenRepostOfValueChanges(): void
|
||||
{
|
||||
$parser = new Parser;
|
||||
|
|
|
@ -11,6 +11,7 @@ use GuzzleHttp\HandlerStack;
|
|||
use GuzzleHttp\Psr7\Response;
|
||||
use Jonnybarnes\WebmentionsParser\Authorship;
|
||||
use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SaveProfileImageJobTest extends TestCase
|
||||
|
@ -24,7 +25,7 @@ class SaveProfileImageJobTest extends TestCase
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function authorshipAlgorithmReturnsNullOnException(): void
|
||||
{
|
||||
$mf = ['items' => []];
|
||||
|
@ -36,7 +37,7 @@ class SaveProfileImageJobTest extends TestCase
|
|||
$this->assertNull($job->handle($authorship));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weDoNotProcessTwitterImages(): void
|
||||
{
|
||||
$mf = ['items' => []];
|
||||
|
@ -54,7 +55,7 @@ class SaveProfileImageJobTest extends TestCase
|
|||
$this->assertNull($job->handle($authorship));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function remoteAuthorImagesAreSavedLocally(): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
|
@ -79,7 +80,7 @@ class SaveProfileImageJobTest extends TestCase
|
|||
$this->assertFileExists(public_path() . '/assets/profile-images/example.org/image');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function localDefaultAuthorImageIsUsedAsFallback(): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
|
@ -107,7 +108,7 @@ class SaveProfileImageJobTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weGetUrlFromPhotoObjectIfAltTextIsProvided(): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
|
@ -135,7 +136,7 @@ class SaveProfileImageJobTest extends TestCase
|
|||
$this->assertFileExists(public_path() . '/assets/profile-images/example.org/image');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function useFirstUrlIfMultipleHomepagesAreProvided(): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
|
|
|
@ -13,13 +13,14 @@ use GuzzleHttp\Middleware;
|
|||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SaveScreenshotJobTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function screenshotIsSavedByJob(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
@ -84,7 +85,7 @@ class SaveScreenshotJobTest extends TestCase
|
|||
Storage::disk('public')->assertExists('/assets/img/bookmarks/' . $bookmark->screenshot . '.png');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function screenshotJobHandlesUnfinishedTasks(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
|
|
@ -10,11 +10,12 @@ use GuzzleHttp\Client;
|
|||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SendWebMentionJobTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function discoverWebmentionEndpointOnOwnDomain(): void
|
||||
{
|
||||
$note = new Note;
|
||||
|
@ -23,7 +24,7 @@ class SendWebMentionJobTest extends TestCase
|
|||
$this->assertNull($job->discoverWebmentionEndpoint('/notes/tagged/test'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function discoverWebmentionEndpointFromHeaderLinks(): void
|
||||
{
|
||||
$url = 'https://example.org/webmention';
|
||||
|
@ -38,7 +39,7 @@ class SendWebMentionJobTest extends TestCase
|
|||
$this->assertEquals($url, $job->discoverWebmentionEndpoint('https://example.org'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function discoverWebmentionEndpointFromHtmlLinkTags(): void
|
||||
{
|
||||
$html = '<link rel="webmention" href="https://example.org/webmention">';
|
||||
|
@ -56,7 +57,7 @@ class SendWebMentionJobTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function discoverWebmentionEndpointFromLegacyHtmlMarkup(): void
|
||||
{
|
||||
$html = '<link rel="http://webmention.org/" href="https://example.org/webmention">';
|
||||
|
@ -74,14 +75,14 @@ class SendWebMentionJobTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function ensureEmptyNoteDoesNotTriggerAnyActions(): void
|
||||
{
|
||||
$job = new SendWebMentions(new Note);
|
||||
$this->assertNull($job->handle());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weResolveRelativeUris(): void
|
||||
{
|
||||
$uri = '/blog/post';
|
||||
|
@ -90,7 +91,7 @@ class SendWebMentionJobTest extends TestCase
|
|||
$this->assertEquals('https://example.org/blog/post', $job->resolveUri($uri, $base));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weSendAWebmentionForANote(): void
|
||||
{
|
||||
$html = '<link rel="http://webmention.org/" href="https://example.org/webmention">';
|
||||
|
@ -110,7 +111,7 @@ class SendWebMentionJobTest extends TestCase
|
|||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function linksInNotesCanNotSupportWebmentions(): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
|
|
|
@ -11,13 +11,14 @@ use GuzzleHttp\HandlerStack;
|
|||
use GuzzleHttp\Middleware;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SyndicateNoteToBlueskyJobTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weSyndicateNotesToBluesky(): void
|
||||
{
|
||||
config(['bridgy.bluesky_token' => 'test']);
|
||||
|
@ -38,7 +39,7 @@ class SyndicateNoteToBlueskyJobTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weSyndicateTheOriginalMarkdownToBluesky(): void
|
||||
{
|
||||
config(['bridgy.bluesky_token' => 'test']);
|
||||
|
|
|
@ -11,13 +11,14 @@ use GuzzleHttp\HandlerStack;
|
|||
use GuzzleHttp\Middleware;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SyndicateNoteToMastodonJobTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weSyndicateNotesToMastodon(): void
|
||||
{
|
||||
config(['bridgy.mastodon_token' => 'test']);
|
||||
|
@ -38,7 +39,7 @@ class SyndicateNoteToMastodonJobTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weSyndicateTheOriginalMarkdown(): void
|
||||
{
|
||||
config(['bridgy.mastodon_token' => 'test']);
|
||||
|
|
|
@ -6,13 +6,14 @@ namespace Tests\Unit;
|
|||
|
||||
use App\Models\Like;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LikesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weCanSetTheAuthorUrl(): void
|
||||
{
|
||||
$like = new Like;
|
||||
|
@ -20,7 +21,7 @@ class LikesTest extends TestCase
|
|||
$this->assertEquals('https://joe.bloggs', $like->author_url);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weDoNotModifyPlainTextContent(): void
|
||||
{
|
||||
$like = new Like;
|
||||
|
@ -31,7 +32,7 @@ class LikesTest extends TestCase
|
|||
$this->assertEquals('some plaintext content', $like->content);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weCanHandleBlankContent(): void
|
||||
{
|
||||
$like = new Like;
|
||||
|
@ -42,7 +43,7 @@ class LikesTest extends TestCase
|
|||
$this->assertNull($like->content);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function htmlLikeContentIsFiltered(): void
|
||||
{
|
||||
$htmlEvil = <<<'HTML'
|
||||
|
|
|
@ -7,13 +7,14 @@ namespace Tests\Unit;
|
|||
use App\Models\Media;
|
||||
use App\Models\Note;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MediaTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function getTheNoteThatMediaInstanceBelongsTo(): void
|
||||
{
|
||||
$media = Media::factory()->for(Note::factory())->create();
|
||||
|
@ -21,7 +22,7 @@ class MediaTest extends TestCase
|
|||
$this->assertInstanceOf(Note::class, $media->note);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function absoluteUrlsAreReturnedUnmodified(): void
|
||||
{
|
||||
$absoluteUrl = 'https://instagram-cdn.com/image/uuid';
|
||||
|
|
|
@ -7,13 +7,14 @@ namespace Tests\Unit;
|
|||
use App\Models\MicropubClient;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MicropubClientsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weCanGetNotesRelatingToClient(): void
|
||||
{
|
||||
$client = MicropubClient::factory()->make();
|
||||
|
|
|
@ -16,6 +16,7 @@ use GuzzleHttp\Psr7\Response;
|
|||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class NotesTest extends TestCase
|
||||
|
@ -25,9 +26,8 @@ class NotesTest extends TestCase
|
|||
/**
|
||||
* Test the getNoteAttribute method. This will then also call the
|
||||
* relevant sub-methods.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function getNoteAttributeMethodCallsSubMethods(): void
|
||||
{
|
||||
// phpcs:ignore
|
||||
|
@ -40,9 +40,8 @@ class NotesTest extends TestCase
|
|||
|
||||
/**
|
||||
* Look for a default image in the contact’s h-card for the makeHCards method.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function defaultImageUsedAsFallbackInMakehcardsMethod(): void
|
||||
{
|
||||
// phpcs:ignore
|
||||
|
@ -70,9 +69,8 @@ class NotesTest extends TestCase
|
|||
|
||||
/**
|
||||
* Look for a specific profile image in the contact’s h-card.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function specificProfileImageUsedInMakehcardsMethod(): void
|
||||
{
|
||||
Contact::factory()->create([
|
||||
|
@ -106,9 +104,8 @@ class NotesTest extends TestCase
|
|||
|
||||
/**
|
||||
* Look for twitter URL when there’s no associated contact.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function twitterLinkIsCreatedWhenNoContactFound(): void
|
||||
{
|
||||
$expected = '<p>Hi <a href="https://twitter.com/bob">@bob</a></p>' . PHP_EOL;
|
||||
|
@ -118,7 +115,7 @@ class NotesTest extends TestCase
|
|||
$this->assertEquals($expected, $note->note);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function shorturlMethodReturnsExpectedValue(): void
|
||||
{
|
||||
$note = Note::factory()->make();
|
||||
|
@ -126,7 +123,7 @@ class NotesTest extends TestCase
|
|||
$this->assertEquals(config('url.shorturl') . '/notes/E', $note->shorturl);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weGetLatitudeLongitudeValuesOfAssociatedPlaceOfNote(): void
|
||||
{
|
||||
$place = Place::factory()->create([
|
||||
|
@ -140,7 +137,7 @@ class NotesTest extends TestCase
|
|||
$this->assertEquals('-2.3805', $note->longitude);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function whenNoAssociatedPlaceWeGetNullForLatitudeLongitudeValues(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -148,7 +145,7 @@ class NotesTest extends TestCase
|
|||
$this->assertNull($note->longitude);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function weCanGetAddressAttributeForAssociatedPlace(): void
|
||||
{
|
||||
$place = Place::factory()->create([
|
||||
|
@ -162,7 +159,7 @@ class NotesTest extends TestCase
|
|||
$this->assertEquals('The Bridgewater Pub', $note->address);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function deletingNotesAlsoDeletesTagsViaTheEventObserver(): void
|
||||
{
|
||||
// first we’ll create a temporary note to delete
|
||||
|
@ -177,7 +174,7 @@ class NotesTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function saveBlankNotesAsNull(): void
|
||||
{
|
||||
$note = new Note(['note' => '']);
|
||||
|
@ -185,7 +182,7 @@ class NotesTest extends TestCase
|
|||
$this->assertNull($note->note);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function reverseGeocodeAnAttraction(): void
|
||||
{
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
|
@ -210,7 +207,7 @@ class NotesTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function reverseGeocodeASuburb(): void
|
||||
{
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
|
@ -235,7 +232,7 @@ class NotesTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function reverseGeocodeACity(): void
|
||||
{
|
||||
// Note I’ve modified this JSON response so it only contains the
|
||||
|
@ -262,7 +259,7 @@ class NotesTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function reverseGeocodeACounty(): void
|
||||
{
|
||||
// Note I’ve removed everything below county to test for queries where
|
||||
|
@ -286,7 +283,7 @@ class NotesTest extends TestCase
|
|||
$this->assertEquals('<span class="p-region">Kent</span>, <span class="p-country-name">UK</span>', $address);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function reverseGeocodeACountry(): void
|
||||
{
|
||||
// Note I’ve removed everything below country to test for querires where
|
||||
|
@ -310,7 +307,7 @@ class NotesTest extends TestCase
|
|||
$this->assertEquals('<span class="p-country-name">Ireland</span>', $address);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function addImageElementToNoteContentWhenMediaAssociated(): void
|
||||
{
|
||||
$media = Media::factory()->create([
|
||||
|
@ -327,7 +324,7 @@ class NotesTest extends TestCase
|
|||
$this->assertEquals($expected, $note->content);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function addVideoElementToNoteContentWhenMediaAssociated(): void
|
||||
{
|
||||
$media = Media::factory()->create([
|
||||
|
@ -344,7 +341,7 @@ class NotesTest extends TestCase
|
|||
$this->assertEquals($expected, $note->content);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function addAudioElementToNoteContentWhenMediaAssociated(): void
|
||||
{
|
||||
$media = Media::factory()->create([
|
||||
|
@ -362,10 +359,9 @@ class NotesTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @todo Why do we need to provide text?
|
||||
*/
|
||||
#[Test]
|
||||
public function provideTextForBlankContent(): void
|
||||
{
|
||||
$note = new Note;
|
||||
|
@ -382,9 +378,8 @@ class NotesTest extends TestCase
|
|||
|
||||
$this->assertNull($note->twitter);
|
||||
}*/
|
||||
|
||||
/** @test */
|
||||
public function markdownContentGetsConverted(): void
|
||||
#[Test]
|
||||
public function markdown_content_gets_converted(): void
|
||||
{
|
||||
$note = Note::factory()->create([
|
||||
'note' => 'The best search engine? https://duckduckgo.com',
|
||||
|
@ -398,9 +393,8 @@ class NotesTest extends TestCase
|
|||
|
||||
/**
|
||||
* For now, just reply on a cached object instead of actually querying Twitter.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function checkInReplyToIsTwitterLink(): void
|
||||
{
|
||||
$tempContent = (object) [
|
||||
|
@ -415,7 +409,7 @@ class NotesTest extends TestCase
|
|||
$this->assertEquals($tempContent, $note->twitter);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function latitudeAndLongitudeCanBeParsedFromPlainLocation(): void
|
||||
{
|
||||
$note = Note::factory()->create([
|
||||
|
@ -426,7 +420,7 @@ class NotesTest extends TestCase
|
|||
$this->assertSame(4.56, $note->longitude);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function addressAttributeCanBeRetrievedFromPlainLocation(): void
|
||||
{
|
||||
Cache::put('1.23,4.56', '<span class="p-country-name">Antarctica</span>');
|
||||
|
@ -438,7 +432,7 @@ class NotesTest extends TestCase
|
|||
$this->assertSame('<span class="p-country-name">Antarctica</span>', $note->address);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mastodonUsernamesAreParsedCorrectly(): void
|
||||
{
|
||||
$expected = '<p>Hi <a href="https://phpc.social/@freekmurze">@freekmurze@phpc.social</a> how are you?</p>' . PHP_EOL;
|
||||
|
|
|
@ -10,13 +10,14 @@ use App\Services\PlaceService;
|
|||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PlacesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function canRetrieveAssociatedNotes(): void
|
||||
{
|
||||
$place = Place::factory()->create();
|
||||
|
@ -27,7 +28,7 @@ class PlacesTest extends TestCase
|
|||
$this->assertCount(5, $place->notes);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function nearMethodReturnsCollection(): void
|
||||
{
|
||||
Place::factory()->create([
|
||||
|
@ -39,7 +40,7 @@ class PlacesTest extends TestCase
|
|||
$this->assertEquals('the-bridgewater-pub', $nearby[0]->slug);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function getLongurl(): void
|
||||
{
|
||||
$place = Place::factory()->create([
|
||||
|
@ -48,7 +49,7 @@ class PlacesTest extends TestCase
|
|||
$this->assertEquals(config('app.url') . '/places/the-bridgewater-pub', $place->longurl);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function getShorturl()
|
||||
{
|
||||
$place = Place::factory()->create([
|
||||
|
@ -57,7 +58,7 @@ class PlacesTest extends TestCase
|
|||
$this->assertEquals(config('url.shorturl') . '/places/the-bridgewater-pub', $place->shorturl);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function getUri(): void
|
||||
{
|
||||
$place = Place::factory()->create([
|
||||
|
@ -66,7 +67,7 @@ class PlacesTest extends TestCase
|
|||
$this->assertEquals(config('app.url') . '/places/the-bridgewater-pub', $place->uri);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function placeServiceReturnsExistingPlaceBasedOnExternalUrlsSearch(): void
|
||||
{
|
||||
Place::factory(10)->create();
|
||||
|
@ -86,7 +87,7 @@ class PlacesTest extends TestCase
|
|||
$this->assertCount(11, Place::all());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function placeServiceRequiresNameWhenCreatingNewPlace(): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
@ -96,7 +97,7 @@ class PlacesTest extends TestCase
|
|||
$service->createPlaceFromCheckin(['foo' => 'bar']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function placeServiceRequiresLatitudeWhenCreatingNewPlace(): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
@ -106,7 +107,7 @@ class PlacesTest extends TestCase
|
|||
$service->createPlaceFromCheckin(['properties' => ['name' => 'bar']]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function placeServiceCanUpdateExternalUrls(): void
|
||||
{
|
||||
$place = Place::factory()->create([
|
||||
|
|
|
@ -8,13 +8,15 @@ use App\Models\Bookmark;
|
|||
use App\Models\Note;
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TagsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function canGetAssociatedNotes(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -23,7 +25,7 @@ class TagsTest extends TestCase
|
|||
$this->assertCount(1, $tag->notes);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function canGetAssociatedBookmarks(): void
|
||||
{
|
||||
$bookmark = Bookmark::factory()->create();
|
||||
|
@ -32,11 +34,8 @@ class TagsTest extends TestCase
|
|||
$this->assertCount(1, $tag->bookmarks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @dataProvider tagsProvider
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('tagsProvider')]
|
||||
public function canNormalize(string $input, string $expected): void
|
||||
{
|
||||
$this->assertSame($expected, Tag::normalize($input));
|
||||
|
|
|
@ -10,13 +10,14 @@ use Codebird\Codebird;
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WebMentionTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function commentableMethodLinksToNotes(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
|
@ -27,7 +28,7 @@ class WebMentionTest extends TestCase
|
|||
$this->assertInstanceOf(Note::class, $webmention->commentable);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function publishedAttributeUsesUpdatedAtWhenNoRelevantMf2Data(): void
|
||||
{
|
||||
$webmention = new WebMention;
|
||||
|
@ -36,7 +37,7 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($updated_at->toDayDateTimeString(), $webmention->published);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function publishedAttributeUsesUpdatedAtWhenErrorParsingMf2Data(): void
|
||||
{
|
||||
$webmention = new WebMention;
|
||||
|
@ -54,7 +55,7 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($updated_at->toDayDateTimeString(), $webmention->published);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function createPhotoLinkDoesNothingWithGenericUrlAndNoLocallySavedImage(): void
|
||||
{
|
||||
$webmention = new WebMention;
|
||||
|
@ -63,7 +64,7 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($homepage));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function createPhotoLinkReturnsLocallySavedImageUrlIfItExists(): void
|
||||
{
|
||||
$webmention = new WebMention;
|
||||
|
@ -72,7 +73,7 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($homepage));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function createPhotoLinkDealsWithSpecialCaseOfDirectTwitterPhotoLinks(): void
|
||||
{
|
||||
$webmention = new WebMention;
|
||||
|
@ -81,7 +82,7 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($twitterProfileImage));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function createPhotoLinkReturnsCachedTwitterPhotoLinks(): void
|
||||
{
|
||||
$webmention = new WebMention;
|
||||
|
@ -91,16 +92,15 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($twitterURL));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function createPhotoLinkResolvesTwitterPhotoLinks(): void
|
||||
{
|
||||
$info = (object) [
|
||||
'profile_image_url_https' => 'https://pbs.twimg.com/static_profile_link.jpg',
|
||||
];
|
||||
$codebirdMock = $this->getMockBuilder(Codebird::class)
|
||||
->addMethods(['users_show'])
|
||||
->getMock();
|
||||
$codebirdMock->method('users_show')
|
||||
$codebirdMock = $this->createPartialMock(Codebird::class, ['__call']);
|
||||
$codebirdMock->method('__call')
|
||||
->with('users_show', $this->anything())
|
||||
->willReturn($info);
|
||||
$this->app->instance(Codebird::class, $codebirdMock);
|
||||
|
||||
|
@ -117,14 +117,14 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($twitterURL));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function getReplyAttributeDefaultsToNull(): void
|
||||
{
|
||||
$webmention = new WebMention;
|
||||
$this->assertNull($webmention->reply);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function getReplyAttributeWithMf2WithoutHtmlReturnsNull(): void
|
||||
{
|
||||
$webmention = new WebMention;
|
||||
|
|
Loading…
Add table
Reference in a new issue