diff --git a/tests/features/bootstrap/FeatureContext.php b/tests/features/bootstrap/FeatureContext.php index 740aee9ee..7bc31ba22 100644 --- a/tests/features/bootstrap/FeatureContext.php +++ b/tests/features/bootstrap/FeatureContext.php @@ -1,35 +1,6 @@ getSession()); } + /** * @When something long is taking long but should output :text */ @@ -139,17 +112,7 @@ public function doSomethingNotThereYet() $button->click(); }); } -// -// Place your definition and hook methods here: -// -// /** -// * @Given /^I have done something with "([^"]*)"$/ -// */ -// public function iHaveDoneSomethingWith($argument) -// { -// doSomethingWith($argument); -// } -// + /** * @Given /^I have logged in as an administrator$/ */ @@ -197,6 +160,7 @@ public function iFillInWithAValidUsername($arg1) { $this->fillField($arg1, $this->params['admin_username']); } + /** * @When I fill in :arg1 with a valid password */ @@ -204,6 +168,7 @@ public function iFillInWithAValidPassword($arg1) { $this->fillField($arg1, $this->params['admin_password']); } + /** * @When /^I fill in "([^"]*)" with an email address$/ */ @@ -212,6 +177,7 @@ public function iFillInWithAnEmailAddress($fieldName) $this->data['email'] = 'email@domain.com'; // at some point really make random $this->fillField($fieldName, $this->data['email']); } + /** * @Given I fill in :arg1 with :arg2 emails */ @@ -224,7 +190,6 @@ public function iFillInWithEmails($arg1, $arg2) $this->fillField($arg1, $content); } - /** * @Given /^I should see the email address I entered$/ */ @@ -232,26 +197,7 @@ public function iShouldSeeTheEmailAddressIEntered() { $this->assertSession()->pageTextContains($this->data['email']); } - /** - * @Given /^No campaigns yet exist$/ - */ - public function iHaveNotYetCreatedCampaigns() - { - // Count the number of campaigns in phplist_message table - $result = mysqli_fetch_assoc( - mysqli_query( - $this->db,' - select - count(*) as count - from - phplist_message; - ') - ); - $campaignCount = $result['count']; - if ($campaignCount > 0) { - $this->throwExpectationException('One or more campagins already exist'); - } - } + /** * @Given /^I have subscriber with email "([^"]*)"/ */ @@ -260,14 +206,6 @@ public function iHaveSubscriber($email) $this->clickLink('S'); } - /** - * @return mysqli - */ - public function getMysqli() - { - return $this->db; - } - /** * @var array $params * @return string @@ -304,34 +242,19 @@ public function iWaitForTheAjaxResponse() $this->getSession()->wait(5000, '(0 === jQuery.active)'); } - /** - * @When I switch to iframe :arg1 - */ - public function iSwitchToIframe($arg1) - { $arg1=$this->find("css",'cke_wysiwyg_frame cke_reset'); - $this->getSession()->switchToIFrame($arg1); - - } - - /** - * Go back to main document frame. - * - * @When (I )switch to main frame - */ - public function switchToMainFrame() - { - $this->getSession()->getDriver()->switchToDefaultContent(); - } - /** * @Then I click on :arg1 */ public function iClickOn($arg1) - { $arg1= $this->find("css",'submit btn btn-primary'); - $this->getSession()->click($arg1); + { + $arg1= $this->find("css",'submit btn btn-primary'); + $this->getSession()->click($arg1); } - /** + + /** * @When I enter text :arg1 + * + * requires the CKEDITOR, which is not there by default */ public function iEnterText($arg1) { @@ -340,10 +263,11 @@ public function iEnterText($arg1) (function(){ CKEDITOR.instances.message.setData( '

This is the editor data.

' ); })(); JS; - //$this->getSession()->executeScript("document.body.innerHTML = '

".$arg1."

'");} - $this->getSession()->evaluateScript($script); + //$this->getSession()->executeScript("document.body.innerHTML = '

".$arg1."

