/**
  * Test covers as anonymous.
  *
  * Check that certain elements should have an image tag,
  * when others do not.
  */
 public function testCollectionViewAnonymous()
 {
     resetState($this->config->getLms());
     $this->open('/' . $this->config->getLocale() . '/ting/collection/870970-basis%3A51043138');
     $this->abstractedPage->waitForPage();
     // Assume we are on collection page and there is a link to item page.
     $this->assertTrue($this->isElementPresent('link=Kantslag : noveller'));
     // Implicitly wait 10 seconds, since covers come via ajax.
     // It's not possible to use a more elegant solution to wait.
     // Second assertion expects to a FALSE result, which in other implementation
     // will trigger a FALSE result instantly, which is not correct.
     // So have to be sure that the AJAX call has finished first, to know
     // that the actual cover element is not present.
     sleep(5);
     // The collection item page opened above is expected to have first
     // collection items contain cover images and the second one - no.
     $this->assertElementPresent('css=.pane-ting-collection .view-mode-full .ting-collection-wrapper:eq(0) .ting-cover img');
     $this->assertElementNotPresent('css=.pane-ting-collection .view-mode-full .ting-collection-wrapper:eq(1) .ting-cover img');
     // Try to bookmark with logging in, if required.
     $this->abstractedPage->userBookmark('.action-button.bookmark-button:eq(0)');
     // Wait for the login popup, if any.
     $is_present = $this->abstractedPage->waitForElement('css=.ding-popup-content form#user-login', 5, FALSE);
     if ($is_present) {
         $this->abstractedPage->fillDingPopupLogin($this->config->getUser(), $this->config->getPass());
     }
     $this->abstractedPage->waitForElement('css=div.ding-bookmark-message');
     $msgs = array('Added to bookmarks', 'This item is in bookmarks already.');
     $this->assertTrue(in_array($this->getText('css=div.ding-bookmark-message'), $msgs));
     // Since there are issues with selenium by clicking ding popup close button,
     // simply refresh the page.
     $this->abstractedPage->refresh();
     // Bookmark again. Here the use is already logged and the item should
     // exist in bookmarks.
     $this->abstractedPage->userBookmark('.action-button.bookmark-button:eq(0)');
     $this->abstractedPage->waitForElement('css=div.ding-bookmark-message');
     $this->assertEquals('This item is in bookmarks already.', $this->getText('css=div.ding-bookmark-message'));
     // Refresh and reserve same item.
     $this->abstractedPage->refresh();
     sleep(5);
     $this->abstractedPage->userReserve('.action-button.reserve-button:eq(1)');
     sleep(5);
     $element = $this->isElementPresent('css=div.ding-popup-content .messages.status');
     if ($element == FALSE) {
         $this->assertTrue($this->isElementPresent('css=div.ding-popup-content .messages.error'));
     } else {
         $this->assertTrue($this->isElementPresent('css=div.ding-popup-content .messages.status'));
     }
     // Test if this is a collection page.
     // If this is truly a collection item is should have certain
     // information about item types and the quantity of those.
     $this->abstractedPage->refresh();
     $this->assertElementPresent('link=Bog (2)');
     // $this->assertElementPresent('link=Ebog (1)');
     // Test the anchor links.
     $this->click('link=Bog (2)');
     sleep(5);
     $this->assertTrue((bool) preg_match('/^.*ting\\/collection\\/870970-basis%3A51043138#Bog$/', $this->getLocation()));
     //   $this->click('link=Ebog (1)');
     //   $this->assertTrue((bool) preg_match('/^.*ting\/collection\/870970-basis%3A51043138#Ebog$/', $this->getLocation()));
 }
 protected function setUp()
 {
     $this->abstractedPage = new DDBTestPageAbstraction($this);
     $this->config = new DDBTestConfig();
     $this->setBrowser($this->config->getBrowser());
     $this->setBrowserUrl($this->config->getUrl());
     resetState($this->config->getLms());
 }
 protected function setUp()
 {
     $this->abstractedPage = new DDBTestPageAbstraction($this);
     $this->config = new DDBTestConfig();
     $this->setBrowser($this->config->getBrowser());
     $this->setBrowserUrl($this->config->getUrl());
     $url = $this->config->getLms() . '/alma/patron/debts?borrCard=' . $this->config->getUser() . '&pinCode=' . $this->config->getPass();
     $this->mock = new DOMDocument();
     $this->mock->loadXML(@file_get_contents($url));
     resetState($this->config->getLms());
 }
