From c74456bdf1d96390509bc14d9dace0d17dc20f5a Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 20 Aug 2026 10:59:26 +0200 Subject: [PATCH] Fix URL --- resources/views/partials/sidebar.blade.php | 5 +- routes/web.php | 2 +- tests/Feature/BtcPaymentLinkTest.php | 145 +++++++++++++++++++++ 3 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 tests/Feature/BtcPaymentLinkTest.php diff --git a/resources/views/partials/sidebar.blade.php b/resources/views/partials/sidebar.blade.php index 167f8a0d1..cb5c5d6d0 100644 --- a/resources/views/partials/sidebar.blade.php +++ b/resources/views/partials/sidebar.blade.php @@ -162,12 +162,12 @@ @endphp @if($userRole !== 'Admin') @if($userRole === 'User') - + Upgrade Your Account @else - + Extend Your Account @@ -186,4 +186,3 @@ @endauth - diff --git a/routes/web.php b/routes/web.php index 692a8b5d3..cbd993ee3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -368,7 +368,7 @@ Route::middleware('role_or_permission:Admin|Moderator|edit release')->prefix('ad // Redirect btcpay route to btc payment server Route::get('btcpay', function () { - return redirect()->to('https://simplegate.space/apps/3MjgKvosMZtc2sSxiRBwadDCn1zA/pos'); + return redirect()->to('https://example.com'); })->name('btcpay'); // Invitation management routes Route::prefix('invitations')->name('invitations.')->group(function () { diff --git a/tests/Feature/BtcPaymentLinkTest.php b/tests/Feature/BtcPaymentLinkTest.php new file mode 100644 index 000000000..c398deda4 --- /dev/null +++ b/tests/Feature/BtcPaymentLinkTest.php @@ -0,0 +1,145 @@ + + */ + private array $originalEnvironment = []; + + public function createApplication() + { + $this->databasePath = sys_get_temp_dir().'/nntmux-btc-payment-link-test.sqlite'; + + $this->originalEnvironment = [ + 'APP_ENV' => getenv('APP_ENV'), + 'DB_CONNECTION' => getenv('DB_CONNECTION'), + 'DB_DATABASE' => getenv('DB_DATABASE'), + ]; + + if (file_exists($this->databasePath)) { + unlink($this->databasePath); + } + + $pdo = new PDO('sqlite:'.$this->databasePath); + $pdo->exec('CREATE TABLE settings (name VARCHAR PRIMARY KEY, value TEXT NULL)'); + $pdo->exec('CREATE TABLE permissions ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name VARCHAR NOT NULL, + guard_name VARCHAR NOT NULL, + created_at DATETIME NULL, + updated_at DATETIME NULL + )'); + $pdo->exec("INSERT INTO settings (name, value) VALUES + ('categorizeforeign', '0'), + ('catwebdl', '0'), + ('title', 'NNTmux Test'), + ('home_link', '/')"); + + $this->setEnvironmentValue('APP_ENV', 'testing'); + $this->setEnvironmentValue('DB_CONNECTION', 'sqlite'); + $this->setEnvironmentValue('DB_DATABASE', $this->databasePath); + + $app = require __DIR__.'/../../bootstrap/app.php'; + + $app->make(Kernel::class)->bootstrap(); + + return $app; + } + + protected function setUp(): void + { + parent::setUp(); + + config([ + 'database.default' => 'sqlite', + 'database.connections.sqlite.database' => $this->databasePath, + 'app.key' => 'base64:'.base64_encode(random_bytes(32)), + ]); + + Gate::before(static fn (): bool => false); + } + + protected function tearDown(): void + { + if ($this->databasePath !== '' && file_exists($this->databasePath)) { + unlink($this->databasePath); + } + + parent::tearDown(); + + foreach ($this->originalEnvironment as $key => $value) { + $this->setEnvironmentValue($key, $value === false ? null : $value); + } + } + + public function test_btcpay_route_redirects_to_placeholder(): void + { + $this->get(route('btcpay')) + ->assertRedirect('https://example.com'); + } + + public function test_user_sidebar_renders_upgrade_placeholder(): void + { + $this->actingAs($this->userWithRole('User')); + + $this->view('partials.sidebar') + ->assertSee('href="https://example.com"', false) + ->assertSee('Upgrade Your Account') + ->assertDontSee('Extend Your Account'); + } + + public function test_supporter_sidebar_renders_extension_placeholder(): void + { + $this->actingAs($this->userWithRole('Supporter')); + + $this->view('partials.sidebar') + ->assertSee('href="https://example.com"', false) + ->assertSee('Extend Your Account') + ->assertDontSee('Upgrade Your Account'); + } + + private function userWithRole(string $roleName): User + { + $user = new User([ + 'consoleview' => false, + 'movieview' => false, + 'musicview' => false, + 'gameview' => false, + 'xxxview' => false, + 'bookview' => false, + ]); + $user->id = 1; + $user->setRelation('roles', new Collection([new Role(['name' => $roleName])])); + + return $user; + } + + private function setEnvironmentValue(string $key, ?string $value): void + { + if ($value === null) { + putenv($key); + unset($_ENV[$key], $_SERVER[$key]); + + return; + } + + putenv($key.'='.$value); + $_ENV[$key] = $value; + $_SERVER[$key] = $value; + } +}