You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.4 KiB
74 lines
2.4 KiB
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\PublicSourceChannel;
|
|
// use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Tests\TestCase;
|
|
|
|
class ExampleTest extends TestCase
|
|
{
|
|
/**
|
|
* A basic test example.
|
|
*/
|
|
public function test_the_application_returns_a_successful_response(): void
|
|
{
|
|
$response = $this->get('/');
|
|
|
|
$response
|
|
->assertOk()
|
|
->assertSee('2026江苏省新消费创新创业大赛')
|
|
->assertSee('href="admin/c/xxf/login"', false);
|
|
}
|
|
|
|
public function test_homepage_signup_link_preserves_public_source(): void
|
|
{
|
|
config([
|
|
'database.default' => 'sqlite',
|
|
'database.connections.sqlite' => [
|
|
'driver' => 'sqlite',
|
|
'database' => ':memory:',
|
|
'prefix' => '',
|
|
'foreign_key_constraints' => false,
|
|
],
|
|
]);
|
|
DB::purge();
|
|
DB::reconnect();
|
|
Schema::create('public_source_channels', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('source_code', 64)->unique();
|
|
$table->string('source_name', 100);
|
|
$table->string('status')->default(PublicSourceChannel::STATUS_ENABLED);
|
|
$table->timestamps();
|
|
});
|
|
PublicSourceChannel::query()->create([
|
|
'source_code' => 'poster_A',
|
|
'source_name' => '海报 A',
|
|
'status' => PublicSourceChannel::STATUS_ENABLED,
|
|
]);
|
|
PublicSourceChannel::query()->create([
|
|
'source_code' => 'closed_src',
|
|
'source_name' => '停用渠道',
|
|
'status' => PublicSourceChannel::STATUS_DISABLED,
|
|
]);
|
|
|
|
$this->get('/?src=poster_A')
|
|
->assertOk()
|
|
->assertSee('href="admin/c/xxf/login"', false)
|
|
->assertSee("localStorage.setItem('cxxfds_public_source_code'", false)
|
|
->assertSee('poster_A');
|
|
|
|
$this->get('/?src=bad%20code')
|
|
->assertOk()
|
|
->assertSee('href="admin/c/xxf/login"', false)
|
|
->assertDontSee("localStorage.setItem('cxxfds_public_source_code'", false);
|
|
|
|
$this->get('/?src=closed_src')
|
|
->assertOk()
|
|
->assertDontSee("localStorage.setItem('cxxfds_public_source_code'", false);
|
|
}
|
|
}
|