Parametrización de los parámetros de conexión a la base de datos declarados en behat.yml y enviados mediante los features.

This commit is contained in:
veronicaaruquipa
2014-12-08 09:51:20 -04:00
parent d502648664
commit c35d4024f3
2 changed files with 139 additions and 11 deletions

View File

@@ -10,7 +10,7 @@ Feature: DataBase Connections Main Tests Mysql
# GET /api/1.0/{workspace}/project/<project-id>/database-connections
# Get list DataBase Connections
# Get list DataBase| dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description | Connections
Scenario Outline: Get the DataBase Connections List when there are exactly zero DataBase Connections
Given I request "project/<project>/database-connections"
Then the response status code should be 200
@@ -18,10 +18,9 @@ Feature: DataBase Connections Main Tests Mysql
And the response has <record> record
Examples:
| project | record |
| 74737540052e1641ab88249082085472 | 1 |
| 87648819953a85c0abc01d3080475981 | 1 |
| 106912358530c9b14ac15d3001790900 | 0 |
| 1265557095225ff5c688f46031700471 | 0 |
# POST /api/1.0/{workspace}/project/<project-id>/database-connection/test
@@ -41,12 +40,141 @@ Feature: DataBase Connections Main Tests Mysql
}
"""
And I request "project/<project>/database-connection/test"
Then database-connection with id "<dbs_uid_number>" is active
Then if database-connection with id "<dbs_uid_number>" is active
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
Examples:
| dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
| 46110938554821d2ddb8d01076533986 | 74737540052e1641ab88249082085472 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
| 40639901154821d2e3bb7e8061116901 | 87648819953a85c0abc01d3080475981 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
| 1 | 106912358530c9b14ac15d3001790900 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
| 2 | 1265557095225ff5c688f46031700471 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
# POST /api/1.0/{workspace}/project/<project-id>/database-connection
# Create new DataBase Connection
Scenario Outline: Create a new database connection
Given database-connection with id "<dbs_uid_number>" is active
And POST this data:
"""
{
"dbs_type": "<dbs_type>",
"dbs_server": "<dbs_server>",
"dbs_database_name": "<dbs_database_name>",
"dbs_username": "<dbs_username>",
"dbs_password": "<dbs_password>",
"dbs_port": <dbs_port>,
"dbs_encode": "<dbs_encode>",
"dbs_description": "<dbs_description>"
}
"""
And I request "project/<project>/database-connection"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
And store "dbs_uid" in session array as variable "dbs_uid_<dbs_uid_number>"
Examples:
| dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
| 1 | 106912358530c9b14ac15d3001790900 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
| 2 | 1265557095225ff5c688f46031700471 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
# GET /api/1.0/{workspace}/project/<project-id>/database-connection
# Get DataBase Connections list of each process
Scenario Outline: Get the DataBase Connections List when there are exactly one DataBase Connections in each process
Given database-connection with id "<dbs_uid_number>" is active
And I request "project/<project>/database-connections"
Then the response status code should be 200
And the response charset is "UTF-8"
And the response has <record> record
Examples:
| project | record | dbs_uid_number |
| 106912358530c9b14ac15d3001790900 | 1 | 1 |
| 1265557095225ff5c688f46031700471 | 1 | 2 |
# PUT /api/1.0/{workspace}/project/<project-id>/database-connection
# Update a DataBase Connection
Scenario Outline: Update a database connection
Given database-connection with id "<dbs_uid_number>" is active
And PUT this data:
"""
{
"dbs_type": "<dbs_type>",
"dbs_server": "<dbs_server>",
"dbs_database_name": "<dbs_database_name>",
"dbs_username": "<dbs_username>",
"dbs_password": "<dbs_password>",
"dbs_port": <dbs_port>,
"dbs_encode": "<dbs_encode>",
"dbs_description": "<dbs_description>"
}
"""
And that I want to update a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
And I request "project/<project>/database-connection"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
Examples:
| dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
| 1 | 106912358530c9b14ac15d3001790900 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
| 2 | 1265557095225ff5c688f46031700471 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
# GET /api/1.0/{workspace}/project/<project-id>/database-connection
# Get a single DataBase Connection and their properties
Scenario Outline: Get a single database connection and check some properties
Given database-connection with id "<dbs_uid_number>" is active
And that I want to get a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
And I request "project/<project>/database-connection"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
And that "dbs_type" is set to "<dbs_type>"
And that "dbs_server" is set to "<dbs_server>"
And that "dbs_database_name" is set to "<dbs_database_name>"
And that "dbs_username" is set to "<dbs_username>"
And that "dbs_password" is set to "<dbs_password>"
And that "dbs_port" is set to "<dbs_port>"
And that "dbs_encode" is set to "<dbs_encode>"
And that "dbs_description" is set to "<dbs_description>"
Examples:
| dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
| 1 | 106912358530c9b14ac15d3001790900 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
| 2 | 1265557095225ff5c688f46031700471 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
# DELETE /api/1.0/{workspace}/project/<project-id>/database-connection
# Delete all DataBase Connections created in this script
Scenario Outline: Delete all Database Connection created in this script
Given database-connection with id "<dbs_uid_number>" is active
And that I want to delete a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
And I request "project/<project>/database-connection"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
Examples:
| project | dbs_uid_number |
| 106912358530c9b14ac15d3001790900 | 1 |
| 1265557095225ff5c688f46031700471 | 2 |
# GET /api/1.0/{workspace}/project/<project-id>/database-connection
# Get DataBase Connections list
Scenario Outline: Get the DataBase Connections List when there are exactly zero DataBase Connections
Given database-connection with id "<dbs_uid_number>" is active
And I request "project/<project>/database-connections"
Then the response status code should be 200
And the response charset is "UTF-8"
And the response has <record> record
Examples:
| project | record | dbs_uid_number |
| 106912358530c9b14ac15d3001790900 | 0 | 1 |
| 1265557095225ff5c688f46031700471 | 0 | 2 |

View File

@@ -1847,11 +1847,11 @@ class RestContext extends BehatContext
*/
public function databaseConnectionWithIdIsActive($dbConnectionId)
{
/* if (file_exists("session.data")) {
if (file_exists("session.data")) {
$sessionData = json_decode(file_get_contents("session.data"));
} else {
$sessionData = new StdClass();
}*/
}
$sessionData = new StdClass();
if(!$sessionData->dbconnectionStatus->$dbConnectionId){