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.

96 lines
3.4 KiB

5 months ago
<?php
namespace Tests\Feature;
use App\Models\PublicSourceChannel;
5 months ago
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
5 months ago
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()
1 month ago
->assertSee('首届沪苏协同新兴产业科创大赛', false)
->assertSee('参赛报名', false)
->assertSee('观众报名', false)
->assertSee('/admin/c/hsxt/login', false)
1 month ago
->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 Shanghai–Suzhou Collaborative Emerging Industries Science &amp; Technology Innovation Competition', false)
->assertSee('COMPETE', false)
->assertSee('ATTEND', false)
->assertSee('/frontend/layout.html?role=user&amp;lang=en', false)
->assertSee('/frontend/layout.html?role=audience&amp;lang=en', false)
->assertSee('href="/" lang="zh-CN"', false)
->assertSee('>中文</a>', false)
->assertSee('hero-banner hero-banner--photonic', false);
5 months ago
}
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()
1 month ago
->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()
1 month ago
->assertSee('/admin/c/hsxt/login', false)
->assertDontSee('localStorage.setItem("cxxfds_public_source_code"', false);
$this->get('/?src=closed_src')
->assertOk()
1 month ago
->assertDontSee('localStorage.setItem("cxxfds_public_source_code"', false);
}
5 months ago
}