feat: xxbb
This commit is contained in:
@@ -127,6 +127,18 @@ class PageVisitTest extends TestCase
|
||||
$this->assertSame('119.0.6045', $parsed['browser_version']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function user_agent_parser_keeps_ios_patch(): void
|
||||
{
|
||||
$parsed = UserAgentParser::parse(
|
||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_8_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.7 Mobile/15E148 Safari/604.1'
|
||||
);
|
||||
$this->assertSame('iOS', $parsed['os']);
|
||||
$this->assertSame('15.8.4', $parsed['os_version']);
|
||||
$this->assertSame('Safari', $parsed['browser']);
|
||||
$this->assertSame('15.6.7', $parsed['browser_version']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function dashboard_includes_pv_uv(): void
|
||||
{
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Admin;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RawLogControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private function superAdmin(): Admin
|
||||
{
|
||||
return Admin::query()->create([
|
||||
'username' => 'root',
|
||||
'password' => 'secret12',
|
||||
'is_super' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function xxbb_log_show_pages_instead_of_loading_the_whole_file(): void
|
||||
{
|
||||
$dir = public_path('log/xxbb');
|
||||
if (! is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
$file = $dir.'/20990101.log';
|
||||
$chunks = [];
|
||||
for ($i = 1; $i <= 90; $i++) {
|
||||
$chunks[] = '2026-08-14 13:00:00 /event {"n":'.$i.',"marker":"ENTRY-'.$i.'"}';
|
||||
}
|
||||
file_put_contents($file, implode("\r\n\r\n", $chunks)."\r\n\r\n");
|
||||
|
||||
try {
|
||||
$admin = $this->superAdmin();
|
||||
$page1 = $this->actingAs($admin, 'admin')
|
||||
->get(route('admin.logs.show', [
|
||||
'file' => '20990101.log',
|
||||
'kind' => 'xxbb',
|
||||
'per_page' => 40,
|
||||
]))
|
||||
->assertOk();
|
||||
$html1 = $page1->getContent();
|
||||
$this->assertSame(40, substr_count($html1, 'class="json-block"'));
|
||||
$this->assertStringContainsString('ENTRY-90', $html1);
|
||||
$this->assertStringNotContainsString('ENTRY-50', $html1);
|
||||
$this->assertStringContainsString('更早', $html1);
|
||||
|
||||
$page2 = $this->actingAs($admin, 'admin')
|
||||
->get(route('admin.logs.show', [
|
||||
'file' => '20990101.log',
|
||||
'kind' => 'xxbb',
|
||||
'per_page' => 40,
|
||||
'page' => 2,
|
||||
]))
|
||||
->assertOk();
|
||||
$html2 = $page2->getContent();
|
||||
$this->assertStringContainsString('ENTRY-50', $html2);
|
||||
$this->assertStringNotContainsString('ENTRY-90', $html2);
|
||||
} finally {
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,29 @@ class XxbbC2ApiTest extends TestCase
|
||||
$this->assertNull($row->session_id);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function iptj_prefers_ua_patch_over_coarse_device_version(): void
|
||||
{
|
||||
Cache::flush();
|
||||
$ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_8_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.7 Mobile/15E148 Safari/604.1';
|
||||
|
||||
$this->call('POST', '/api/iptj', [], [], [], [
|
||||
'CONTENT_TYPE' => 'application/json',
|
||||
'HTTP_USER_AGENT' => $ua,
|
||||
], json_encode([
|
||||
'channelCode' => '56885688',
|
||||
'deviceVersion' => 'iOS 15.8',
|
||||
'domain' => 'xxbb.tv',
|
||||
]))->assertOk();
|
||||
|
||||
$row = PageVisit::query()->first();
|
||||
$this->assertNotNull($row);
|
||||
$this->assertSame('iOS', $row->os);
|
||||
$this->assertSame('15.8.4', $row->os_version);
|
||||
$this->assertSame('Safari', $row->browser);
|
||||
$this->assertSame('15.6.7', $row->browser_version);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function iptj_dedupes_by_session_id(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user