Exemple #4
0
include 'reciteOperation.php';
header('Cache-control: private, must-revalidate');
//support page back
if (!$_SESSION['userID']) {
    header("Location: ../../../reciteWord/php/login/Login.php");
}
$template = new FastTemplate("../../view/html/templates/reciteWord");
$template->define(array("main" => "reciteWord.html", "ol" => "ol.html", "li" => "li.html"));
$template->assign("MESSAGE", "");
$template->assign("NEWWORD", "");
$template->assign("DEFINITION", "You have no words need to be recited");
if (isset($_POST["classification"])) {
    $userID = $_SESSION['userID'];
    $class = $_POST["classification"];
    $_SESSION['class'] = $class;
    resetState($userID, $class);
    $wordID = selectRandomWord($userID, $class);
    $_SESSION['thisWord'] = $wordID;
    $_SESSION['class'] = $class;
    showCurrentDef($wordID);
    showCurrentWords($wordID, $class);
}
if (isset($_POST["chooseWord"])) {
    //echo "get it!";
    $chooseWord = $_POST["chooseWord"];
    $correctWordID = $_SESSION['thisWord'];
    $userID = $_SESSION['userID'];
    $class = $_SESSION['class'];
    $correctWord = verifyCorrect($correctWordID);
    if ($correctWord === $chooseWord) {
        saveRight($userID, $correctWordID);
 /**
  * Test covers for a certain item on item page as anonymous.
  */
 public function testItemPageAnonymous()
 {
     resetState($this->config->getLms());
     $this->open('/' . $this->config->getLocale());
     // Search for an item.
     $this->abstractedPage->userMakeSearch('dorthe nors');
     // Check the item title on search result page.
     $this->assertTrue($this->isElementPresent('link=Stormesteren : roman'));
     // Click on title. Goes to collection page.
     $this->click('link=Stormesteren : roman');
     $this->abstractedPage->waitForPage();
     // Check the item title on the collection page.
     $this->assertTrue($this->isElementPresent('link=Stormesteren : roman'));
     // Click on title. Goes to item page.
     $this->click('link=Stormesteren : roman');
     $this->abstractedPage->waitForPage();
     // Wait for the cover to show up.
     $is_present = $this->abstractedPage->waitForElement('css=.ting-cover-processed img', 5, FALSE);
     $this->assertTrue($is_present);
     // Test availability marker.
     $this->assertTrue($this->isElementPresent("css=#availability-870970-basis24908941"));
     // Test holdings table.
     // Open availability table.
     $this->assertTrue($this->isElementPresent("link=Holdings available on the shelf"));
     $this->click("link=Holdings available on the shelf");
     // Check copies information.
     //$this->assertTrue($this->isElementPresent("css=#holdings-870970-basis24908941 > p"));
     // $this->abstractedPage->waitForElement('css=#holdings-870970-basis24908941 > p');
     sleep(5);
     $this->assertElementContainsText('css=#holdings-870970-basis24908941 > p', 'We have 3 copies. There is 1 user in queue to loan the material.');
     // Check specific row in the availability table.
     $this->abstractedPage->waitForElement('css=.availability-holdings-table td');
     $this->assertElementContainsText('css=.availability-holdings-table td', 'Hovedbiblioteket > Voksen > > > Nors');
     // Test bookmarking & reserving.
     // Try to bookmark with logging in, if required.
     $this->abstractedPage->userBookmark('.action-button.bookmark-button:eq(0)');
     // Wait for the login popup, if any.
     $is_present = $this->abstractedPage->waitForElement('css=.ding-popup-content form#user-login', 5, FALSE);
     if ($is_present) {
         $this->abstractedPage->fillDingPopupLogin($this->config->getUser(), $this->config->getPass());
     }
     sleep(5);
     $this->abstractedPage->waitForElement('css=div.ding-bookmark-message');
     $msgs = array('Added to bookmarks', 'This item is in bookmarks already.');
     $this->assertTrue(in_array($this->getText('css=div.ding-bookmark-message'), $msgs));
     // Since there are issues with selenium by clicking ding popup close button,
     // simply refresh the page.
     $this->abstractedPage->refresh();
     // Bookmark again. Here the use is already logged and the item should
     sleep(5);
     // exist in bookmarks.
     $this->abstractedPage->userBookmark('.action-button.bookmark-button:eq(0)');
     $this->abstractedPage->waitForElement('css=div.ding-bookmark-message');
     $this->assertEquals('This item is in bookmarks already.', $this->getText('css=div.ding-bookmark-message'));
     // Refresh and reserve same item.
     $this->abstractedPage->refresh();
     $this->abstractedPage->userReserve('.action-button.reserve-button:eq(0)');
     sleep(5);
     $element = $this->isElementPresent('css=div.ding-popup-content .messages.status');
     if ($element == FALSE) {
         $this->assertTrue($this->isElementPresent('css=div.ding-popup-content .messages.error'));
     } else {
         $this->assertTrue($this->isElementPresent('css=div.ding-popup-content .messages.status'));
     }
 }