false]; $mod = $this->newSyslogPage(); $mod->preprocess(); $mod->render(); $this->assertContains('main.no-permission', Message::$errors, 'Should add no-permission error'); // Heading template still added, but no 'page-syslog' template $names = array_column(Render::$templates, 'name'); $this->assertNotEmpty($names); $this->assertSame('heading', Render::$templates[0]['name']); $this->assertNotContains('page-syslog', $names); } public function testRenderWithFiltersAndTypes(): void { User::$permissions = ['view' => true]; // Apply filters via GET (we search for 'login' which exists in seed) $_GET['filter'] = 'session-open,foo-custom'; // includes one unknown type $_GET['search'] = 'login'; $_GET['not'] = '0'; $_REQUEST = $_GET; $mod = $this->newSyslogPage(); $mod->preprocess(); $mod->render(); // Verify render payload from real Paginate $names = array_column(Render::$templates, 'name'); $this->assertContains('page-syslog', $names); $tpl = null; foreach (Render::$templates as $t) { if ($t['name'] === 'page-syslog') { $tpl = $t; break; } } $this->assertNotNull($tpl); $data = $tpl['data']; $this->assertSame('session-open,foo-custom', $data['filter']); $this->assertSame('login', $data['search']); $this->assertSame(false, $data['not']); $this->assertIsString($data['types']); $typesArray = json_decode($data['types'], true); $this->assertIsArray($typesArray); $ids = array_column($typesArray, 'logtypeid'); // Should include both DB types and unknown filter value $this->assertContains('session-open', $ids); $this->assertContains('partition-temp', $ids); $this->assertContains('foo-custom', $ids); // Each list row enriched with 'date' and 'icon' $this->assertArrayHasKey('list', $data); $this->assertNotEmpty($data['list']); $this->assertArrayHasKey('date', $data['list'][0]); $this->assertArrayHasKey('icon', $data['list'][0]); } public function testRenderWithAllowedLocationsRestrictionFiltersRows(): void { User::$permissions = ['view' => true]; // Restrict allowed locations (no 0) -> only logs from machines in these locations remain User::$allowedLocations = [5, 6]; $_REQUEST = $_GET = []; $mod = $this->newSyslogPage(); $mod->preprocess(); $mod->render(); $tpl = null; foreach (Render::$templates as $t) { if ($t['name'] === 'page-syslog') { $tpl = $t; break; } } $this->assertNotNull($tpl); $data = $tpl['data']; $this->assertArrayHasKey('list', $data); // With allowedLocations [5,6] and seed machines m1@1, m2@5, only m2 should remain $this->assertNotEmpty($data['list']); $uuids = array_column($data['list'], 'machineuuid'); $this->assertContains('m2', $uuids); $this->assertNotContains('m1', $uuids); } }