2014-12-04 18:20:15 +01:00
|
|
|
<?php
|
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
use PHPUnit_Extensions_Selenium2TestCase_Keys as Keys;
|
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase
|
|
|
|
{
|
|
|
|
protected $basePageHeading = NULL;
|
|
|
|
protected $expectedPageUrl = NULL;
|
|
|
|
protected $expectedDataSet = NULL;
|
|
|
|
protected $expectedCounterPage = NULL;
|
|
|
|
protected $expectedCounterUnread = '';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
protected $ignorePageTitle = FALSE;
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
protected static $databaseConnection = NULL;
|
|
|
|
protected static $databaseTester = NULL;
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
private $waitTimeout = 5000;
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public static function browsers()
|
|
|
|
{
|
|
|
|
return json_decode(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BROWSERS, true);
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
protected function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// trigger database fixtures onSetUp routines
|
2015-01-15 02:01:54 +01:00
|
|
|
$dataset = $this->getDataSet('fixture_feed1', 'fixture_feed2');
|
|
|
|
$this->getDatabaseTester($dataset)->onSetUp();
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
// Set the base URL for the tests.
|
|
|
|
$this->setBrowserUrl(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL);
|
|
|
|
}
|
|
|
|
|
2015-01-04 22:25:28 +01:00
|
|
|
public function doLoginIfRequired($url)
|
2014-12-04 18:20:15 +01:00
|
|
|
{
|
|
|
|
// (re)load the requested page
|
|
|
|
$this->url($url);
|
|
|
|
|
|
|
|
// check if login is need and login
|
|
|
|
$elements = $this->elements($this->using('css selector')->value('body#login-page'));
|
|
|
|
|
|
|
|
if (count($elements) === 1) {
|
2015-01-15 02:01:54 +01:00
|
|
|
$this->byCssSelector("input[value='".DB_FILENAME."']")->click();
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$this->byId('form-username')->click();
|
|
|
|
$this->keys('admin');
|
|
|
|
$this->byId('form-password')->click();
|
|
|
|
$this->keys('admin');
|
|
|
|
$this->byTag('form')->submit();
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$this->url($url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function tearDownAfterClass()
|
|
|
|
{
|
|
|
|
static::$databaseConnection = NULL;
|
|
|
|
static::$databaseTester = NULL;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
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');
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
// url has not been changed (its likely that everything was done via javascript then)
|
|
|
|
$this->assertEquals($this->expectedPageUrl, $this->url(), 'URL has been changed.');
|
|
|
|
|
|
|
|
// some tests switch to a page where no counter exists and the expected
|
|
|
|
// pagetitle doesn't match to definition.
|
|
|
|
if ($this->ignorePageTitle === FALSE) {
|
|
|
|
//remove LEFT-TO-RIGHT MARK char from string as the webdriver does it when using text() on the page <h[1|2|3]>
|
|
|
|
$pagetitle = preg_replace('/\x{200E}/u', '', $this->title());
|
|
|
|
$this->assertEquals($this->getExpectedPageTitle(), $pagetitle, 'page title differ from expectation');
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
// 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'));
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
// TODO: changes row order, why?
|
2015-01-04 22:25:28 +01:00
|
|
|
//$actualDataSet = $this->getConnection()->createDataSet();
|
2014-12-04 18:20:15 +01:00
|
|
|
$actualDataSet = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
|
2015-01-04 22:25:28 +01:00
|
|
|
$actualDataSet->addTable('items', 'SELECT * FROM items');
|
2014-12-04 18:20:15 +01:00
|
|
|
$actualDataSetFiltered = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($actualDataSet);
|
|
|
|
$actualDataSetFiltered->setExcludeColumnsForTable('items', array('updated'));
|
|
|
|
|
|
|
|
PHPUnit_Extensions_Database_TestCase::assertDataSetsEqual($expectedDataSetFiltered, $actualDataSetFiltered, 'Unexpected changes in database');
|
|
|
|
}
|
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
protected function getDataSet()
|
2014-12-04 18:20:15 +01:00
|
|
|
{
|
|
|
|
$compositeDs = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet();
|
2015-01-15 02:01:54 +01:00
|
|
|
$dataSetFiles = func_get_args();
|
2014-12-04 18:20:15 +01:00
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
foreach ($dataSetFiles as $dataSetFile) {
|
|
|
|
$ds = new PHPUnit_Extensions_Database_DataSet_XmlDataSet(dirname(__FILE__).DIRECTORY_SEPARATOR.'datasets'.DIRECTORY_SEPARATOR.$dataSetFile.'.xml');
|
|
|
|
$compositeDs->addDataSet($ds);
|
2014-12-04 18:20:15 +01:00
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
return $compositeDs;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
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';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
if (!ENABLE_MULTIPLE_DB) {
|
|
|
|
throw new Exception('Enable multiple databases support to run the tests!');
|
|
|
|
}
|
|
|
|
|
|
|
|
$picoDb = new PicoDb\Database(array(
|
|
|
|
'driver' => 'sqlite',
|
|
|
|
'filename' => \Model\Database\get_path(),
|
|
|
|
));
|
|
|
|
|
|
|
|
$picoDb->schema()->check(Schema\VERSION);
|
|
|
|
|
|
|
|
// make the database world writeable, maybe the current
|
|
|
|
// user != webserver user
|
|
|
|
chmod(\Model\Database\get_path(), 0666);
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
// get pdo object
|
|
|
|
$pdo = $picoDb->getConnection();
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
// 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');
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
return static::$databaseConnection;
|
|
|
|
}
|
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
protected function getDatabaseTester($dataset)
|
2014-12-04 18:20:15 +01:00
|
|
|
{
|
|
|
|
if (is_null(static::$databaseTester)) {
|
2015-01-15 02:01:54 +01:00
|
|
|
$rdataset = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($dataset);
|
|
|
|
$rdataset->addSubStrReplacement('##TIMESTAMP##', substr((string)(time()-100), 0, -2));
|
2014-12-04 18:20:15 +01:00
|
|
|
|
|
|
|
// article/feed import on database->onSetUp();
|
2015-01-15 02:01:54 +01:00
|
|
|
$tester = new PHPUnit_Extensions_Database_DefaultTester($this->getConnection());
|
2014-12-04 18:20:15 +01:00
|
|
|
$tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT());
|
|
|
|
$tester->setDataSet($rdataset);
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
static::$databaseTester = $tester;
|
2015-01-04 22:25:28 +01:00
|
|
|
}
|
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
return static::$databaseTester;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
private function getCounterUnread()
|
|
|
|
{
|
|
|
|
$value = $this->element($this->using('id')->value('nav-counter'))->text();
|
|
|
|
return $value;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
private function getCounterPage()
|
|
|
|
{
|
|
|
|
$value = NULL;
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$elements = $this->elements($this->using('id')->value('page-counter'));
|
|
|
|
|
|
|
|
if (count($elements) === 1) {
|
|
|
|
$value = $elements[0]->text();
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
// public to be accessible within an closure
|
|
|
|
public function isElementVisible($element)
|
|
|
|
{
|
|
|
|
$displaySize = $element->size();
|
|
|
|
|
|
|
|
return ($element->displayed() && $displaySize['height']>0 && $displaySize['width']>0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// public to be accessible within an closure
|
|
|
|
public function isElementInvisible($element)
|
|
|
|
{
|
|
|
|
$displaySize = $element->size();
|
|
|
|
|
|
|
|
return ($element->displayed() === FALSE || $displaySize['height']=0 || $displaySize['width']=0);
|
|
|
|
}
|
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
private function waitForElementVisibility($element, $visible)
|
|
|
|
{
|
|
|
|
// return false in case of timeout
|
|
|
|
try {
|
2015-01-15 02:01:54 +01:00
|
|
|
// Workaround for PHP < 5.4
|
|
|
|
$CI = $this;
|
|
|
|
|
|
|
|
$value = $this->waitUntil(function() use($CI, $element, $visible) {
|
2014-12-04 18:20:15 +01:00
|
|
|
// a "No such Element" or "Stale Element Reference" exception is
|
|
|
|
// valid if an object should disappear
|
|
|
|
try {
|
2015-01-15 02:01:54 +01:00
|
|
|
if (($visible && $CI->isElementVisible($element))
|
|
|
|
|| (! $visible && $CI->isElementInvisible($element))) {
|
2014-12-04 18:20:15 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
|
|
|
|
|
|
|
|
$noSuchElement = ($e->getCode() === PHPUnit_Extensions_Selenium2TestCase_WebDriverException::NoSuchElement
|
|
|
|
|| $e->getCode() === PHPUnit_Extensions_Selenium2TestCase_WebDriverException::StaleElementReference);
|
|
|
|
|
|
|
|
if (($visible === FALSE) && ($noSuchElement)) {
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, $this->waitTimeout);
|
|
|
|
}
|
|
|
|
catch(PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
|
|
|
|
if ($e->getCode() === PHPUnit_Extensions_Selenium2TestCase_WebDriverException::Timeout) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function waitForElementCountByCssSelector($cssSelector, $elementCount)
|
|
|
|
{
|
|
|
|
// return false in case of timeout
|
|
|
|
try {
|
|
|
|
// Workaround for PHP < 5.4
|
|
|
|
$CI = $this;
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$value = $this->waitUntil(function() use($cssSelector, $elementCount, $CI) {
|
|
|
|
$elements = $CI->elements($CI->using('css selector')->value($cssSelector));
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
if (count($elements) === $elementCount) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}, $this->waitTimeout);
|
|
|
|
}
|
|
|
|
catch(PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
|
|
|
|
if ($e->getCode() === PHPUnit_Extensions_Selenium2TestCase_WebDriverException::Timeout) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
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);
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
if (($attributeHasValue && !$invertMatch) || (!$attributeHasValue && $invertMatch)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}, $this->waitTimeout);
|
|
|
|
}
|
|
|
|
catch(PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
|
|
|
|
if ($e->getCode() === PHPUnit_Extensions_Selenium2TestCase_WebDriverException::Timeout) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
return $value;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
private function waitForIconMarkRead($article, $visible)
|
|
|
|
{
|
|
|
|
$icon = $article->elements($article->using('css selector')->value('span.read-icon'));
|
|
|
|
|
|
|
|
$value = $this->waitForElementVisibility($icon[0], $visible);
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function waitForIconBookmark($article, $visible)
|
|
|
|
{
|
|
|
|
$icon = $article->elements($article->using('css selector')->value('span.bookmark-icon'));
|
|
|
|
|
|
|
|
$value = $this->waitForElementVisibility($icon[0], $visible);
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBasePageHeading()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* WORKAROUND: Its not possible to get an elements text content without
|
|
|
|
* the text of its childs. Thats why we have to differ between
|
|
|
|
* pageheadings with counter and without counter.
|
|
|
|
*/
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
// text of its childs
|
|
|
|
$pageHeading = $this->byCssSelector('div.page-header > h2:first-child')->text();
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
// Some PageHeadings have a counter included
|
|
|
|
$innerHeadingElements = $this->elements($this->using('css selector')->value('div.page-header > h2:first-child *'));
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
if (count($innerHeadingElements) > 0)
|
|
|
|
{
|
|
|
|
$innerHeading = $innerHeadingElements[0]->text();
|
|
|
|
$pageHeading = substr($pageHeading, 0, (strlen($innerHeading) * -1));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $pageHeading;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURLPageUnread()
|
|
|
|
{
|
|
|
|
return PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=unread';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURLPageBookmarks()
|
|
|
|
{
|
|
|
|
return PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=bookmarks';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURLPageHistory()
|
|
|
|
{
|
|
|
|
return PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=history';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURLPageFirstFeed()
|
|
|
|
{
|
|
|
|
return PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=feed-items&feed_id=1';
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getURLPagePreferences()
|
|
|
|
{
|
|
|
|
return PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=config';
|
|
|
|
}
|
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
public function getURLPageSubscriptions()
|
|
|
|
{
|
|
|
|
return PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_BASEURL.'?action=feeds';
|
|
|
|
}
|
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getShortcutNextItemA()
|
|
|
|
{
|
|
|
|
return 'n';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getShortcutNextItemB()
|
|
|
|
{
|
|
|
|
return 'j';
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
public function getShortcutNextItemC()
|
|
|
|
{
|
|
|
|
return PHPUnit_Extensions_Selenium2TestCase_Keys::RIGHT;
|
|
|
|
}
|
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getShortcutPreviousItemA()
|
|
|
|
{
|
|
|
|
return 'p';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getShortcutPreviousItemB()
|
|
|
|
{
|
|
|
|
return 'k';
|
|
|
|
}
|
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
public function getShortcutPreviousItemC()
|
|
|
|
{
|
|
|
|
return PHPUnit_Extensions_Selenium2TestCase_Keys::LEFT;
|
|
|
|
}
|
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getShortcutToogleReadStatus()
|
|
|
|
{
|
|
|
|
return 'm';
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getShortcutToogleBookmarkStatus()
|
|
|
|
{
|
|
|
|
return 'f';
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getShortcutGoToUnread()
|
|
|
|
{
|
|
|
|
return 'gu';
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getArticles()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article';
|
|
|
|
|
|
|
|
$articles = $this->elements($this->using('css selector')->value($cssSelector));
|
|
|
|
return $articles;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getArticlesUnread()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-item-status="unread"]';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$articles = $this->elements($this->using('css selector')->value($cssSelector));
|
|
|
|
return $articles;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getArticlesRead()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-item-status="read"]';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$articles = $this->elements($this->using('css selector')->value($cssSelector));
|
|
|
|
return $articles;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getArticlesNotBookmarked()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-item-bookmark="0"]';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$articles = $this->elements($this->using('css selector')->value($cssSelector));
|
|
|
|
return $articles;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getArticlesNotFromFeedOne()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article:not(.feed-1)';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$articles = $this->elements($this->using('css selector')->value($cssSelector));
|
|
|
|
return $articles;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
public function getFeedFailed()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-feed-id="4"]';
|
|
|
|
|
|
|
|
$feed = $this->element($this->using('css selector')->value($cssSelector));
|
|
|
|
return $feed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFeedDisabled()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-feed-id="2"]';
|
|
|
|
|
|
|
|
$feed = $this->element($this->using('css selector')->value($cssSelector));
|
|
|
|
return $feed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFeedErrorMessages()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article .feed-parsing-error';
|
|
|
|
|
|
|
|
if (func_num_args() === 0) {
|
|
|
|
$feed = $this;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$feed = func_get_arg(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
$feeds = $feed->elements($this->using('css selector')->value($cssSelector));
|
|
|
|
|
|
|
|
// Workaround for PHP < 5.4
|
|
|
|
$CI = $this;
|
|
|
|
|
|
|
|
return array_filter($feeds, function($feed) use($CI) {
|
|
|
|
return $CI->isElementVisible($feed);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getArticleUnreadNotBookmarked()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-item-id="7c6afaa5"]';
|
|
|
|
|
|
|
|
$article = $this->element($this->using('css selector')->value($cssSelector));
|
|
|
|
return $article;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getArticleReadNotBookmarked()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-item-id="9b20eb66"]';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$article = $this->element($this->using('css selector')->value($cssSelector));
|
|
|
|
return $article;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArticleUnreadBookmarked()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-item-id="7cb2809d"]';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$article = $this->element($this->using('css selector')->value($cssSelector));
|
|
|
|
return $article;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArticleReadBookmarked()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-item-id="9fa78b54"]';
|
|
|
|
|
|
|
|
$articles = $this->element($this->using('css selector')->value($cssSelector));
|
|
|
|
return $articles;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinkReadStatusToogle($article)
|
|
|
|
{
|
|
|
|
$link = $article->element($article->using('css selector')->value('a.mark'));
|
|
|
|
return $link;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinkBookmarkStatusToogle($article)
|
|
|
|
{
|
|
|
|
$link = $article->element($article->using('css selector')->value('a.bookmark'));
|
|
|
|
return $link;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinkRemove($article)
|
|
|
|
{
|
|
|
|
$link = $article->element($article->using('css selector')->value('a.delete'));
|
|
|
|
return $link;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getLinkFeedMarkReadHeader()
|
|
|
|
{
|
|
|
|
$link = $this->element($this->using('css selector')->value('div.page-header a[data-action="mark-feed-read"]'));
|
|
|
|
return $link;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getLinkFeedMarkReadBottom()
|
|
|
|
{
|
|
|
|
$link = $this->element($this->using('css selector')->value('div#bottom-menu a[data-action="mark-feed-read"]'));
|
|
|
|
return $link;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getLinkMarkAllReadHeader()
|
|
|
|
{
|
2015-04-19 10:17:29 +02:00
|
|
|
$link = $this->element($this->using('css selector')->value('div.page-header a[href|="?action=mark-all-read"]'));
|
2014-12-04 18:20:15 +01:00
|
|
|
return $link;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getLinkMarkAllReadBottom()
|
|
|
|
{
|
2015-04-19 10:17:29 +02:00
|
|
|
$link = $this->element($this->using('css selector')->value('div#bottom-menu a[href|="?action=mark-all-read"]'));
|
2014-12-04 18:20:15 +01:00
|
|
|
return $link;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function getLinkFlushHistory()
|
|
|
|
{
|
|
|
|
$link = $this->element($this->using('css selector')->value('div.page-header a[href="?action=confirm-flush-history"]'));
|
|
|
|
return $link;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinkDestructive()
|
|
|
|
{
|
|
|
|
$link = $this->element($this->using('css selector')->value('a.btn-red'));
|
|
|
|
return $link;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2015-01-15 02:01:54 +01:00
|
|
|
public function getAlertBox()
|
|
|
|
{
|
|
|
|
$cssSelector = 'p.alert';
|
|
|
|
|
|
|
|
$alertBox = $this->elements($this->using('css selector')->value($cssSelector));
|
|
|
|
return $alertBox;
|
|
|
|
}
|
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function waitForArticleIsCurrentArticle($article)
|
|
|
|
{
|
|
|
|
$isCurrent = $this->waitForElementAttributeHasValue($article, 'id', 'current-item');
|
|
|
|
return $isCurrent;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function waitForArticleIsNotCurrentArticle($article)
|
|
|
|
{
|
|
|
|
$isCurrent = $this->waitForElementAttributeHasValue($article, 'id', 'current-item', TRUE);
|
|
|
|
return $isCurrent;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function waitForIconMarkReadVisible($article)
|
|
|
|
{
|
|
|
|
$visible = $this->waitForIconMarkRead($article, TRUE);
|
|
|
|
return $visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function waitForIconMarkReadInvisible($article)
|
|
|
|
{
|
|
|
|
$invisible = $this->waitForIconMarkRead($article, FALSE);
|
|
|
|
return $invisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function waitForIconBookmarkVisible($article)
|
|
|
|
{
|
|
|
|
$visible = $this->waitForIconBookmark($article, TRUE);
|
|
|
|
return $visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function waitForIconBookmarkInvisible($article)
|
|
|
|
{
|
|
|
|
$invisible = $this->waitForIconBookmark($article, FALSE);
|
|
|
|
return $invisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function waitForArticleInvisible($article)
|
|
|
|
{
|
|
|
|
$invisible = $this->waitForElementVisibility($article, FALSE);
|
|
|
|
return $invisible;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function waitForArticlesMarkRead()
|
|
|
|
{
|
|
|
|
$cssSelector = 'article[data-item-status="unread"]';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$read = $this->waitForElementCountByCssSelector($cssSelector, 0);
|
|
|
|
return $read;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function waitForAlert()
|
|
|
|
{
|
|
|
|
$cssSelector = 'p.alert';
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$visible = $this->waitForElementCountByCssSelector($cssSelector, 1);
|
|
|
|
return $visible;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function sendKeysAndWaitForPageLoaded($keys)
|
|
|
|
{
|
|
|
|
$this->keys($keys);
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
// Workaround for PHP < 5.4
|
|
|
|
$CI = $this;
|
|
|
|
|
|
|
|
$this->waitUntil(function() use($CI) {
|
|
|
|
$readyState = $CI->execute(array(
|
|
|
|
'script' => 'return document.readyState;',
|
|
|
|
'args' => array()
|
|
|
|
));
|
|
|
|
|
|
|
|
if ($readyState === 'complete') {
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
}, $this->waitTimeout);
|
2014-12-04 18:20:15 +01:00
|
|
|
}
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
public function setArticleAsCurrentArticle($article)
|
|
|
|
{
|
|
|
|
$script = 'document.getElementById("' .$article->attribute('id') .'").id = "current-item";'
|
|
|
|
. 'return true';
|
|
|
|
|
|
|
|
$this->execute(array(
|
|
|
|
'script' => $script,
|
|
|
|
'args' => array()
|
|
|
|
));
|
2015-01-04 22:25:28 +01:00
|
|
|
|
2014-12-04 18:20:15 +01:00
|
|
|
$result = $this->waitForArticleIsCurrentArticle($article);
|
|
|
|
if ($result === FALSE) {
|
|
|
|
throw new Exception('the article could not be set as current article.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-19 10:17:29 +02:00
|
|
|
?>
|