This repository has been archived by the owner on Jan 22, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Leitner
committed
Dec 11, 2014
1 parent
b61213d
commit 451e362
Showing
5 changed files
with
201 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
phantomjs: | ||
context: | ||
parameters: | ||
user: '' | ||
password: '' | ||
features_path: %behat.paths.features% | ||
paths: | ||
features: tests/integrations | ||
bootstrap: %behat.paths.features%/bootstrap | ||
extensions: | ||
Behat\MinkExtension\Extension: | ||
base_url: 'test.bitpay.com' | ||
goutte: ~ | ||
selenium2: | ||
wd_host: "http://localhost:8643/wd/hub" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<?php | ||
|
||
use Behat\Behat\Context\ClosuredContextInterface, | ||
Behat\Behat\Context\TranslatedContextInterface, | ||
Behat\Behat\Context\BehatContext, | ||
Behat\Behat\Exception\PendingException; | ||
use Behat\Gherkin\Node\PyStringNode, | ||
Behat\Gherkin\Node\TableNode; | ||
|
||
use Behat\MinkExtension\Context\MinkContext; | ||
|
||
require __DIR__ . '/../../../vendor/autoload.php'; | ||
// | ||
// Require 3rd-party libraries here: | ||
// | ||
// require_once 'PHPUnit/Autoload.php'; | ||
// require_once 'PHPUnit/Framework/Assert/Functions.php'; | ||
// | ||
|
||
/** | ||
* Features context. | ||
*/ | ||
class FeatureContext extends MinkContext | ||
{ | ||
private $params = array(); | ||
/** | ||
* Initializes context. | ||
* Every scenario gets it's own context object. | ||
* | ||
* @param array $parameters context parameters (set them up through behat.yml) | ||
*/ | ||
public function __construct(array $parameters) | ||
{ | ||
$this->params = $parameters; | ||
} | ||
/** | ||
* @Then /^I wait for the suggestion box to appear$/ | ||
*/ | ||
public function iWaitForTheSuggestionBoxToAppear() | ||
{ | ||
$this->getSession()->wait(5000, | ||
"$('.suggestions-results').children().length > 0" | ||
); | ||
} | ||
|
||
/** | ||
* @Given /^that there is no token saved locally$/ | ||
*/ | ||
public function thatThereIsNoTokenSavedLocally() | ||
{ | ||
$token_path = $this->params['features_path'].'token.txt'; | ||
if (file_exists($token_path)) | ||
unlink($token_path); | ||
} | ||
|
||
/** | ||
* @Given /^that there is a local keyfile$/ | ||
*/ | ||
public function thatThereIsALocalKeyfile() | ||
{ | ||
$token_path = $this->params['features_path'].'pri.pem'; | ||
} | ||
|
||
/** | ||
* @When /^the user pairs with BitPay with a valid pairing code$/ | ||
*/ | ||
public function theUserPairsWithBitpayWithAValidPairingCode() | ||
{ | ||
throw new PendingException(); | ||
} | ||
|
||
/** | ||
* @Given /^tokens will be saved locally$/ | ||
*/ | ||
public function tokensWillBeSavedLocally() | ||
{ | ||
throw new PendingException(); | ||
} | ||
|
||
/** | ||
* @Given /^that there is no local keyfile$/ | ||
*/ | ||
public function thatThereIsNoLocalKeyfile() | ||
{ | ||
$key_path = $this->params['features_path'].'pri.pem'; | ||
if (file_exists($key_path)) | ||
unlink($key_path); | ||
} | ||
|
||
/** | ||
* @Then /^the keyfile will be saved locally$/ | ||
*/ | ||
public function theKeyfileWillBeSavedLocally() | ||
{ | ||
throw new PendingException(); | ||
} | ||
|
||
/** | ||
* @Given /^the user fails to pair with a semantically invalid code "([^"]*)"$/ | ||
*/ | ||
public function theUserFailsToPairWithASemanticallyInvalidCode($arg1) | ||
{ | ||
throw new PendingException(); | ||
} | ||
|
||
/** | ||
* @Then /^they will receive a BitPay::ArgumentError matching "([^"]*)"$/ | ||
*/ | ||
public function theyWillReceiveABitpayArgumenterrorMatching($arg1) | ||
{ | ||
throw new PendingException(); | ||
} | ||
|
||
/** | ||
* @When /^the fails to pair with BitPay because of an incorrect port$/ | ||
*/ | ||
public function theFailsToPairWithBitpayBecauseOfAnIncorrectPort() | ||
{ | ||
throw new PendingException(); | ||
} | ||
|
||
/** | ||
* @Then /^they will receive a BitPay::ConnectionError matching "([^"]*)"$/ | ||
*/ | ||
public function theyWillReceiveABitpayConnectionerrorMatching($arg1) | ||
{ | ||
throw new PendingException(); | ||
} | ||
|
||
/** | ||
* @Given /^the user fails to pair with a semantically valid code "([^"]*)"$/ | ||
*/ | ||
public function theUserFailsToPairWithASemanticallyValidCode($arg1) | ||
{ | ||
throw new PendingException(); | ||
} | ||
|
||
/** | ||
* @Then /^they will receive a BitPay::BitPayError matching "([^"]*)"$/ | ||
*/ | ||
public function theyWillReceiveABitpayBitpayerrorMatching($arg1) | ||
{ | ||
throw new PendingException(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# pairing.feature | ||
Feature: pairing with bitpay | ||
In order to access bitpay | ||
It is required that the library | ||
Is able to pair successfully | ||
|
||
Background: | ||
Given that there is no token saved locally | ||
|
||
Scenario: there is a local keyfile | ||
Given that there is a local keyfile | ||
When the user pairs with BitPay with a valid pairing code | ||
And tokens will be saved locally | ||
|
||
Scenario: there is no local keyfile | ||
Given that there is no local keyfile | ||
When the user pairs with BitPay with a valid pairing code | ||
Then the keyfile will be saved locally | ||
And tokens will be saved locally | ||
|
||
Scenario: the client has a bad pairing code | ||
Given the user fails to pair with a semantically valid code "a1b2c3d" | ||
Then they will receive a BitPay::BitPayError matching "500: Unable to create token" | ||
|
||
Scenario: the client has an incorrect pairing code | ||
Given the user fails to pair with a semantically invalid code "a2b2c3d4" | ||
Then they will receive a BitPay::ArgumentError matching "pairing code is not legal" | ||
|
||
Scenario: the client has a bad port configuration to a closed port | ||
Given that there is a local keyfile | ||
When the fails to pair with BitPay because of an incorrect port | ||
Then they will receive a BitPay::ConnectionError matching "Connection refused" |