From 71275eac2c46290cd32c9492779c4c7d245777bc Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Sat, 15 Nov 2014 14:32:31 +0100 Subject: [PATCH] display & update the number of unread items on every page with an "unread items" menu --- assets/js/all.min.js | 34 +-- assets/js/item.js | 78 ++++-- controllers/bookmark.php | 1 + controllers/config.php | 9 + controllers/console.php | 1 + controllers/feed.php | 7 + controllers/history.php | 2 + controllers/item.php | 4 +- templates/layout.php | 2 +- .../datasets/fixture_OneUnreadArticle.xml | 247 ++++++++++++++++++ tests/integration/keyboardShortcutsTest.php | 14 +- tests/integration/pageBookmarksTest.php | 64 +++++ tests/integration/pageFirstFeedTest.php | 75 ++++++ tests/integration/pageHistoryTest.php | 41 +++ tests/integration/pageUnreadTest.php | 3 + 15 files changed, 539 insertions(+), 43 deletions(-) create mode 100644 tests/integration/datasets/fixture_OneUnreadArticle.xml diff --git a/assets/js/all.min.js b/assets/js/all.min.js index af8d444..f712118 100644 --- a/assets/js/all.min.js +++ b/assets/js/all.min.js @@ -1,20 +1,20 @@ var Miniflux={};Miniflux.App=function(){return{Run:function(){Miniflux.Event.ListenKeyboardEvents();Miniflux.Event.ListenMouseEvents()}}}(); -Miniflux.Feed=function(){var d=[];return{Update:function(c,a){var b=c.querySelector("span.items-count");if(b){var d=c.getAttribute("data-feed-id"),e=c.querySelector("h2:first-of-type");e.className="loading-icon";var f=new XMLHttpRequest;f.onload=function(){e.className="";var f=c.querySelector(".feed-last-checked");f&&(f.innerHTML=f.getAttribute("data-after-update"));if(f=c.querySelector(".feed-parsing-error"))f.innerHTML="";var d=JSON.parse(this.responseText);d.result?b.innerHTML=d.items_count.items_unread+ -"/"+d.items_count.items_total:f&&(f.innerHTML=f.getAttribute("data-after-error"));a&&a(d)};f.open("POST","?action=refresh-feed&feed_id="+d,!0);f.send()}},UpdateAll:function(){var c=Array.prototype.slice.call(document.querySelectorAll("article:not([data-feed-disabled])")),a=setInterval(function(){for(;0d.length;){var b=c.shift();d.push(parseInt(b.getAttribute("data-feed-id")));Miniflux.Feed.Update(b,function(b){b=d.indexOf(b.feed_id);0<=b&&d.splice(b,1);0===c.length&&0===d.length&&(clearInterval(a), +Miniflux.Feed=function(){var b=[];return{Update:function(e,a){var d=e.querySelector("span.items-count");if(d){var b=e.getAttribute("data-feed-id"),l=e.querySelector("h2:first-of-type");l.className="loading-icon";var g=new XMLHttpRequest;g.onload=function(){l.className="";var b=e.querySelector(".feed-last-checked");b&&(b.innerHTML=b.getAttribute("data-after-update"));if(b=e.querySelector(".feed-parsing-error"))b.innerHTML="";var c=JSON.parse(this.responseText);c.result?d.innerHTML=c.items_count.items_unread+ +"/"+c.items_count.items_total:b&&(b.innerHTML=b.getAttribute("data-after-error"));a&&a(c)};g.open("POST","?action=refresh-feed&feed_id="+b,!0);g.send()}},UpdateAll:function(){var e=Array.prototype.slice.call(document.querySelectorAll("article:not([data-feed-disabled])")),a=setInterval(function(){for(;0b.length;){var d=e.shift();b.push(parseInt(d.getAttribute("data-feed-id")));Miniflux.Feed.Update(d,function(d){d=b.indexOf(d.feed_id);0<=d&&b.splice(d,1);0===e.length&&0===b.length&&(clearInterval(a), window.location.href="?action=unread")})}},100)}}}(); -Miniflux.Item=function(){function d(e){return item_id=e.getAttribute("data-item-id")}function c(e){if(e&&e.hasAttribute("data-reverse-label")){var a=e.innerHTML;e.innerHTML=e.getAttribute("data-reverse-label");e.setAttribute("data-reverse-label",a)}}function a(e){"mouse"!==Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();e.parentNode.removeChild(e);if(e=document.getElementById("page-counter")){var a=document.querySelector("section.page"),b=parseInt(e.textContent,10)-1,c=document.getElementsByTagName("article"); -if(0===b||0===c.length)window.location=location.href;e.textContent=b;switch(a.getAttribute("data-item-page")){case "unread":document.title="Miniflux ("+b+")";document.getElementById("nav-counter").textContent=b;break;case "feed-items":document.title="("+b+") "+e.parentNode.firstChild.nodeValue;break;default:document.title=e.parentNode.firstChild.nodeValue+" ("+b+")"}}}function b(e){var b=d(e),g=new XMLHttpRequest;g.onload=function(){if(Miniflux.Nav.IsListing())if(e.getAttribute("data-hide"))a(e); -else{e.setAttribute("data-item-status","read");var b=e.querySelector("a.mark");c(b);(b=e.querySelector("a.mark"))&&b.setAttribute("data-action","mark-unread")}};g.open("POST","?action=mark-item-read&id="+b,!0);g.send()}function h(e){var b=d(e),g=new XMLHttpRequest;g.onload=function(){if(Miniflux.Nav.IsListing())if(e.getAttribute("data-hide"))a(e);else{e.setAttribute("data-item-status","unread");var b=e.querySelector("a.mark");c(b);(b=e.querySelector("a.mark"))&&b.setAttribute("data-action","mark-read")}}; -g.open("POST","?action=mark-item-unread&id="+b,!0);g.send()}return{MarkAsRead:b,MarkAsUnread:h,MarkAsRemoved:function(b){var f=d(b),c=new XMLHttpRequest;c.onload=function(){Miniflux.Nav.IsListing()&&a(b)};c.open("POST","?action=mark-item-removed&id="+f,!0);c.send()},SwitchBookmark:function(b){var f=d(b),g="1"===b.getAttribute("data-item-bookmark")?"0":"1",k=new XMLHttpRequest;k.onload=function(){var f=document.querySelector("section.page");if(Miniflux.Nav.IsListing()&&"bookmarks"===f.getAttribute("data-item-page"))a(b); -else if(b.setAttribute("data-item-bookmark",g),Miniflux.Nav.IsListing())f=b.querySelector("a.bookmark"),c(f);else if((f=b.querySelector("a.bookmark-icon"))&&f.hasAttribute("data-reverse-title")){var d=f.getAttribute("title");f.setAttribute("title",f.getAttribute("data-reverse-title"));f.setAttribute("data-reverse-title",d)}};k.open("POST","?action=bookmark&id="+f+"&value="+g,!0);k.send()},SwitchStatus:function(a){var f=a.getAttribute("data-item-status");"read"===f?h(a):"unread"===f&&b(a)},Show:function(b){(b= -b.querySelector("a.show"))&&b.click()},OpenOriginal:function(a){var f=a.querySelector("a.original");f&&("unread"===a.getAttribute("data-item-status")&&b(a),f.removeAttribute("data-action"),"mouse"!==Miniflux.Event.lastEventType&&f.click())},DownloadContent:function(b){var a=document.getElementById("download-item");if(a){a.innerHTML=" "+a.getAttribute("data-before-message");a.className="loading-icon";var c=new XMLHttpRequest;c.onload=function(){var b=JSON.parse(c.responseText);a.className="";if(b.result){var e= -document.getElementById("item-content");e&&(e.innerHTML=b.content);a.innerHTML=a.getAttribute("data-after-message")}else a.innerHTML=a.getAttribute("data-failure-message")};b=d(b);c.open("POST","?action=download-item&id="+b,!0);c.send()}},MarkListingAsRead:function(b){for(var a=document.getElementsByTagName("article"),c=[],k=0,h=a.length;kb-(a.offsetTop+a.offsetHeight)||b-a.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,a.offsetTop-10)}function c(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var a=document.getElementById("next-page");a&&a.click()},OpenPreviousPage:function(){var a=document.getElementById("previous-page");a&&a.click()},SelectNextItem:function(){var a=document.getElementById("next-item"); -if(a)a.click();else if(c())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var b=0,h=a.length;bb-(a.offsetTop+a.offsetHeight)||b-a.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,a.offsetTop-10)}function e(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var a=document.getElementById("next-page");a&&a.click()},OpenPreviousPage:function(){var a=document.getElementById("previous-page");a&&a.click()},SelectNextItem:function(){var a=document.getElementById("next-item"); +if(a)a.click();else if(e())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var d=0,h=a.length;d $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'nothing_to_read' => Request\int_param('nothing_to_read'), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'bookmarks', 'title' => t('Bookmarks').' ('.$nb_items.')' ))); diff --git a/controllers/config.php b/controllers/config.php index d4a4b50..94e7892 100644 --- a/controllers/config.php +++ b/controllers/config.php @@ -17,6 +17,7 @@ Router\get_action('new-db', function() { 'values' => array( 'csrf' => Model\Config\generate_csrf(), ), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('New database') ))); @@ -49,6 +50,7 @@ Router\post_action('new-db', function() { Response\html(Template\layout('new_db', array( 'errors' => $errors, 'values' => $values + array('csrf' => Model\Config\generate_csrf()), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('New database') ))); @@ -61,6 +63,7 @@ Router\post_action('new-db', function() { Router\get_action('confirm-auto-update', function() { Response\html(Template\layout('confirm_auto_update', array( + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Confirmation') ))); @@ -126,6 +129,7 @@ Router\get_action('config', function() { 'sorting_options' => Model\Config\get_sorting_directions(), 'display_mode' => Model\Config\get_display_mode(), 'redirect_nothing_to_read_options' => Model\Config\get_nothing_to_read_redirections(), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Preferences') ))); @@ -162,6 +166,7 @@ Router\post_action('config', function() { 'sorting_options' => Model\Config\get_sorting_directions(), 'redirect_nothing_to_read_options' => Model\Config\get_nothing_to_read_redirections(), 'display_mode' => Model\Config\get_display_mode(), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Preferences') ))); @@ -172,6 +177,7 @@ Router\get_action('help', function() { Response\html(Template\layout('help', array( 'config' => Model\Config\get_all(), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Help') ))); @@ -183,6 +189,7 @@ Router\get_action('about', function() { Response\html(Template\layout('about', array( 'csrf' => Model\Config\generate_csrf(), 'config' => Model\Config\get_all(), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('About') ))); @@ -195,6 +202,7 @@ Router\get_action('database', function() { 'csrf' => Model\Config\generate_csrf(), 'config' => Model\Config\get_all(), 'db_size' => filesize(\Model\Database\get_path()), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Database') ))); @@ -205,6 +213,7 @@ Router\get_action('api', function() { Response\html(Template\layout('api', array( 'config' => Model\Config\get_all(), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('API') ))); diff --git a/controllers/console.php b/controllers/console.php index 5e83969..6881547 100644 --- a/controllers/console.php +++ b/controllers/console.php @@ -19,6 +19,7 @@ Router\get_action('console', function() { Response\html(Template\layout('console', array( 'content' => @file_get_contents(DEBUG_FILENAME), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Console') ))); diff --git a/controllers/feed.php b/controllers/feed.php index 7f5d1d3..52282a9 100644 --- a/controllers/feed.php +++ b/controllers/feed.php @@ -22,6 +22,7 @@ Router\get_action('edit-feed', function() { Response\html(Template\layout('edit_feed', array( 'values' => Model\Feed\get($id), 'errors' => array(), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'feeds', 'title' => t('Edit subscription') ))); @@ -48,6 +49,7 @@ Router\post_action('edit-feed', function() { Response\html(Template\layout('edit_feed', array( 'values' => $values, 'errors' => $errors, + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'feeds', 'title' => t('Edit subscription') ))); @@ -60,6 +62,7 @@ Router\get_action('confirm-remove-feed', function() { Response\html(Template\layout('confirm_remove_feed', array( 'feed' => Model\Feed\get($id), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'feeds', 'title' => t('Confirmation') ))); @@ -131,6 +134,7 @@ Router\get_action('feeds', function() { 'favicons' => Model\Feed\get_all_favicons(), 'feeds' => Model\Feed\get_all_item_counts(), 'nothing_to_read' => Request\int_param('nothing_to_read'), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'feeds', 'title' => t('Subscriptions') ))); @@ -144,6 +148,7 @@ Router\get_action('add', function() { 'csrf' => Model\Config\generate_csrf(), ), 'errors' => array(), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'feeds', 'title' => t('New subscription') ))); @@ -184,6 +189,7 @@ Router\action('subscribe', function() { 'url' => $url, 'csrf' => Model\Config\generate_csrf(), ), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'feeds', 'title' => t('Subscriptions') ))); @@ -201,6 +207,7 @@ Router\get_action('import', function() { Response\html(Template\layout('import', array( 'errors' => array(), + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'feeds', 'title' => t('OPML Import') ))); diff --git a/controllers/history.php b/controllers/history.php index b4fbd0f..7031118 100644 --- a/controllers/history.php +++ b/controllers/history.php @@ -26,6 +26,7 @@ Router\get_action('history', function() { 'direction' => '', 'display_mode' => Model\Config\get('items_display_mode'), 'nb_items' => $nb_items, + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'nothing_to_read' => Request\int_param('nothing_to_read'), @@ -38,6 +39,7 @@ Router\get_action('history', function() { Router\get_action('confirm-flush-history', function() { Response\html(Template\layout('confirm_flush_items', array( + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'history', 'title' => t('Confirmation') ))); diff --git a/controllers/item.php b/controllers/item.php index 48f4842..625ace6 100644 --- a/controllers/item.php +++ b/controllers/item.php @@ -53,7 +53,6 @@ Router\get_action('show', function() { switch ($menu) { case 'unread': $nav = Model\Item\get_nav($item); - $nb_unread_items = Model\Item\count_by_status('unread'); break; case 'history': $nav = Model\Item\get_nav($item, array('read')); @@ -67,7 +66,7 @@ Router\get_action('show', function() { } Response\html(Template\layout('show_item', array( - 'nb_unread_items' => isset($nb_unread_items) ? $nb_unread_items : null, + 'nb_unread_items' => $nb_unread_items = Model\Item\count_by_status('unread'), 'item' => $item, 'feed' => $feed, 'item_nav' => isset($nav) ? $nav : null, @@ -96,6 +95,7 @@ Router\get_action('feed-items', function() { 'feed' => $feed, 'items' => $items, 'nb_items' => $nb_items, + 'nb_unread_items' => Model\Item\count_by_status('unread'), 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'menu' => 'feed-items', diff --git a/templates/layout.php b/templates/layout.php index a3a4f47..ca1aabf 100644 --- a/templates/layout.php +++ b/templates/layout.php @@ -23,7 +23,7 @@
  • > - 0 ? $nb_unread_items : '' ?> +
  • diff --git a/tests/integration/datasets/fixture_OneUnreadArticle.xml b/tests/integration/datasets/fixture_OneUnreadArticle.xml new file mode 100644 index 0000000..cb53284 --- /dev/null +++ b/tests/integration/datasets/fixture_OneUnreadArticle.xml @@ -0,0 +1,247 @@ + + + + id + site_url + feed_url + title + last_modified + etag + last_checked + enabled + download_content + parsing_error + rtl + + 1 + http://miniflux.net/ + http://miniflux.net/feed.xml + Recent Miniflux Releases + + + + 1 + 0 + 0 + 0 + + + 2 + https://github.com/fguillot/miniflux/commits/master + https://github.com/fguillot/miniflux/commits/master.atom + Recent Commits to miniflux:master + + + + 1 + 0 + 0 + 0 + +
    + + id + url + title + author + content + updated + status + feed_id + bookmark + enclosure + enclosure_type + language + + 22ca3b4f + http://miniflux.net/news.html#2013-03-21 + Miniflux 1.0.2 is released + + <ul><li><a href="http://miniflux.net/miniflux-1.0.2.zip" rel="noreferrer" target="_blank" >Download archive</a></li> + <li><a href="http://miniflux.net/changes.html#v1.0.2" rel="noreferrer" target="_blank" >ChangeLog</a></li> + </ul> + ##TIMESTAMP##92 + read + 1 + 0 + + + en-US + + + 30d227f3 + http://miniflux.net/news.html#2013-07-22 + Miniflux 1.0.10 is released! + + <ul><li><a href="http://miniflux.net/miniflux-1.0.10.zip" rel="noreferrer" target="_blank" >Download archive</a></li> + <li><a href="http://miniflux.net/changes.html#v1.0.10" rel="noreferrer" target="_blank" >ChangeLog</a></li> + </ul> + ##TIMESTAMP##97 + read + 1 + 1 + + + en-US + + + 4b2dbd17 + http://miniflux.net/news.html#2013-03-26 + Miniflux 1.0.3 is released + + <ul><li><a href="http://miniflux.net/miniflux-1.0.3.zip" rel="noreferrer" target="_blank" >Download archive</a></li> + <li><a href="http://miniflux.net/changes.html#v1.0.3" rel="noreferrer" target="_blank" >ChangeLog</a></li> + </ul> + ##TIMESTAMP##93 + read + 1 + 0 + + + en-US + + + 51b4239b + http://miniflux.net/news.html#2013-04-12 + Miniflux 1.0.6 is released + + <ul><li><a href="http://miniflux.net/miniflux-1.0.6.zip" rel="noreferrer" target="_blank" >Download archive</a></li> + <li><a href="http://miniflux.net/changes.html#v1.0.6" rel="noreferrer" target="_blank" >ChangeLog</a></li> + </ul> + ##TIMESTAMP##94 + read + 1 + 1 + + + en-US + + + 7c6afaa5 + http://miniflux.net/news.html#2014-01-02 + Miniflux 1.1.1 is released + + <ul><li><a href="http://miniflux.net/miniflux-1.1.1.zip" rel="noreferrer" target="_blank" >Download archive</a></li> + <li><a href="http://miniflux.net/changes.html#v1.1.1" rel="noreferrer" target="_blank" >ChangeLog</a></li> + </ul><p>Major improvements:</p> + <ul><li>New theme: Copper (By the contributor Nicolas Dewaele)</li> + <li>Display a message next to a feed when there is a parsing error</li> + <li>Change default value of autoflush to 15 days if not set to avoid large database</li> + <li>Add autoflush value &quot;immediately&quot;</li> + <li>Add an option to choose where to be redirected when there is nothing to read</li> + <li>Bug fixes</li> + </ul> + ##TIMESTAMP##99 + read + 1 + 0 + + + en-US + + + 7cb2809d + http://miniflux.net/news.html#2013-09-02 + Miniflux 1.0.11 is released + + <ul><li><a href="http://miniflux.net/miniflux-1.0.11.zip" rel="noreferrer" target="_blank" >Download archive</a></li> + <li><a href="http://miniflux.net/changes.html#v1.0.11" rel="noreferrer" target="_blank" >ChangeLog</a></li> + </ul> + ##TIMESTAMP##98 + unread + 1 + 1 + + + en-US + + + 9b20eb66 + http://miniflux.net/news.html#2013-04-30 + Miniflux 1.0.7 is released + + <ul><li><a href="http://miniflux.net/miniflux-1.0.7.zip" rel="noreferrer" target="_blank" >Download archive</a></li> + <li><a href="http://miniflux.net/changes.html#v1.0.7" rel="noreferrer" target="_blank" >ChangeLog</a></li> + </ul> + ##TIMESTAMP##95 + read + 1 + 0 + + + en-US + + + 9fa78b54 + http://miniflux.net/news.html#2013-06-02 + Miniflux 1.0.8 is released + + <ul><li><a href="http://miniflux.net/miniflux-1.0.8.zip" rel="noreferrer" target="_blank" >Download archive</a></li> + <li><a href="http://miniflux.net/changes.htm#v1.0.8" rel="noreferrer" target="_blank" >ChangeLog</a></li> + </ul> + ##TIMESTAMP##96 + read + 1 + 1 + + + en-US + + + 1f4670bf + https://github.com/fguillot/miniflux/commit/e1b22f2d3592d653d4c22ce5f137bb1e0ae5dd3f + Redirect to the feed page after adding a subscription + fguillot + <pre>Redirect to the feed page after adding a subscription</pre> + ##TIMESTAMP##89 + read + 2 + 0 + + + en-US + + + 2063e830 + https://github.com/fguillot/miniflux/commit/e732e80deed05ea46667957835b2499bb895ebe9 + Update the Json-RPC library and improve make-archive.sh + fguillot + <pre>Update the Json-RPC library and improve make-archive.sh</pre> + ##TIMESTAMP##88 + read + 2 + 0 + + + en-US + + + 208ee9dd + https://github.com/fguillot/miniflux/commit/871f1d1d6410403599c774ad9aa20e55c77162fc + Update PicoDb and improve schema migration error handling + fguillot + <pre>Update PicoDb and improve schema migration error handling</pre> + ##TIMESTAMP##87 + read + 2 + 1 + + + en-US + + + 3530d7cd + https://github.com/fguillot/miniflux/commit/d7e5cd0ad424859912fc209651494fad5c52cd34 + New theme: 'Hello' created by Meradoou + fguillot + <pre>New theme: &#039;Hello&#039; created by Meradoou</pre> + ##TIMESTAMP##86 + read + 2 + 1 + + + en-US + +
    +
    diff --git a/tests/integration/keyboardShortcutsTest.php b/tests/integration/keyboardShortcutsTest.php index ec44018..dd1c781 100644 --- a/tests/integration/keyboardShortcutsTest.php +++ b/tests/integration/keyboardShortcutsTest.php @@ -5,6 +5,7 @@ require_once 'minifluxTestCase.php'; class keyboardShortcutTest extends minifluxTestCase { const DEFAULT_COUNTER_PAGE = 8; + const DEFAULT_COUNTER_UNREAD = 6; public function setUpPage() { @@ -34,6 +35,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->assertTrue($secondIsCurrentArticle, 'The second Article is not the current Article'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -51,6 +53,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->assertTrue($secondIsCurrentArticle, 'The second Article is not the current Article'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1');; } @@ -68,6 +71,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->assertTrue($secondIsNotCurrentArticle, 'The second Article is still the current Article'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -85,6 +89,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->assertTrue($secondIsNotCurrentArticle, 'The second Article is still the current Article'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -103,6 +108,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->assertTrue($lastIsCurrentArticle, 'The last Article is not the current Article'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -121,6 +127,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->assertTrue($firstIsCurrentArticle, 'The first Article is not the current Article'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -131,6 +138,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->url($url); $this->byId('form-username')->value($this->getShortcutGoToUnread()); + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = $url; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); @@ -142,6 +150,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->sendKeysAndWaitForPageLoaded('gb'); $this->expectedCounterPage = '6'; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = $this->getURLPageBookmarks(); $this->expectedDataSet = $this->getDataSet('fixture_feed1'); @@ -153,6 +162,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->sendKeysAndWaitForPageLoaded('gh'); $this->expectedCounterPage = '6'; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = $this->getURLPageHistory(); $this->expectedDataSet = $this->getDataSet('fixture_feed1'); @@ -164,7 +174,7 @@ class keyboardShortcutTest extends minifluxTestCase $this->sendKeysAndWaitForPageLoaded($this->getShortcutGoToUnread()); $this->expectedCounterPage = '6'; - $this->expectedCounterUnread = '6'; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = $this->getURLPageUnread(); $this->expectedDataSet = $this->getDataSet('fixture_feed1'); @@ -175,6 +185,7 @@ class keyboardShortcutTest extends minifluxTestCase { $this->sendKeysAndWaitForPageLoaded('gs'); + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=feeds'; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); @@ -185,6 +196,7 @@ class keyboardShortcutTest extends minifluxTestCase { $this->sendKeysAndWaitForPageLoaded('gp'); + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = $this->getURLPagePreferences(); $this->expectedDataSet = $this->getDataSet('fixture_feed1'); diff --git a/tests/integration/pageBookmarksTest.php b/tests/integration/pageBookmarksTest.php index 96a6948..f086408 100644 --- a/tests/integration/pageBookmarksTest.php +++ b/tests/integration/pageBookmarksTest.php @@ -5,6 +5,7 @@ require_once 'minifluxTestCase.php'; class pageBookmarksTest extends minifluxTestCase { const DEFAULT_COUNTER_PAGE = 6; + const DEFAULT_COUNTER_UNREAD = 6; public function setUpPage() { @@ -26,6 +27,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertNotEmpty($articles, 'no articles from other feeds found'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -35,6 +37,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertEmpty($articles, 'found not bookmarked articles.'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -49,6 +52,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($visible, 'read icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1;; $this->expectedDataSet = $this->getDataSet('expected_MarkReadBookmarkedArticle'); } @@ -63,6 +67,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($visible, 'read icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1;; $this->expectedDataSet = $this->getDataSet('expected_MarkReadBookmarkedArticle'); } @@ -77,6 +82,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($invisible, 'read icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1;; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadBookmarkedArticle'); } @@ -91,6 +97,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($invisible, 'read icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1;; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadBookmarkedArticle'); } @@ -105,6 +112,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkReadArticle'); } @@ -120,6 +128,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkReadArticle'); } @@ -134,6 +143,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkUnreadArticle'); } @@ -148,6 +158,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkUnreadArticle'); } @@ -162,6 +173,7 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($invisible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_RemoveReadBookmarkedArticle'); } @@ -176,9 +188,59 @@ class pageBookmarksTest extends minifluxTestCase $this->assertTrue($invisible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1; $this->expectedDataSet = $this->getDataSet('expected_RemoveUnreadBookmarkedArticle'); } + public function testUnreadCounterFromNothingToValue() + { + // load different fixture and reload the page + $backupDataTester = static::$databaseTester; + + static::$databaseTester = NULL; + $this->getDatabaseTester('fixture_OnlyReadArticles', FALSE)->onSetUp(); + + static::$databaseTester = $backupDataTester; + $this->refresh(); + + // start the "real" test + // dont't trust the name! The Article is read+bookmarked here + $article = $this->getArticleUnreadBookmarked(); + + $link = $this->getLinkReadStatusToogle($article); + $link->click(); + + $this->waitForIconMarkReadInvisible($article); + + $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = 1; + $this->expectedDataSet = $this->getDataSet('fixture_OneUnreadArticle',FALSE); + } + + public function testUnreadCounterFromValueToNothing() + { + // load different fixture and reload the page + $backupDataTester = static::$databaseTester; + + static::$databaseTester = NULL; + $this->getDatabaseTester('fixture_OneUnreadArticle', FALSE)->onSetUp(); + + static::$databaseTester = $backupDataTester; + $this->refresh(); + + // start the "real" test + $article = $this->getArticleUnreadBookmarked(); + + $link = $this->getLinkReadStatusToogle($article); + $link->click(); + + $this->waitForIconMarkReadVisible($article); + + $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = ''; + $this->expectedDataSet = $this->getDataSet('fixture_OnlyReadArticles',FALSE); + } + public function testRedirectWithZeroArticles() { $articles = $this->getArticles(); @@ -193,6 +255,8 @@ class pageBookmarksTest extends minifluxTestCase $visible = $this->waitForAlert(); $this->assertTrue($visible, 'alert box did not appear'); + $this->expectedCounterPage = NULL; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_NoBookmarkedArticles', FALSE); $this->ignorePageTitle = TRUE; diff --git a/tests/integration/pageFirstFeedTest.php b/tests/integration/pageFirstFeedTest.php index b5f33ab..401874a 100644 --- a/tests/integration/pageFirstFeedTest.php +++ b/tests/integration/pageFirstFeedTest.php @@ -5,6 +5,7 @@ require_once 'minifluxTestCase.php'; class pageFirstFeedTest extends minifluxTestCase { const DEFAULT_COUNTER_PAGE = 8; + const DEFAULT_COUNTER_UNREAD = 6; public function setUpPage() { @@ -26,6 +27,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertEmpty($articles, 'found articles from other feeds on page for first feed.'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -40,6 +42,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($visible, 'read icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1; $this->expectedDataSet = $this->getDataSet('expected_MarkReadNotBookmarkedArticle'); } @@ -54,6 +57,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($visible, 'read icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1; $this->expectedDataSet = $this->getDataSet('expected_MarkReadNotBookmarkedArticle'); } @@ -68,6 +72,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($visible, 'read icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1; $this->expectedDataSet = $this->getDataSet('expected_MarkReadBookmarkedArticle'); } @@ -82,6 +87,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($visible, 'read icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1; $this->expectedDataSet = $this->getDataSet('expected_MarkReadBookmarkedArticle'); } @@ -96,6 +102,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'read icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadNotBookmarkedArticle'); } @@ -110,6 +117,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'read icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadNotBookmarkedArticle'); } @@ -124,6 +132,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'read icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadBookmarkedArticle'); } @@ -138,6 +147,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'read icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadBookmarkedArticle'); } @@ -152,6 +162,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($visible, 'bookmark icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_BookmarkReadArticle'); } @@ -166,6 +177,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($visible, 'bookmark icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_BookmarkReadArticle'); } @@ -180,6 +192,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($visible, 'bookmark icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_BookmarkUnreadArticle'); } @@ -194,6 +207,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($visible, 'bookmark icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_BookmarkUnreadArticle'); } @@ -208,6 +222,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkReadArticle'); } @@ -222,6 +237,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkReadArticle'); } @@ -236,6 +252,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkUnreadArticle'); } @@ -250,6 +267,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkUnreadArticle'); } @@ -264,6 +282,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_RemoveReadNotBookmarkedArticle'); } @@ -278,6 +297,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_RemoveReadBookmarkedArticle'); } @@ -292,6 +312,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1; $this->expectedDataSet = $this->getDataSet('expected_RemoveUnreadNotBookmarkedArticle'); } @@ -306,6 +327,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($invisible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1; $this->expectedDataSet = $this->getDataSet('expected_RemoveUnreadBookmarkedArticle'); } @@ -318,6 +340,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($read, 'there are still unread articles'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = 2; $this->expectedDataSet = $this->getDataSet('expected_MarkFeedRead'); } @@ -330,9 +353,59 @@ class pageFirstFeedTest extends minifluxTestCase $this->assertTrue($read, 'there are still unread articles'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = 2; $this->expectedDataSet = $this->getDataSet('expected_MarkFeedRead'); } + public function testUnreadCounterFromNothingToValue() + { + // load different fixture and reload the page + $backupDataTester = static::$databaseTester; + + static::$databaseTester = NULL; + $this->getDatabaseTester('fixture_OnlyReadArticles', FALSE)->onSetUp(); + + static::$databaseTester = $backupDataTester; + $this->refresh(); + + // start the "real" test + // dont't trust the name! The Article is read+bookmarked here + $article = $this->getArticleUnreadBookmarked(); + + $link = $this->getLinkReadStatusToogle($article); + $link->click(); + + $this->waitForIconMarkReadInvisible($article); + + $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = 1; + $this->expectedDataSet = $this->getDataSet('fixture_OneUnreadArticle',FALSE); + } + + public function testUnreadCounterFromValueToNothing() + { + // load different fixture and reload the page + $backupDataTester = static::$databaseTester; + + static::$databaseTester = NULL; + $this->getDatabaseTester('fixture_OneUnreadArticle', FALSE)->onSetUp(); + + static::$databaseTester = $backupDataTester; + $this->refresh(); + + // start the "real" test + $article = $this->getArticleUnreadBookmarked(); + + $link = $this->getLinkReadStatusToogle($article); + $link->click(); + + $this->waitForIconMarkReadVisible($article); + + $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = ''; + $this->expectedDataSet = $this->getDataSet('fixture_OnlyReadArticles',FALSE); + } + public function testRedirectWithZeroArticles() { $articles = $this->getArticles(); @@ -348,6 +421,8 @@ class pageFirstFeedTest extends minifluxTestCase $visible = $this->waitForAlert(); $this->assertTrue($visible, 'alert box did not appear'); + $this->expectedCounterPage = NULL; + $this->expectedCounterUnread = 2; $this->expectedDataSet = $this->getDataSet('expected_FirstFeedAllRemoved'); $this->ignorePageTitle = TRUE; diff --git a/tests/integration/pageHistoryTest.php b/tests/integration/pageHistoryTest.php index 5268afc..e1151ca 100644 --- a/tests/integration/pageHistoryTest.php +++ b/tests/integration/pageHistoryTest.php @@ -5,6 +5,7 @@ require_once 'minifluxTestCase.php'; class pageHistoryTest extends minifluxTestCase { const DEFAULT_COUNTER_PAGE = 6; + const DEFAULT_COUNTER_UNREAD = 6; public function setUpPage() { @@ -26,6 +27,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertNotEmpty($articles, 'no articles from other feeds found'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -35,6 +37,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertEmpty($articles, 'found unread articles.'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } @@ -49,6 +52,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($visible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadNotBookmarkedArticle'); } @@ -63,6 +67,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($visible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadNotBookmarkedArticle'); } @@ -77,6 +82,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($visible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadBookmarkedArticle'); } @@ -91,6 +97,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($visible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadBookmarkedArticle'); } @@ -105,6 +112,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($visible, 'bookmark icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_BookmarkReadArticle'); } @@ -119,6 +127,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($visible, 'bookmark icon is not visible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_BookmarkReadArticle'); } @@ -133,6 +142,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkReadArticle'); } @@ -147,6 +157,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($invisible, 'bookmark icon is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkReadArticle'); } @@ -161,6 +172,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($invisible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_RemoveReadNotBookmarkedArticle'); } @@ -175,6 +187,7 @@ class pageHistoryTest extends minifluxTestCase $this->assertTrue($invisible, 'article is is not invisible'); $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_RemoveReadBookmarkedArticle'); } @@ -187,11 +200,37 @@ class pageHistoryTest extends minifluxTestCase $destructiveLink->click(); $this->expectedCounterPage = 3; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_NoReadNotBookmarkedArticles', FALSE); $this->ignorePageTitle = TRUE; } + public function testUnreadCounterFromNothingToValue() + { + // load different fixture and reload the page + $backupDataTester = static::$databaseTester; + + static::$databaseTester = NULL; + $this->getDatabaseTester('fixture_OnlyReadArticles', FALSE)->onSetUp(); + + static::$databaseTester = $backupDataTester; + $this->refresh(); + + // start the "real" test + // dont't trust the name! The Article is read+bookmarked here + $article = $this->getArticleUnreadBookmarked(); + + $link = $this->getLinkReadStatusToogle($article); + $link->click(); + + $this->waitForIconMarkReadInvisible($article); + + $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE + static::DEFAULT_COUNTER_UNREAD - 1; + $this->expectedCounterUnread = 1; + $this->expectedDataSet = $this->getDataSet('fixture_OneUnreadArticle',FALSE); + } + public function testRedirectWithZeroArticles() { $articles = $this->getArticles(); @@ -207,6 +246,8 @@ class pageHistoryTest extends minifluxTestCase $visible = $this->waitForAlert(); $this->assertTrue($visible, 'alert box did not appear'); + $this->expectedCounterPage = NULL; + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + static::DEFAULT_COUNTER_PAGE; $this->expectedDataSet = $this->getDataSet('expected_NoReadArticles', FALSE); $this->ignorePageTitle = TRUE; diff --git a/tests/integration/pageUnreadTest.php b/tests/integration/pageUnreadTest.php index 3ef550c..af0be12 100644 --- a/tests/integration/pageUnreadTest.php +++ b/tests/integration/pageUnreadTest.php @@ -199,6 +199,7 @@ class pageUnreadTest extends minifluxTestCase $read = $this->waitForArticlesMarkRead(); $this->assertTrue($read, 'there are still unread articles'); + $this->expectedCounterPage = NULL; $this->expectedCounterUnread = ''; $this->expectedPageUrl = PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=feeds¬hing_to_read=1'; $this->expectedDataSet = $this->getDataSet('fixture_OnlyReadArticles', FALSE); @@ -214,6 +215,7 @@ class pageUnreadTest extends minifluxTestCase $read = $this->waitForArticlesMarkRead(); $this->assertTrue($read, 'there are still unread articles'); + $this->expectedCounterPage = NULL; $this->expectedCounterUnread = ''; $this->expectedPageUrl = PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=feeds¬hing_to_read=1'; $this->expectedDataSet = $this->getDataSet('fixture_OnlyReadArticles', FALSE); @@ -236,6 +238,7 @@ class pageUnreadTest extends minifluxTestCase $visible = $this->waitForAlert(); $this->assertTrue($visible, 'alert box did not appear'); + $this->expectedCounterPage = NULL; $this->expectedCounterUnread = ''; $this->expectedPageUrl = PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=feeds¬hing_to_read=1'; $this->expectedDataSet = $this->getDataSet('fixture_OnlyReadArticles', FALSE);