Skip to content
Snippets Groups Projects
Commit 0a78cb46 authored by Michael Hamann's avatar Michael Hamann
Browse files

Fix the test if a subscription already exists FS#2580

This fixes the test for existing subscriptions by not only testing if
the subscription for the deepest namespace level is for the current page
but by simply testing all levels. Test case is included, it fails
without this change.
parent 05be3a57
No related branches found
No related tags found
No related merge requests found
<?php
/**
* Tests the subscription set function
*/
class subscription_set_test extends DokuWikiTest {
/**
* Tests, if overwriting subscriptions works even when subscriptions for the same
* user exist for two nested namespaces, this is a test for the bug described in FS#2580
*/
function test_overwrite() {
subscription_set('admin', ':', 'digest', '123456789');
subscription_set('admin', ':wiki:', 'digest', '123456789');
subscription_set('admin', ':', 'digest', '1234', true);
subscription_set('admin', ':wiki:', 'digest', '1234', true);
$subscriptions = subscription_find(':wiki:', array('user' => 'admin'));
$this->assertCount(1, $subscriptions[':'], 'More than one subscription saved for the root namespace even though the old one should have been overwritten.');
$this->assertCount(1, $subscriptions[':wiki:'], 'More than one subscription saved for the wiki namespace even though the old one should have been overwritten.');
$this->assertCount(2, $subscriptions, 'Didn\'t find the expected two subscriptions');
}
}
......@@ -132,7 +132,7 @@ function subscription_set($user, $page, $style, $data = null,
// Delete subscription if one exists and $overwrite is true. If $overwrite
// is false, fail.
$subs = subscription_find($page, array('user' => $user));
if (count($subs) > 0 && array_pop(array_keys($subs)) === $page) {
if (count($subs) > 0 && isset($subs[$page])) {
if (!$overwrite) {
msg(sprintf($lang['subscr_already_subscribed'], $user,
prettyprint_id($page)), -1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment