diff --git a/tests/integration/keyboardShortcutsTest.php b/tests/integration/keyboardShortcutsTest.php index dd1c781..514a334 100644 --- a/tests/integration/keyboardShortcutsTest.php +++ b/tests/integration/keyboardShortcutsTest.php @@ -6,12 +6,12 @@ class keyboardShortcutTest extends minifluxTestCase { const DEFAULT_COUNTER_PAGE = 8; const DEFAULT_COUNTER_UNREAD = 6; - + public function setUpPage() { $url = $this->getURLPageFirstFeed(); - parent::setUpPage($url); - + $this->doLoginIfRequired($url); + $this->basePageHeading = $this->getBasePageHeading(); $this->expectedPageUrl = $url; } @@ -24,127 +24,127 @@ class keyboardShortcutTest extends minifluxTestCase public function testNextItemShortcutA() { $articles = $this->getArticles(); - + $this->setArticleAsCurrentArticle($articles[0]); $this->keys($this->getShortcutNextItemA()); $firstIsNotCurrentArticle = $this->waitForArticleIsNotCurrentArticle($articles[0]); $secondIsCurrentArticle = $this->waitForArticleIsCurrentArticle($articles[1]); - + $this->assertTrue($firstIsNotCurrentArticle, 'The first Article is still the current Article'); $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'); } - + public function testNextItemShortcutB() { $articles = $this->getArticles(); - + $this->setArticleAsCurrentArticle($articles[0]); $this->keys($this->getShortcutNextItemB()); - + $firstIsNotCurrentArticle = $this->waitForArticleIsNotCurrentArticle($articles[0]); $secondIsCurrentArticle = $this->waitForArticleIsCurrentArticle($articles[1]); - + $this->assertTrue($firstIsNotCurrentArticle, 'The first Article is still the current Article'); $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');; } - + public function testPreviousItemA() { $articles = $this->getArticles(); - + $this->setArticleAsCurrentArticle($articles[1]); $this->keys($this->getShortcutPreviousItemA()); - + $firstIsCurrentArticle = $this->waitForArticleIsCurrentArticle($articles[0]); $secondIsNotCurrentArticle = $this->waitForArticleIsNotCurrentArticle($articles[1]); - + $this->assertTrue($firstIsCurrentArticle, 'The first Article is not the current Article'); $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'); } - + public function testPreviousItemB() { $articles = $this->getArticles(); - + $this->setArticleAsCurrentArticle($articles[1]); $this->keys($this->getShortcutPreviousItemB()); - + $firstIsCurrentArticle = $this->waitForArticleIsCurrentArticle($articles[0]); $secondIsNotCurrentArticle = $this->waitForArticleIsNotCurrentArticle($articles[1]); - + $this->assertTrue($firstIsCurrentArticle, 'The first Article is not the current Article'); $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'); } - + public function testNextStopsAtLastArticle() { $articles = $this->getArticles(); $lastIndex = count($articles) - 1; - + $this->setArticleAsCurrentArticle($articles[$lastIndex]); $this->keys($this->getShortcutNextItemA()); - + $firstIsNotCurrentArticle = $this->waitForArticleIsNotCurrentArticle($articles[0]); $lastIsCurrentArticle = $this->waitForArticleIsCurrentArticle($articles[$lastIndex]); - + $this->assertTrue($firstIsNotCurrentArticle, 'The first Article is still the current Article'); $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'); } - + public function testPreviousStopsAtFirstArticle() { $articles = $this->getArticles(); $lastIndex = count($articles) - 1; - + $this->setArticleAsCurrentArticle($articles[0]); $this->keys($this->getShortcutPreviousItemA()); - + $lastIsNotCurrentArticle = $this->waitForArticleIsNotCurrentArticle($articles[$lastIndex]); $firstIsCurrentArticle = $this->waitForArticleIsCurrentArticle($articles[0]); - + $this->assertTrue($lastIsNotCurrentArticle, 'The last Article is still the current Article'); $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'); } - + public function testShortcutsOnInputFiledAreDisabled() { $url = $this->getURLPagePreferences(); - + $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'); - + $this->ignorePageTitle = TRUE; } - + public function testGoToBookmarks() { $this->sendKeysAndWaitForPageLoaded('gb'); @@ -153,34 +153,34 @@ class keyboardShortcutTest extends minifluxTestCase $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = $this->getURLPageBookmarks(); $this->expectedDataSet = $this->getDataSet('fixture_feed1'); - + $this->ignorePageTitle = TRUE; } - + public function testGoToHistory() { $this->sendKeysAndWaitForPageLoaded('gh'); - + $this->expectedCounterPage = '6'; $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = $this->getURLPageHistory(); $this->expectedDataSet = $this->getDataSet('fixture_feed1'); - + $this->ignorePageTitle = TRUE; } public function testGoToUnread() { $this->sendKeysAndWaitForPageLoaded($this->getShortcutGoToUnread()); - + $this->expectedCounterPage = '6'; $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = $this->getURLPageUnread(); $this->expectedDataSet = $this->getDataSet('fixture_feed1'); - + $this->ignorePageTitle = TRUE; } - + public function testGoToSubscriptions() { $this->sendKeysAndWaitForPageLoaded('gs'); @@ -188,18 +188,18 @@ class keyboardShortcutTest extends minifluxTestCase $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=feeds'; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); - + $this->ignorePageTitle = TRUE; } - + public function testGoToPreferences() { $this->sendKeysAndWaitForPageLoaded('gp'); - + $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedPageUrl = $this->getURLPagePreferences(); $this->expectedDataSet = $this->getDataSet('fixture_feed1'); - + $this->ignorePageTitle = TRUE; } } diff --git a/tests/integration/minifluxTestCase.php b/tests/integration/minifluxTestCase.php index de80179..ed119ce 100644 --- a/tests/integration/minifluxTestCase.php +++ b/tests/integration/minifluxTestCase.php @@ -7,34 +7,32 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase protected $expectedDataSet = NULL; protected $expectedCounterPage = NULL; protected $expectedCounterUnread = ''; - + protected $ignorePageTitle = FALSE; - + protected static $databaseConnection = NULL; protected static $databaseTester = NULL; - + private $waitTimeout = 5000; - + public static function browsers() { return json_decode(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BROWSERS, true); } - + protected function setUp() { parent::setUp(); // trigger database fixtures onSetUp routines $this->getDatabaseTester('fixture_feed1', TRUE)->onSetUp(); - + // Set the base URL for the tests. $this->setBrowserUrl(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL); } - public function setUpPage($url) + public function doLoginIfRequired($url) { - parent::setUpPage(); - // (re)load the requested page $this->url($url); @@ -43,13 +41,13 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase if (count($elements) === 1) { $this->url('?action=select-db&database='.DB_FILENAME); - + $this->byId('form-username')->click(); $this->keys('admin'); $this->byId('form-password')->click(); $this->keys('admin'); $this->byTag('form')->submit(); - + $this->url($url); } } @@ -59,13 +57,13 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase static::$databaseConnection = NULL; static::$databaseTester = NULL; } - + protected function assertPostConditions() { // counter exists on every page $this->assertEquals($this->expectedCounterPage, $this->getCounterPage(), 'page-counter differ from expectation'); $this->assertEquals($this->expectedCounterUnread, $this->getCounterUnread(), 'unread counter differ from expectation'); - + // url has not been changed (its likely that everything was done via javascript then) $this->assertEquals($this->expectedPageUrl, $this->url(), 'URL has been changed.'); @@ -76,16 +74,16 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase $pagetitle = preg_replace('/\x{200E}/u', '', $this->title()); $this->assertEquals($this->getExpectedPageTitle(), $pagetitle, 'page title differ from expectation'); } - + // assert that the current database matches the expected database $expectedDataSetFiltered = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($this->expectedDataSet); $expectedDataSetFiltered->addIncludeTables(array('items')); $expectedDataSetFiltered->setExcludeColumnsForTable('items', array('updated')); - + // TODO: changes row order, why? - //$actualDataSet = $this->getConnection()->createDataSet(); + //$actualDataSet = $this->getConnection()->createDataSet(); $actualDataSet = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection()); - $actualDataSet->addTable('items', 'SELECT * FROM items'); + $actualDataSet->addTable('items', 'SELECT * FROM items'); $actualDataSetFiltered = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($actualDataSet); $actualDataSetFiltered->setExcludeColumnsForTable('items', array('updated')); @@ -98,22 +96,22 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase $ds1 = new PHPUnit_Extensions_Database_DataSet_XmlDataSet(dirname(__FILE__).DIRECTORY_SEPARATOR.'datasets'.DIRECTORY_SEPARATOR.$dataSetFile.'.xml'); $compositeDs->addDataSet($ds1); - + if ($appendFeed2) { // feed2 should be normaly untouched $ds2 = new PHPUnit_Extensions_Database_DataSet_XmlDataSet(dirname(__FILE__).DIRECTORY_SEPARATOR.'datasets'.DIRECTORY_SEPARATOR.'fixture_feed2.xml'); $compositeDs->addDataSet($ds2); } - + return $compositeDs; } - + protected function getConnection() { if (is_null(static::$databaseConnection)) { // let Miniflux setup the database require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common.php'; - + if (!ENABLE_MULTIPLE_DB) { throw new Exception('Enable multiple databases support to run the tests!'); } @@ -128,17 +126,17 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase // make the database world writeable, maybe the current // user != webserver user chmod(\Model\Database\get_path(), 0666); - + // get pdo object $pdo = $picoDb->getConnection(); - + // disable fsync! its awefull slow without transactions and I found // no way to use setDataSet function with transactions $pdo->exec("pragma synchronous = off;"); static::$databaseConnection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo, 'sqlite'); } - + return static::$databaseConnection; } @@ -153,29 +151,29 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase $rdataset = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($dataset); $rdataset->addSubStrReplacement('##TIMESTAMP##', substr((string)(time()-100), 0, -2)); $tester->setDataSet($rdataset); - + static::$databaseTester = $tester; - } - + } + return static::$databaseTester; } - + private function getCounterUnread() { $value = $this->element($this->using('id')->value('nav-counter'))->text(); return $value; } - + private function getCounterPage() { $value = NULL; - + $elements = $this->elements($this->using('id')->value('page-counter')); if (count($elements) === 1) { $value = $elements[0]->text(); } - + return $value; } @@ -224,10 +222,10 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase try { // Workaround for PHP < 5.4 $CI = $this; - + $value = $this->waitUntil(function() use($cssSelector, $elementCount, $CI) { $elements = $CI->elements($CI->using('css selector')->value($cssSelector)); - + if (count($elements) === $elementCount) { return TRUE; } @@ -243,14 +241,14 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase return $value; } - + private function waitForElementAttributeHasValue($element, $attribute, $attributeValue, $invertMatch = FALSE) { // return false in case of timeout try { $value = $this->waitUntil(function() use($element, $attribute, $attributeValue, $invertMatch) { $attributeHasValue = ($element->attribute($attribute) === $attributeValue); - + if (($attributeHasValue && !$invertMatch) || (!$attributeHasValue && $invertMatch)) { return TRUE; } @@ -263,10 +261,10 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase throw $e; } } - + return $value; } - + private function waitForIconMarkRead($article, $visible) { $icon = $article->elements($article->using('css selector')->value('span.read-icon')); @@ -290,13 +288,13 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase * the text of its childs. Thats why we have to differ between * pageheadings with counter and without counter. */ - + // text of its childs $pageHeading = $this->byCssSelector('div.page-header > h2:first-child')->text(); - + // Some PageHeadings have a counter included $innerHeadingElements = $this->elements($this->using('css selector')->value('div.page-header > h2:first-child *')); - + if (count($innerHeadingElements) > 0) { $innerHeading = $innerHeadingElements[0]->text(); @@ -325,7 +323,7 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase { return PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=feed-items&feed_id=1'; } - + public function getURLPagePreferences() { return PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=config'; @@ -340,7 +338,7 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase { return 'j'; } - + public function getShortcutPreviousItemA() { return 'p'; @@ -355,17 +353,17 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase { return 'm'; } - + public function getShortcutToogleBookmarkStatus() { return 'f'; } - + public function getShortcutGoToUnread() { return 'gu'; } - + public function getArticles() { $cssSelector = 'article'; @@ -373,39 +371,39 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase $articles = $this->elements($this->using('css selector')->value($cssSelector)); return $articles; } - + public function getArticlesUnread() { $cssSelector = 'article[data-item-status="unread"]'; - + $articles = $this->elements($this->using('css selector')->value($cssSelector)); return $articles; } - + public function getArticlesRead() { $cssSelector = 'article[data-item-status="read"]'; - + $articles = $this->elements($this->using('css selector')->value($cssSelector)); return $articles; } - + public function getArticlesNotBookmarked() { $cssSelector = 'article[data-item-bookmark="0"]'; - + $articles = $this->elements($this->using('css selector')->value($cssSelector)); return $articles; } - + public function getArticlesNotFromFeedOne() { $cssSelector = 'article:not(.feed-1)'; - + $articles = $this->elements($this->using('css selector')->value($cssSelector)); return $articles; } - + public function getArticleUnreadNotBookmarked() { $cssSelector = 'article[data-item-id="7c6afaa5"]'; @@ -413,11 +411,11 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase $article = $this->element($this->using('css selector')->value($cssSelector)); return $article; } - + public function getArticleReadNotBookmarked() { $cssSelector = 'article[data-item-id="9b20eb66"]'; - + $article = $this->element($this->using('css selector')->value($cssSelector)); return $article; } @@ -425,7 +423,7 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase public function getArticleUnreadBookmarked() { $cssSelector = 'article[data-item-id="7cb2809d"]'; - + $article = $this->element($this->using('css selector')->value($cssSelector)); return $article; } @@ -455,31 +453,31 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase $link = $article->element($article->using('css selector')->value('a.delete')); return $link; } - + public function getLinkFeedMarkReadHeader() { $link = $this->element($this->using('css selector')->value('div.page-header a[data-action="mark-feed-read"]')); return $link; } - + public function getLinkFeedMarkReadBottom() { $link = $this->element($this->using('css selector')->value('div#bottom-menu a[data-action="mark-feed-read"]')); return $link; } - + public function getLinkMarkAllReadHeader() { $link = $this->element($this->using('css selector')->value('div.page-header a[data-action="mark-all-read"]')); return $link; } - + public function getLinkMarkAllReadBottom() { $link = $this->element($this->using('css selector')->value('div#bottom-menu a[data-action="mark-all-read"]')); return $link; } - + public function getLinkFlushHistory() { $link = $this->element($this->using('css selector')->value('div.page-header a[href="?action=confirm-flush-history"]')); @@ -491,19 +489,19 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase $link = $this->element($this->using('css selector')->value('a.btn-red')); return $link; } - + public function waitForArticleIsCurrentArticle($article) { $isCurrent = $this->waitForElementAttributeHasValue($article, 'id', 'current-item'); return $isCurrent; } - + public function waitForArticleIsNotCurrentArticle($article) { $isCurrent = $this->waitForElementAttributeHasValue($article, 'id', 'current-item', TRUE); return $isCurrent; } - + public function waitForIconMarkReadVisible($article) { $visible = $this->waitForIconMarkRead($article, TRUE); @@ -533,27 +531,27 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase $invisible = $this->waitForElementVisibility($article, FALSE); return $invisible; } - + public function waitForArticlesMarkRead() { $cssSelector = 'article[data-item-status="unread"]'; - + $read = $this->waitForElementCountByCssSelector($cssSelector, 0); return $read; } - + public function waitForAlert() { $cssSelector = 'p.alert'; - + $visible = $this->waitForElementCountByCssSelector($cssSelector, 1); return $visible; } - + public function sendKeysAndWaitForPageLoaded($keys) { $this->keys($keys); - + // Workaround for PHP < 5.4 $CI = $this; @@ -566,9 +564,9 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase if ($readyState === 'complete') { return TRUE; } - }, $this->waitTimeout); + }, $this->waitTimeout); } - + public function setArticleAsCurrentArticle($article) { $script = 'document.getElementById("' .$article->attribute('id') .'").id = "current-item";' @@ -578,7 +576,7 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase 'script' => $script, 'args' => array() )); - + $result = $this->waitForArticleIsCurrentArticle($article); if ($result === FALSE) { throw new Exception('the article could not be set as current article.'); diff --git a/tests/integration/pageBookmarksTest.php b/tests/integration/pageBookmarksTest.php index f086408..28d8f9a 100644 --- a/tests/integration/pageBookmarksTest.php +++ b/tests/integration/pageBookmarksTest.php @@ -6,12 +6,12 @@ class pageBookmarksTest extends minifluxTestCase { const DEFAULT_COUNTER_PAGE = 6; const DEFAULT_COUNTER_UNREAD = 6; - + public function setUpPage() { $url = $this->getURLPageBookmarks(); - parent::setUpPage($url); - + $this->doLoginIfRequired($url); + $this->basePageHeading = $this->getBasePageHeading(); $this->expectedPageUrl = $url; } @@ -25,22 +25,22 @@ class pageBookmarksTest extends minifluxTestCase { $articles = $this->getArticlesNotFromFeedOne(); $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'); } - + public function testOnlyBookmarkedArticles() { $articles = $this->getArticlesNotBookmarked(); $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'); } - + public function testMarkReadBookmarkedArticleLink() { $article = $this->getArticleUnreadBookmarked(); @@ -59,10 +59,10 @@ class pageBookmarksTest extends minifluxTestCase public function testMarkReadBookmarkedArticleKeyboard() { $article = $this->getArticleUnreadBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); - + $visible = $this->waitForIconMarkReadVisible($article); $this->assertTrue($visible, 'read icon is not visible'); @@ -89,7 +89,7 @@ class pageBookmarksTest extends minifluxTestCase public function testMarkUnreadBookmarkedArticleKeyboard() { $article = $this->getArticleReadBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); @@ -114,7 +114,7 @@ class pageBookmarksTest extends minifluxTestCase $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE - 1; $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_UnbookmarkReadArticle'); - + } public function testUnbookmarkReadArticleKeyboard() @@ -141,7 +141,7 @@ class pageBookmarksTest extends minifluxTestCase $invisible = $this->waitForArticleInvisible($article); $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'); @@ -191,27 +191,27 @@ class pageBookmarksTest extends minifluxTestCase $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); @@ -221,40 +221,40 @@ class pageBookmarksTest extends minifluxTestCase { // 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(); - + foreach($articles as $article) { $link = $this->getLinkBookmarkStatusToogle($article); $link->click(); - + $this->waitForArticleInvisible($article); } - + $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); diff --git a/tests/integration/pageFirstFeedTest.php b/tests/integration/pageFirstFeedTest.php index 401874a..45c2b2d 100644 --- a/tests/integration/pageFirstFeedTest.php +++ b/tests/integration/pageFirstFeedTest.php @@ -6,13 +6,13 @@ class pageFirstFeedTest extends minifluxTestCase { const DEFAULT_COUNTER_PAGE = 8; const DEFAULT_COUNTER_UNREAD = 6; - + public function setUpPage() { $url = $this->getURLPageFirstFeed(); - parent::setUpPage($url); - - $this->basePageHeading = $this->getBasePageHeading(); + $this->doLoginIfRequired($url); + + $this->basePageHeading = $this->getBasePageHeading(); $this->expectedPageUrl = $url; } @@ -25,12 +25,12 @@ class pageFirstFeedTest extends minifluxTestCase { $articles = $this->getArticlesNotFromFeedOne(); $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'); } - + public function testMarkReadNotBookmarkedArticleLink() { $article = $this->getArticleUnreadNotBookmarked(); @@ -49,18 +49,18 @@ class pageFirstFeedTest extends minifluxTestCase public function testMarkReadNotBookmarkedArticleKeyboard() { $article = $this->getArticleUnreadNotBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); - + $visible = $this->waitForIconMarkReadVisible($article); $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'); } - + public function testMarkReadBookmarkedArticleLink() { $article = $this->getArticleUnreadBookmarked(); @@ -79,10 +79,10 @@ class pageFirstFeedTest extends minifluxTestCase public function testMarkReadBookmarkedArticleKeyboard() { $article = $this->getArticleUnreadBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); - + $visible = $this->waitForIconMarkReadVisible($article); $this->assertTrue($visible, 'read icon is not visible'); @@ -105,11 +105,11 @@ class pageFirstFeedTest extends minifluxTestCase $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadNotBookmarkedArticle'); } - + public function testMarkUnreadNotBookmarkedArticleKeyboard() { $article = $this->getArticleReadNotBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); @@ -139,7 +139,7 @@ class pageFirstFeedTest extends minifluxTestCase public function testMarkUnreadBookmarkedArticleKeyboard() { $article = $this->getArticleReadBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); @@ -165,7 +165,7 @@ class pageFirstFeedTest extends minifluxTestCase $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_BookmarkReadArticle'); } - + public function testBookmarkReadArticleKeyboard() { $article = $this->getArticleReadNotBookmarked(); @@ -330,15 +330,15 @@ class pageFirstFeedTest extends minifluxTestCase $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1; $this->expectedDataSet = $this->getDataSet('expected_RemoveUnreadBookmarkedArticle'); } - + public function testMarkFeedReadHeaderLink() { $link = $this->getLinkFeedMarkReadHeader(); $link->click(); - + $read = $this->waitForArticlesMarkRead(); $this->assertTrue($read, 'there are still unread articles'); - + $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; $this->expectedCounterUnread = 2; $this->expectedDataSet = $this->getDataSet('expected_MarkFeedRead'); @@ -348,35 +348,35 @@ class pageFirstFeedTest extends minifluxTestCase { $link = $this->getLinkFeedMarkReadBottom(); $link->click(); - + $read = $this->waitForArticlesMarkRead(); $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); @@ -386,45 +386,45 @@ class pageFirstFeedTest extends minifluxTestCase { // 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(); $this->assertGreaterThanOrEqual(1, count($articles), 'no articles found'); - + foreach($articles as $article) { $link = $this->getLinkRemove($article); $link->click(); - + $this->waitForArticleInvisible($article); } - + $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 e1151ca..ed1a684 100644 --- a/tests/integration/pageHistoryTest.php +++ b/tests/integration/pageHistoryTest.php @@ -6,13 +6,13 @@ class pageHistoryTest extends minifluxTestCase { const DEFAULT_COUNTER_PAGE = 6; const DEFAULT_COUNTER_UNREAD = 6; - + public function setUpPage() { $url = $this->getURLPageHistory(); - parent::setUpPage($url); + $this->doLoginIfRequired($url);; - $this->basePageHeading = $this->getBasePageHeading(); + $this->basePageHeading = $this->getBasePageHeading(); $this->expectedPageUrl = $url; } @@ -25,22 +25,22 @@ class pageHistoryTest extends minifluxTestCase { $articles = $this->getArticlesNotFromFeedOne(); $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'); } - + public function testOnlyReadArticles() { $articles = $this->getArticlesUnread(); $this->assertEmpty($articles, 'found unread articles.'); - + $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); } - + public function testMarkUnreadNotBookmarkedArticleLink() { $article = $this->getArticleReadNotBookmarked(); @@ -55,11 +55,11 @@ class pageHistoryTest extends minifluxTestCase $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD + 1; $this->expectedDataSet = $this->getDataSet('expected_MarkUnreadNotBookmarkedArticle'); } - + public function testMarkUnreadNotBookmarkedArticleKeyboard() { $article = $this->getArticleReadNotBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); @@ -89,7 +89,7 @@ class pageHistoryTest extends minifluxTestCase public function testMarkUnreadBookmarkedArticleKeyboard() { $article = $this->getArticleReadBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); @@ -115,7 +115,7 @@ class pageHistoryTest extends minifluxTestCase $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('expected_BookmarkReadArticle'); } - + public function testBookmarkReadArticleKeyboard() { $article = $this->getArticleReadNotBookmarked(); @@ -195,37 +195,37 @@ class pageHistoryTest extends minifluxTestCase { $link = $this->getLinkFlushHistory(); $link->click(); - + $destructiveLink = $this->getLinkDestructive(); $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); @@ -235,21 +235,21 @@ class pageHistoryTest extends minifluxTestCase { $articles = $this->getArticles(); $this->assertGreaterThanOrEqual(1, count($articles), 'no articles found'); - + foreach($articles as $article) { $link = $this->getLinkReadStatusToogle($article); $link->click(); - + $this->waitForArticleInvisible($article); } - + $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 af0be12..d78848f 100644 --- a/tests/integration/pageUnreadTest.php +++ b/tests/integration/pageUnreadTest.php @@ -6,12 +6,12 @@ class pageUnreadTest extends minifluxTestCase { const DEFAULT_COUNTER_PAGE = 6; const DEFAULT_COUNTER_UNREAD = 6; - + public function setUpPage() { $url = $this->getURLPageUnread(); - parent::setUpPage($url); - + $this->doLoginIfRequired($url); + $this->expectedPageUrl = $url; } @@ -25,17 +25,17 @@ class pageUnreadTest extends minifluxTestCase { $articles = $this->getArticlesNotFromFeedOne(); $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'); } - + public function testOnlyUnreadArticles() { $articles = $this->getArticlesRead(); $this->assertEmpty($articles, 'found read articles.'); - + $this->expectedCounterPage = static::DEFAULT_COUNTER_PAGE; $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD; $this->expectedDataSet = $this->getDataSet('fixture_feed1'); @@ -59,18 +59,18 @@ class pageUnreadTest extends minifluxTestCase public function testMarkReadNotBookmarkedArticleKeyboard() { $article = $this->getArticleUnreadNotBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); - + $visible = $this->waitForArticleInvisible($article); $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_MarkReadNotBookmarkedArticle'); } - + public function testMarkReadBookmarkedArticleLink() { $article = $this->getArticleUnreadBookmarked(); @@ -89,10 +89,10 @@ class pageUnreadTest extends minifluxTestCase public function testMarkReadBookmarkedArticleKeyboard() { $article = $this->getArticleUnreadBookmarked(); - + $this->setArticleAsCurrentArticle($article); $this->keys($this->getShortcutToogleReadStatus()); - + $visible = $this->waitForArticleInvisible($article); $this->assertTrue($visible, 'article is is not invisible'); @@ -125,7 +125,7 @@ class pageUnreadTest extends minifluxTestCase $visible = $this->waitForIconBookmarkVisible($article); $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'); @@ -140,7 +140,7 @@ class pageUnreadTest extends minifluxTestCase $invisible = $this->waitForIconBookmarkInvisible($article); $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'); @@ -155,7 +155,7 @@ class pageUnreadTest extends minifluxTestCase $invisible = $this->waitForIconBookmarkInvisible($article); $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'); @@ -190,20 +190,20 @@ class pageUnreadTest extends minifluxTestCase $this->expectedCounterUnread = static::DEFAULT_COUNTER_UNREAD - 1; $this->expectedDataSet = $this->getDataSet('expected_RemoveUnreadBookmarkedArticle'); } - + public function testMarkAllReadHeaderLink() { $link = $this->getLinkMarkAllReadHeader(); $link->click(); - + $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); - + $this->ignorePageTitle = TRUE; } @@ -211,38 +211,38 @@ class pageUnreadTest extends minifluxTestCase { $link = $this->getLinkMarkAllReadBottom(); $link->click(); - + $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); - + $this->ignorePageTitle = TRUE; } - + public function testRedirectWithZeroArticles() { $articles = $this->getArticles(); $this->assertGreaterThanOrEqual(1, count($articles), 'no articles found'); - + foreach($articles as $article) { $link = $this->getLinkReadStatusToogle($article); $link->click(); - + $this->waitForArticleInvisible($article); } - + $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); - + $this->ignorePageTitle = TRUE; } }