Skip to content

Commit

Permalink
Merge pull request rrze-mmz#60 from rrze-mmz/increase-test-coverage
Browse files Browse the repository at this point in the history
Add more tests to increase test coverage
  • Loading branch information
stefanosgeo authored Feb 27, 2024
2 parents d08fe08 + 18aa326 commit 99e42a2
Show file tree
Hide file tree
Showing 29 changed files with 2,668 additions and 53 deletions.
4 changes: 4 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,16 @@ [email protected]:/tides/tides.git
DEPLOY_BRANCH=testing
DEPLOY_BASE_DIR=/srv/www


ADMIN_MAIL_ADDRESS=[email protected]
DEV_MAIL_ADDRESS=[email protected]
SUPPORT_MAIL_ADDRESS=[email protected]

CHECK_FAUTV_VIDEOLINKS=true
FAUTV_USER_IP=127.0.0.1
DEFAULT_IMAGE_ID=1
CDN_SERVER_URL=http://localhost/
CDN_SERVER_SECRET='YOUR_SERVER_SECRET'

FEEDS_DEFAULT_OWNER_NAME = Tides
FEEDS_DEFAULT_OWNER_EMAIL = [email protected]
Expand Down
18 changes: 7 additions & 11 deletions app/Console/Commands/CheckTimeAvailabilityClips.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,15 @@ public function handle(): int
"ClipID: {$clip->id} / Title:{$clip->episode} {$clip->title} is still available for users"
);
}
} elseif ($now->lessThan($clip->time_availability_start)) {
if ($clip->is_public) {
$clip->is_public = false;
$this->info(
"ClipID: {$clip->id} / Title:{$clip->episode} {$clip->title} will be withdrawn for users"
);
} else {
$this->info("ClipID: {$clip->id} / Title:{$clip->episode} {$clip->title} should remain offline");
}
} elseif ($now->lessThan($clip->time_availability_start) && $clip->is_public) {
$clip->is_public = false;
$this->info(
"ClipID: {$clip->id} / Title:{$clip->episode} {$clip->title} will be withdrawn for users"
);
} else {
$this
->info("ClipID: {$clip->id} / Title:{$clip->episode} {$clip->title} does not
met the criteria for checks");
->info("ClipID: {$clip->id} / Title:{$clip->episode} {$clip->title} does not met the criteria".
'for checks');
}

$clip->save();
Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/FetchOpencastAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Http\Controllers\Backend\Traits\Transferable;
use App\Models\Clip;
use App\Services\OpencastService;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

Expand Down Expand Up @@ -63,7 +62,7 @@ public function handle(OpencastService $opencastService): int
$events = $opencastService->getProcessedEventsBySeriesID($clip->series->opencast_series_id);

$events->each(function ($event) use ($clip, $opencastService) {
if ($clip->created_at->format('Y-m-d') === Carbon::parse($event['created'])->format('Y-m-d')) {
if ($clip->opencast_event_id === $event['identifier']) {
$this->checkOpencastAssetsForClipUpload($clip, $event['identifier'], $opencastService);
$this->info("Videos from Clip {$clip->title} is online");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class OpencastMutlipleIngest extends Command
class OpencastMultipleIngest extends Command
{
/**
* The name and signature of the consoleq command.
* The name and signature of the console command.
*
* @var string
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Backend/AssetsTransferController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use App\Http\Controllers\Backend\Traits\Transferable;
use App\Http\Controllers\Controller;
use App\Http\Requests\UploadAssetRequest;
use App\Models\Clip;
use App\Models\Traits\UploadAssetRequest;
use App\Services\OpencastService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/Backend/TriggerSmilFilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class TriggerSmilFilesController extends Controller
*/
public function __invoke(Clip $clip, WowzaService $wowzaService): RedirectResponse
{
$this->authorize('edit', $clip);

$wowzaService->createSmilFile($clip);

session()->flash('flashMessage', "{$clip->title} smil files created successfully");
Expand Down
17 changes: 0 additions & 17 deletions app/Http/Controllers/Backend/UploadChannelBanner.php

This file was deleted.

3 changes: 3 additions & 0 deletions app/Models/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Notifications\DatabaseNotification;

class Notification extends DatabaseNotification
{
use HasFactory;

public function users(): BelongsTo
{
return $this->belongsTo(User::class, 'notifiable_id');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Requests;
namespace App\Models\Traits;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
Expand Down
4 changes: 2 additions & 2 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ function findUserByOpencastRole(string $opencastRole): User|string
function getProtectedUrl(string $filePath): string
{
$filePath = '/'.$filePath;
$secret = 'emsJue5Rtv7';
$cdn = 'https://vp-cdn-balance.rrze.de/media_bu/';
$secret = config('settings.portal.cdn_server_secret');
$cdn = config('settings.portal.cdn_server_url');
$hexTime = dechex(time());
$userIP = (App::environment(['testing', 'local'])) ? env('FAUTV_USER_IP') : $_SERVER['REMOTE_ADDR'];
$token = md5($secret.$filePath.$hexTime.$userIP);
Expand Down
2 changes: 2 additions & 0 deletions config/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
'deploy_repo' => env('DEPLOY_REPO', '[email protected]/mmz/tides'),
'deploy_branch' => env('DEPLOY_BRANCH', 'main'),
'admin_main_address' => env('ADMIN_MAIL_ADDRESS', '[email protected]'),
'cdn_server_url' => env('CDN_SERVER_URL', 'http://localhost/'),
'cdn_server_secret' => env('CDN_SERVER_SECRET', 'dsnJ23fjeq!'),
],
'user' => [
'accept_use_terms' => false,
Expand Down
4 changes: 1 addition & 3 deletions database/factories/AssetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ class AssetFactory extends Factory

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
$uploadedFile = UploadedFile::fake()->create('video.mp4', '10000', 'video/mp4');

Expand Down
9 changes: 7 additions & 2 deletions database/factories/LivestreamFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ class LivestreamFactory extends Factory
public function definition(): array
{
return [
'name' => $this->faker->title,
'url' => $this->faker->url,
'clip_id' => null,
'name' => 'test-lecture-hall',
'url' => 'wowza_livestream_url',
'content_path' => 'wowza_content_path',
'file_path' => 'wowza_file_path',
'active' => false,
'app_name' => 'test-lecture-hall',
];
}
}
31 changes: 31 additions & 0 deletions database/factories/NotificationFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Database\Factories;

use App\Models\Notification;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends Factory<Notification>
*/
class NotificationFactory extends Factory
{
protected $model = Notification::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => '1',
'type' => 'notification_type',
'notifiable_type' => 'user',
'notifiable_id' => User::factory()->create()->id,
'data' => 'data',
];
}
}
Loading

0 comments on commit 99e42a2

Please sign in to comment.