<?php

namespace Zoomyboy\MedialibraryHelper\Tests\Feature;

use Illuminate\Foundation\Console\VendorPublishCommand;
use Illuminate\Support\Facades\Artisan;
use Spatie\MediaLibrary\MediaLibraryServiceProvider;

afterEach(function () {
    @unlink(config_path('media-library.php'));
});

test('modifies config file', function () {
    Artisan::call(VendorPublishCommand::class, ['--provider' => MediaLibraryServiceProvider::class, '--tag' => 'config']);
    $configContents = file_get_contents(config_path('media-library.php'));
    $configContents = preg_replace('/\'image_driver\' => env.*/', '\'image_driver\' => "lala",', $configContents);
    file_put_contents(config_path('media-library.php'), $configContents);

    $this->tearDownTheTestEnvironment();
    $this->setUpTheTestEnvironment();

    $this->assertEquals('lala', config('media-library.image_driver'));
    $this->assertEquals('temp', config('media-library.temp_disk'));
});
