@@ -50,33 +50,35 @@ protected function setUp(): void {
5050 }
5151
5252 private function addDummyValues (): void {
53- $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_5MIN + 1 , 10 );
53+ $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_5MIN + 1 , ƒ10);
54+ $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_5MIN + 1 , 11 );
5455 $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_1HOUR + 1 , 20 );
56+ $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_1HOUR + 1 , 21 );
57+ $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_1HOUR + 1 , 22 );
5558 $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_1DAY + 1 , 30 );
56- $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_7DAYS + 1 , 40 );
5759 $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_1MONTH + 1 , 50 );
5860 $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_3MONTHS + 1 , 60 );
5961 $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_6MONTHS + 1 , 70 );
6062 $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_1YEAR + 1 , 80 );
63+ $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_1YEAR + 1 , 88 );
64+ $ this ->addDummyValuesWithLastLogin (self ::CURRENT_TIME - self ::OFFSET_1YEAR + 1 , 88 );
6165 }
6266
63- private function addDummyValuesWithLastLogin ($ lastActivity , $ numOfEntries ): void {
64- for ($ i = 0 ; $ i < $ numOfEntries ; $ i ++) {
65- $ query = $ this ->connection ->getQueryBuilder ();
66- $ query ->insert (self ::TABLE )
67- ->values (
68- [
69- 'userid ' => $ query ->createNamedParameter ('user- ' . ($ numOfEntries + $ i % 2 )),
70- 'appid ' => $ query ->createNamedParameter ('login ' ),
71- 'configkey ' => $ query ->createNamedParameter ('lastLogin ' ),
72- 'configvalue ' => $ query ->createNamedParameter ($ lastActivity ),
73- 'lazy ' => $ query ->createNamedParameter (0 ),
74- 'type ' => $ query ->createNamedParameter (0 ),
75- 'flags ' => $ query ->createNamedParameter (0 ),
76- ]
77- );
78- $ query ->executeStatement ();
79- }
67+ private function addDummyValuesWithLastLogin ($ lastActivity , $ id ): void {
68+ $ query = $ this ->connection ->getQueryBuilder ();
69+ $ query ->insert (self ::TABLE )
70+ ->values (
71+ [
72+ 'userid ' => $ query ->createNamedParameter ("user- $ id " ),
73+ 'appid ' => $ query ->createNamedParameter ('login ' ),
74+ 'configkey ' => $ query ->createNamedParameter ('lastLogin ' ),
75+ 'configvalue ' => $ query ->createNamedParameter ($ lastActivity ),
76+ 'lazy ' => $ query ->createNamedParameter (0 ),
77+ 'type ' => $ query ->createNamedParameter (0 ),
78+ 'flags ' => $ query ->createNamedParameter (0 ),
79+ ]
80+ );
81+ $ query ->executeStatement ();
8082 }
8183
8284 public function testGetSessionStatistics () {
@@ -88,12 +90,12 @@ public function testGetSessionStatistics() {
8890
8991 $ this ->assertSame (8 , count ($ result ));
9092 $ this ->assertSame (2 , $ result ['last5minutes ' ]);
91- $ this ->assertSame (4 , $ result ['last1hour ' ]);
92- $ this ->assertSame (6 , $ result ['last24hours ' ]);
93- $ this ->assertSame (8 , $ result ['last7days ' ]);
94- $ this ->assertSame (10 , $ result ['last1month ' ]);
95- $ this ->assertSame (12 , $ result ['last3months ' ]);
96- $ this ->assertSame (14 , $ result ['last6months ' ]);
97- $ this ->assertSame (16 , $ result ['lastyear ' ]);
93+ $ this ->assertSame (3 , $ result ['last1hour ' ]);
94+ $ this ->assertSame (1 , $ result ['last24hours ' ]);
95+ $ this ->assertSame (0 , $ result ['last7days ' ]);
96+ $ this ->assertSame (1 , $ result ['last1month ' ]);
97+ $ this ->assertSame (1 , $ result ['last3months ' ]);
98+ $ this ->assertSame (1 , $ result ['last6months ' ]);
99+ $ this ->assertSame (2 , $ result ['lastyear ' ]);
98100 }
99101}
0 commit comments