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.

100 lines
3.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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('首届沪苏协同新兴产业科创大赛', false)
->assertSee('参赛报名', false)
->assertSee('观众报名', false)
->assertSee('/admin/c/hsxt/login', false)
->assertSee('/admin/c/hsxt/audience/login', false)
->assertSee('href="/en"', false)
->assertSee('>EN</a>', false);
}
public function test_english_homepage_returns_a_successful_response(): void
{
$response = $this->get('/en');
$response
->assertOk()
->assertSee('Inaugural ShanghaiSuzhou Collaborative Emerging Industries Science &amp; Technology Innovation Competition', false)
->assertSee('COMPETE', false)
->assertSee('ATTEND', false)
->assertSee('/admin/c/hsxt/login?lang=en', false)
->assertSee('/admin/c/hsxt/audience/login?lang=en', false)
->assertSee('href="/" lang="zh-CN"', false)
->assertSee('>中文</a>', false)
->assertSee('hero-banner hero-banner--photonic', false);
$this->assertFileExists(public_path('en/index.php'));
$this->assertFileExists(public_path('en/index.html'));
$this->assertFileExists(public_path('frontend/event-site-en.html'));
}
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('/admin/c/hsxt/login', false)
->assertSee('/admin/c/hsxt/audience/login', false)
->assertSee('localStorage.setItem("cxxfds_public_source_code"', false)
->assertSee('poster_A');
$this->get('/?src=bad%20code')
->assertOk()
->assertSee('/admin/c/hsxt/login', false)
->assertDontSee('localStorage.setItem("cxxfds_public_source_code"', false);
$this->get('/?src=closed_src')
->assertOk()
->assertDontSee('localStorage.setItem("cxxfds_public_source_code"', false);
}
}