Skip to content

Commit 8bd67d6

Browse files
committed
Add more migration test assertions.
1 parent bfbb949 commit 8bd67d6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/notification/notification_method_webpush_test.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,13 @@ public function test_export_data_with_migration(): void
507507
$migration_class = '\phpbb\webpushnotifications\migrations\handle_subscriptions';
508508
$migrator->populate_migrations([$migration_class]);
509509

510+
// Revert migration data
510511
while ($migrator->migration_state($migration_class) !== false)
511512
{
512513
$migrator->revert($migration_class);
513514
}
514515

516+
// Test reverting data results
515517
$sql = 'SELECT config_name, config_value FROM ' . CONFIG_TABLE . "
516518
WHERE config_name IN('webpush_enable', 'webpush_vapid_public', 'webpush_vapid_private')";
517519
$result = $this->db->sql_query($sql);
@@ -527,5 +529,27 @@ public function test_export_data_with_migration(): void
527529
$this->assertEquals($this->config['wpn_webpush_enable'], $exported_config_data['webpush_enable']);
528530
$this->assertEquals($this->config['wpn_webpush_vapid_public'], $exported_config_data['webpush_vapid_public']);
529531
$this->assertEquals($this->config['wpn_webpush_vapid_private'], $exported_config_data['webpush_vapid_private']);
532+
533+
$sql = "SELECT * FROM phpbb_user_notifications
534+
WHERE method = '" . $this->db->sql_escape('notification.method.webpush') . "'";
535+
$result = $this->db->sql_query($sql);
536+
$this->assertGreaterThan(0, count($this->db->sql_fetchrowset($result)));
537+
$this->db->sql_freeresult($result);
538+
539+
$sql = "SELECT * FROM phpbb_user_notifications
540+
WHERE method = '" . $this->db->sql_escape('notification.method.phpbb.wpn.webpush') . "'";
541+
$result = $this->db->sql_query($sql);
542+
$this->assertEquals(0, count($this->db->sql_fetchrowset($result)));
543+
$this->db->sql_freeresult($result);
544+
545+
$this->assertEquals(
546+
$this->db->sql_fetchrowset($this->db->sql_query('SELECT * FROM phpbb_wpn_notification_push')),
547+
$this->db->sql_fetchrowset($this->db->sql_query('SELECT * FROM phpbb_notification_push'))
548+
);
549+
550+
$this->assertEquals(
551+
$this->db->sql_fetchrowset($this->db->sql_query('SELECT * FROM phpbb_wpn_push_subscriptions')),
552+
$this->db->sql_fetchrowset($this->db->sql_query('SELECT * FROM phpbb_push_subscriptions'))
553+
);
530554
}
531555
}

0 commit comments

Comments
 (0)