@@ -115,14 +115,49 @@ public function testConstruct()
115115 $ instance = new CachedEntry ($ userAgent , $ clientHints , $ values );
116116 $ this ->assertIsObject ($ instance );
117117 $ this ->assertInstanceOf (CachedEntry::class, $ instance );
118- $ this ->assertSame ('' , $ instance ->getBot ());
118+ $ this ->assertSame (null , $ instance ->getBot ());
119119 $ this ->assertSame ($ values ['brand ' ], $ instance ->getBrandName ());
120120 $ this ->assertSame ($ expectedClient , $ instance ->getClient ());
121121 $ this ->assertSame ($ values ['device ' ], $ instance ->getDevice ());
122122 $ this ->assertSame ($ values ['model ' ], $ instance ->getModel ());
123123 $ this ->assertSame ($ expectedOs , $ instance ->getOs ());
124124 }
125125
126+ public function testConstructDefault ()
127+ {
128+ $ userAgent = "unknown " ;
129+
130+ $ clientHints = [
131+ 'HTTP_SEC_CH_UA_PLATFORM ' => '"Windows" ' ,
132+ 'HTTP_SEC_CH_UA ' => '" Not A;Brand";v="99", "Chromium";v="95", "Microsoft Edge";v="95" ' ,
133+ 'HTTP_SEC_CH_UA_MOBILE ' => "?0 " ,
134+ 'HTTP_SEC_CH_UA_FULL_VERSION ' => '"98.0.0.1" ' ,
135+ 'HTTP_SEC_CH_UA_PLATFORM_VERSION ' => '"14.0.0" ' ,
136+ 'HTTP_SEC_CH_UA_ARCH ' => "x86 " ,
137+ 'HTTP_SEC_CH_UA_BITNESS ' => "64 " ,
138+ 'HTTP_SEC_CH_UA_MODEL ' => ""
139+ ];
140+
141+ $ expectedOs = [
142+ 'name ' => 'Windows ' ,
143+ 'short_name ' => 'WIN ' ,
144+ 'version ' => '11 ' ,
145+ 'platform ' => 'x64 ' ,
146+ 'family ' => 'Windows ' ,
147+ ];
148+
149+
150+ $ instance = new CachedEntry ($ userAgent , $ clientHints , []);
151+ $ this ->assertIsObject ($ instance );
152+ $ this ->assertInstanceOf (CachedEntry::class, $ instance );
153+ $ this ->assertSame (null , $ instance ->getBot ());
154+ $ this ->assertSame ('' , $ instance ->getBrandName ());
155+ $ this ->assertSame (null , $ instance ->getClient ());
156+ $ this ->assertSame (null , $ instance ->getDevice ());
157+ $ this ->assertSame ('' , $ instance ->getModel ());
158+ $ this ->assertSame ($ expectedOs , $ instance ->getOs ());
159+ }
160+
126161 public function testGetNumCacheFiles_noneCached ()
127162 {
128163 $ this ->assertEquals (0 , CachedEntry::getNumEntriesInCacheDir ());
0 commit comments