Skip to content

Commit

Permalink
Merge pull request #7 from adambullmer/testing
Browse files Browse the repository at this point in the history
Adding behat tests
  • Loading branch information
adambullmer committed May 1, 2016
2 parents 1600582 + fd7a697 commit e5df57f
Show file tree
Hide file tree
Showing 6 changed files with 660 additions and 3 deletions.
6 changes: 6 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
default:
formatter:
name: pretty
paths:
features: test/features
bootstrap: %behat.paths.features%/bootstrap
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dependencies:
test:
override:
- ./vendor/bin/phpunit --coverage-text
- ./vendor/bin/behat
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"php": ">=5.3.0"
},
"require-dev": {
"behat/behat": "~2.5",
"phpunit/phpunit": "5.3.*"
}
}
5 changes: 2 additions & 3 deletions regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
]
},
"IA": {
"rule": "^[0-9]{9}|([0-9]{3}[A-Z]{2}[0-9]{4})$",
"rule": "^([0-9]{9}|([0-9]{3}[A-Z]{2}[0-9]{4}))$",
"description": [
"9 Numeric",
"3 Numeric + 2 Alpha + 4 Numeric"
Expand Down Expand Up @@ -325,8 +325,7 @@
"WA": {
"rule": "^(?=.{12}$)[A-Z]{1,7}[A-Z0-9\\*]{4,11}$",
"description": [
"1-7 Alpha + any combination of Alpha, Numeric,",
"* for a total of 12 characters"
"1-7 Alpha + any combination of Alpha, Numeric, and * for a total of 12 characters"
]
},
"WV": {
Expand Down
53 changes: 53 additions & 0 deletions test/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

//
// Require 3rd-party libraries here:
//
// require_once 'PHPUnit/Autoload.php';
// require_once 'PHPUnit/Framework/Assert/Functions.php';
//

/**
* Features context.
*/
class FeatureContext extends \Behat\Behat\Context\BehatContext {
private $state = NULL;

private $driversLicense = NULL;

private $results = NULL;

/**
* @Given /^I have the state (.*)$/
*/
public function iHaveAState($state) {
$this->state = $state;
}

/**
* @Given /^I have a drivers license (.*)$/
*/
public function iHaveADriversLicense($license) {
$this->driversLicense = $license;
}

/**
* @When /^I validate the license$/
*/
public function iValidateTheLicense() {
$validator = new \USDLRegex\Validator();
$this->results = $validator->validate($this->state, $this->driversLicense);
}

/**
* @Then /^the result is (.*)$/
*/
public function theResultIs($expected) {
$expectedBool = ($expected === 'TRUE') ? TRUE : FALSE;

if ($expectedBool !== $this->results) {
throw new \Exception('The results were not ' . $expected);
}
}
}

Loading

0 comments on commit e5df57f

Please sign in to comment.