'");} + $this->getSession()->evaluateScript($script); } - /** + + /** * @Then I should read :arg1 */ public function iShouldRead($arg1) @@ -353,24 +277,23 @@ public function iShouldRead($arg1) CKEDITOR.instances.message.getData();})(); JS; - $this->getSession()->evaluateScript($script); + $this->getSession()->evaluateScript($script); } - /** + + /** * @Then :arg1 checkbox should be checked */ - /** + + /** * @Then /^Radio button with id "([^"]*)" should be checked$/ */ - public function RadioButtonWithIdShouldBeChecked($sId) - { - $elementByCss = $this->getSession()->getPage()->find('css', 'input[type="radio"]:checked#'.$sId); - // if (!$elementByCss) { - // throw new Exception('Radio button with id ' . $sId.' is not checked'); - // } - } - - /** + public function RadioButtonWithIdShouldBeChecked($sId) + { + $elementByCss = $this->getSession()->getPage()->find('css', 'input[type="radio"]:checked#'.$sId); + } + + /** * @When I switch back from iframe */ public function iSwitchBackFrom($name=null) @@ -378,7 +301,7 @@ public function iSwitchBackFrom($name=null) $this->getSession()->getDriver()->switchToIframe(null); } - /** + /** * @Then I switch to other iframe :arg1 */ public function iSwitchToOtherIframe($arg1) @@ -399,7 +322,7 @@ public function iMouseOver($arg1) $findName->mouseOver(); } } - /** + /** * @Given I click over :arg1 */ public function iClickOver($arg1) @@ -410,45 +333,45 @@ public function iClickOver($arg1) } /** - * @Given I write :text into :field - */ - public function iWriteTextIntoField($text, $field) - { - $field = $this->getSession() - ->getDriver() - ->getWebDriverSession() - ->element('xpath', '//*[@id="edit_list_categories"]/div/input'); - $field->postValue(['value' => [$text]]); - } + * @Given I write :text into :field + */ + public function iWriteTextIntoField($text, $field) + { + $field = $this->getSession() + ->getDriver() + ->getWebDriverSession() + ->element('xpath', '//*[@id="edit_list_categories"]/div/input'); + $field->postValue(['value' => [$text]]); + } - /** - * @Given I go back - */ + /** + * @Given I go back + */ public function iGoBack() { $this->getSession()->getDriver()->back(); } - /** - * @When I confirm the popup - */ + /** + * @When I confirm the popup + */ public function iConfirmThePopup() { $this->getSession()->getDriver()->getWebDriverSession()->accept_alert(); } - /** - * @Given I go back to :arg1 - */ + /** + * @Given I go back to :arg1 + */ public function iGoBackTo($page) { $this->getSession()->getDriver()->back(); } - /** - * @Then The header color should be black - */ + /** + * @Then The header color should be black + */ public function theDivContextMenuBlockMenuColorShouldBeBlack() { @@ -464,12 +387,13 @@ public function theDivContextMenuBlockMenuColorShouldBeBlack() throw new Exception(); } } - /** - * @Then I should see :message on popups - */ + + /** + * @Then I should see :message on popups + */ public function iShouldSeeOnPopups($message) - { return $message == $this->getSession()->getDriver()->getWebDriverSession()->getAlert_text(); - + { + return $message == $this->getSession()->getDriver()->getWebDriverSession()->getAlert_text(); } } diff --git a/tests/features/bootstrap/ScreenshotContext.php b/tests/features/bootstrap/ScreenshotContext.php index 0af1a0d12..30ac53937 100644 --- a/tests/features/bootstrap/ScreenshotContext.php +++ b/tests/features/bootstrap/ScreenshotContext.php @@ -52,35 +52,6 @@ public function takeAScreenshot() print sprintf("Screenshot is available :\n%s", $url); } - protected function getScreenshotUrl($filename) - { - if (!self::$wsendUser) { - self::$wsendUser = $this->getWsendUser(); - } - - exec(sprintf( - 'curl -F "uid=%s" -F "filehandle=@%s" %s 2>/dev/null', - self::$wsendUser, - $filename, - 'https://wsend.net/upload_cli' - ), $output, $return); - - return $output[0]; - } - - protected function getWsendUser() - { - // create a wsend anonymous user - $curl = curl_init('https://wsend.net/createunreg'); - curl_setopt($curl, CURLOPT_POSTFIELDS, 'start=1'); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - - $wsendUser = curl_exec($curl); - curl_close($curl); - - return $wsendUser; - } - protected function getScreenshotFilename() { $filename = $this->scenarioTitle; diff --git a/tests/features/bootstrap/SubscriberContext.php b/tests/features/bootstrap/SubscriberContext.php index 55668a926..c8bf3a60a 100644 --- a/tests/features/bootstrap/SubscriberContext.php +++ b/tests/features/bootstrap/SubscriberContext.php @@ -136,8 +136,6 @@ public function iHaveList($name, $owner = null, $description=null) } - - /** * @Given /I want to send campaign with title "(.*)"/ */