Skip to content

Commit

Permalink
Add xCP modules tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxu committed Dec 30, 2023
1 parent a59cfed commit 7e48889
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/functional/functional_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,39 @@ public function test_extension_enabled()
$this->assertStringContainsString('phpBB Browser Push Notifications', $crawler->filter('.ext_enabled')->eq(0)->text());
$this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text());
}

public function test_acp_module()
{
$this->login();
$this->admin_login();

$crawler = self::request('GET', 'adm/index.php?i=-phpbb-webpushnotifications-acp-wpn_acp_module&mode=webpush&sid=' . $this->sid);

$this->assertContainsLang('ACP_WEBPUSH_SETTINGS', $crawler->filter('h1')->text());
$this->assertContainsLang('ACP_WEBPUSH_SETTINGS_EXPLAIN', $crawler->filter('div.main > p')->text());
$this->assertContainsLang('WEBPUSH_GENERATE_VAPID_KEYS', $crawler->filter('input[type="button"]')->attr('value'));

$form = $crawler->selectButton('submit')->form([
'config[webpush_enable]' => 1,
'config[webpush_vapid_public]' => 'BDnYSJHVZBxq834LqDGr893IfazEez7q-jYH2QBNlT0ji2C9UwGosiqz8Dp_ZN23lqAngBZyRjXVWF4ZLA8X2zI',
'config[webpush_vapid_private]' => 'IE5OYlmfWsMbBU1lzvr0bxrxVAXIteSkAnwGlZIhmRk',
]);
$crawler = self::submit($form);
$this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text());

$crawler = self::request('GET', 'adm/index.php?i=-phpbb-webpushnotifications-acp-wpn_acp_module&mode=webpush&sid=' . $this->sid);
$this->assertEqual(1, $crawler->filter('input[name="config[webpush_enable]"]')->attr('value'));
}

public function test_ucp_module()
{
$this->login();

$crawler = self::request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');

$this->assertContainsLang('NOTIFY_WEBPUSH_ENABLE', $crawler->filter('label[for="subscribe_webpush"]')->text());
$this->assertContainsLang('ACP_WEBPUSH_SETTINGS_EXPLAIN', $crawler->filter('dt > span')->text());
$this->assertContainsLang('NOTIFICATION_METHOD_WEBPUSH', $crawler->filter('th')->eq(2)->text());
}

}

0 comments on commit 7e48889

Please sign in to comment.