add functionnal testing

remotes/origin/master
Jerome De Almeida 2016-05-17 16:05:44 +02:00
parent c69e73b2e7
commit 387f4fce70
4 changed files with 159 additions and 1 deletions

9
behat.yml Executable file
View File

@ -0,0 +1,9 @@
default:
extensions:
Behat\MinkExtension:
base_url: http://127.0.0.1:8080
goutte: ~
suites:
features:
paths: [ %paths.base%/features ]
contexts: [ AmvContext ]

View File

@ -11,7 +11,14 @@
"php": ">=5.5", "php": ">=5.5",
"zendframework/zendframework": "2.5.3", "zendframework/zendframework": "2.5.3",
"doctrine/doctrine-orm-module": "^0.10", "doctrine/doctrine-orm-module": "^0.10",
"doctrine/migrations": "^1.4" "doctrine/migrations": "^1.4",
"behat/behat": "~3.0",
"behat/mink": "^1.6",
"behat/mink-extension": "^2.0",
"behat/mink-goutte-driver": "^1.1"
},
"config": {
"bin-dir": "bin/"
}, },
"repositories":[ "repositories":[
{ {

65
features/amv.feature Executable file
View File

@ -0,0 +1,65 @@
@amvService
Feature: Amvs services
Test complies for amv service
Scenario Outline: Test complies requirements
Given That I want to call the amv service
And I should test complies with Amode <a_mode> and Tmode <t_mode> and Vmode <v_mode> and Amodel <a_model> and Tmodel <t_model> and Vmodel <v_model> and IsRegulator <is_regulator> and the Result is <result>
Examples:
| a_mode | t_mode | v_mode | a_model | t_model | v_model | is_regulator | result |
| 0 | 0 | 0 | 1 | 1 | 1 | 0 | true |
| 0 | 0 | 0 | 1 | 1 | 1 | 1 | true |
| 0 | 0 | 0 | 1 | 1 | 2 | 0 | true |
| 0 | 0 | 0 | 1 | 1 | 2 | 1 | true |
| 0 | 0 | 0 | 1 | 2 | 3 | 0 | true |
| 0 | 0 | 0 | 1 | 2 | 3 | 1 | true |
| 0 | 0 | 1 | 1 | 1 | 1 | 0 | false |
| 0 | 0 | 1 | 1 | 1 | 1 | 1 | false |
| 0 | 0 | 1 | 1 | 1 | 2 | 0 | false |
| 0 | 0 | 1 | 1 | 1 | 2 | 1 | false |
| 0 | 0 | 1 | 1 | 2 | 3 | 0 | false |
| 0 | 0 | 1 | 1 | 2 | 3 | 1 | false |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 | false |
| 0 | 1 | 0 | 1 | 1 | 1 | 1 | false |
| 0 | 1 | 0 | 1 | 1 | 2 | 0 | false |
| 0 | 1 | 0 | 1 | 1 | 2 | 1 | false |
| 0 | 1 | 0 | 1 | 2 | 3 | 0 | false |
| 0 | 1 | 0 | 1 | 2 | 3 | 1 | false |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 | true |
| 1 | 0 | 0 | 1 | 1 | 1 | 1 | false |
| 1 | 0 | 0 | 1 | 1 | 2 | 0 | true |
| 1 | 0 | 0 | 1 | 1 | 2 | 1 | false |
| 1 | 0 | 0 | 1 | 2 | 3 | 0 | true |
| 1 | 0 | 0 | 1 | 2 | 3 | 1 | false |
| 1 | 1 | 0 | 1 | 1 | 1 | 0 | true |
| 1 | 1 | 0 | 1 | 1 | 1 | 1 | false |
| 1 | 1 | 0 | 1 | 1 | 2 | 0 | true |
| 1 | 1 | 0 | 1 | 1 | 2 | 1 | false |
| 1 | 1 | 0 | 1 | 2 | 3 | 0 | true |
| 1 | 1 | 0 | 1 | 2 | 3 | 1 | false |
| 1 | 0 | 1 | 1 | 1 | 1 | 0 | true |
| 1 | 0 | 1 | 1 | 1 | 1 | 1 | false |
| 1 | 0 | 1 | 1 | 1 | 2 | 0 | true |
| 1 | 0 | 1 | 1 | 1 | 2 | 1 | false |
| 1 | 0 | 1 | 1 | 2 | 3 | 0 | true |
| 1 | 0 | 1 | 1 | 2 | 3 | 1 | false |
| 0 | 1 | 1 | 1 | 1 | 1 | 0 | false |
| 0 | 1 | 1 | 1 | 1 | 1 | 1 | false |
| 0 | 1 | 1 | 1 | 1 | 2 | 0 | false |
| 0 | 1 | 1 | 1 | 1 | 2 | 1 | false |
| 0 | 1 | 1 | 1 | 2 | 3 | 0 | false |
| 0 | 1 | 1 | 1 | 2 | 3 | 1 | false |
| 1 | 1 | 1 | 1 | 1 | 1 | 0 | true |
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | true |
| 1 | 1 | 1 | 1 | 1 | 2 | 0 | false |
| 1 | 1 | 1 | 1 | 1 | 2 | 1 | false |
| 1 | 1 | 1 | 1 | 2 | 3 | 0 | false |
| 1 | 1 | 1 | 1 | 2 | 3 | 1 | false |

View File

@ -0,0 +1,77 @@
<?php
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
/**
* Features context.
*/
class AmvContext extends \Behat\MinkExtension\Context\MinkContext implements \Behat\Behat\Context\SnippetAcceptingContext
{
protected $service;
/**
* @var Zend\Mvc\Application
*/
protected static $zendApp;
/**
* @BeforeSuite
*/
public static function initializeZendFramework() {
if(self::$zendApp === null) {
$path = __DIR__ . '/../../config/application.config.php';
self::$zendApp = Zend\Mvc\Application::init(require $path);
}
}
/**
* Initializes context.
*
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct()
{
}
/**
* @Given /^That I want to call the amv service$/
*/
public function thatIWantToCallTheAmvService()
{
$this->service = new \MonarcCore\Service\AmvService();
}
/**
* @Given I should test complies with Amode :arg1 and Tmode :arg2 and Vmode :arg3 and Amodel :arg4 and Tmodel :arg5 and Vmodel :arg6 and IsRegulator :arg7 and the Result is true
*/
public function iShouldTestCompliesWithAmodeAndTmodeAndVmodeAndAmodelAndTmodelAndVmodelAndIsregulatorAndTheResultIsTrue($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7)
{
$service = $this->service;
$result = $service->compliesControl($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
PHPUnit_Framework_Assert::assertTrue($result);
}
/**
* @Given I should test complies with Amode :arg1 and Tmode :arg2 and Vmode :arg3 and Amodel :arg4 and Tmodel :arg5 and Vmodel :arg6 and IsRegulator :arg7 and the Result is false
*/
public function iShouldTestCompliesWithAmodeAndTmodeAndVmodeAndAmodelAndTmodelAndVmodelAndIsregulatorAndTheResultIsFalse($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7)
{
$service = $this->service;
$result = $service->compliesControl($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
PHPUnit_Framework_Assert::assertFalse($result);
}
}