test: couverture 100% AnalyticsUniqId (29/29 methodes, 67/67 lignes)
tests/Entity/AnalyticsTest.php:
- 16 nouveaux tests pour les methodes statiques de parsing:
- parseDeviceType: desktop (UA Windows), mobile (iPhone, Android),
tablet (iPad)
- parseOs: Windows (Windows NT), macOS (Macintosh), iOS (iPhone sans
Mac OS X dans le UA), Android, Linux, unknown (retourne null)
- parseBrowser: Chrome, Firefox, Edge (Edg/), Safari (sans Chrome),
Opera (OPR/), unknown (retourne null)
AnalyticsUniqId passe de 89.66% (26/29) a 100% (29/29) methodes
et de 56.72% (38/67) a 100% (67/67) lignes
Resultat: 351 tests, 699 assertions, 0 failures
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,84 @@ class AnalyticsTest extends TestCase
|
||||
$this->assertNull($v->getUser());
|
||||
}
|
||||
|
||||
// --- AnalyticsUniqId static parsers ---
|
||||
|
||||
public function testParseDeviceTypeDesktop(): void
|
||||
{
|
||||
$this->assertSame('desktop', AnalyticsUniqId::parseDeviceType('Mozilla/5.0 (Windows NT 10.0; Win64; x64)'));
|
||||
}
|
||||
|
||||
public function testParseDeviceTypeMobile(): void
|
||||
{
|
||||
$this->assertSame('mobile', AnalyticsUniqId::parseDeviceType('Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X)'));
|
||||
$this->assertSame('mobile', AnalyticsUniqId::parseDeviceType('Mozilla/5.0 (Linux; Android 12; Pixel 6) Mobile'));
|
||||
}
|
||||
|
||||
public function testParseDeviceTypeTablet(): void
|
||||
{
|
||||
$this->assertSame('tablet', AnalyticsUniqId::parseDeviceType('Mozilla/5.0 (iPad; CPU OS 15_0 like Mac OS X)'));
|
||||
}
|
||||
|
||||
public function testParseOsWindows(): void
|
||||
{
|
||||
$this->assertSame('Windows', AnalyticsUniqId::parseOs('Mozilla/5.0 (Windows NT 10.0; Win64; x64)'));
|
||||
}
|
||||
|
||||
public function testParseOsMac(): void
|
||||
{
|
||||
$this->assertSame('macOS', AnalyticsUniqId::parseOs('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'));
|
||||
}
|
||||
|
||||
public function testParseOsIos(): void
|
||||
{
|
||||
$this->assertSame('iOS', AnalyticsUniqId::parseOs('Mozilla/5.0 (iPhone; CPU iPhone OS 15_0)'));
|
||||
}
|
||||
|
||||
public function testParseOsAndroid(): void
|
||||
{
|
||||
$this->assertSame('Android', AnalyticsUniqId::parseOs('Mozilla/5.0 (Linux; Android 12; Pixel 6)'));
|
||||
}
|
||||
|
||||
public function testParseOsLinux(): void
|
||||
{
|
||||
$this->assertSame('Linux', AnalyticsUniqId::parseOs('Mozilla/5.0 (X11; Linux x86_64)'));
|
||||
}
|
||||
|
||||
public function testParseOsUnknown(): void
|
||||
{
|
||||
$this->assertNull(AnalyticsUniqId::parseOs('some-random-bot'));
|
||||
}
|
||||
|
||||
public function testParseBrowserChrome(): void
|
||||
{
|
||||
$this->assertSame('Chrome', AnalyticsUniqId::parseBrowser('Mozilla/5.0 Chrome/120.0.0.0 Safari/537.36'));
|
||||
}
|
||||
|
||||
public function testParseBrowserFirefox(): void
|
||||
{
|
||||
$this->assertSame('Firefox', AnalyticsUniqId::parseBrowser('Mozilla/5.0 Firefox/121.0'));
|
||||
}
|
||||
|
||||
public function testParseBrowserEdge(): void
|
||||
{
|
||||
$this->assertSame('Edge', AnalyticsUniqId::parseBrowser('Mozilla/5.0 Chrome/120.0 Edg/120.0'));
|
||||
}
|
||||
|
||||
public function testParseBrowserSafari(): void
|
||||
{
|
||||
$this->assertSame('Safari', AnalyticsUniqId::parseBrowser('Mozilla/5.0 (Macintosh) AppleWebKit/605.1.15 Safari/605.1.15'));
|
||||
}
|
||||
|
||||
public function testParseBrowserOpera(): void
|
||||
{
|
||||
$this->assertSame('Opera', AnalyticsUniqId::parseBrowser('Mozilla/5.0 OPR/106.0.0.0'));
|
||||
}
|
||||
|
||||
public function testParseBrowserUnknown(): void
|
||||
{
|
||||
$this->assertNull(AnalyticsUniqId::parseBrowser('some-random-bot'));
|
||||
}
|
||||
|
||||
// --- AnalyticsEvent ---
|
||||
|
||||
public function testEventConstructor(): void
|
||||
|
||||
Reference in New Issue
Block a user