Skip to content

Commit

Permalink
Auhtor-names(#81): step definitions for the acceptance tests for giga…
Browse files Browse the repository at this point in the history
…science story

implemented the step definitions for the scenario to implement the story for issue #81 from gigascience perspective.

Made used of Behat tables to and real author names from the database.

That means taht before each run of the suite, the sample of production database needs to be loaded. The database dump is called "author-names-80-81-82.pgdmp" and it differs only from the  2016 dump by having an Attribute record for "urlredirect".
  • Loading branch information
Rija Menage committed Jan 31, 2018
1 parent 138d72b commit 5b76328
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/features/author-names.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ Feature: Standardizing the display of names of a paper's authors


Scenario Outline:
Given author has surname <surname>
And author has first name <first_name>
And author has middle name <middle_name>
When I am on <dataset>
Then the author's name should be displayed as <display_name>
Given author has surname "<surname>"
And author has first name "<first_name>"
And author has middle name "<middle_name>"
When I am on "<dataset>"
Then I should see "<display_name>"

Examples:
| surname| first_name | middle_name | dataset | display_name |
| Teo | Audrey | SM | /dataset/100182 | Teo ASM |
| Gilbert | M.Thomas | P | /dataset/101031 | Gilbert MTP |
| Muñoz | Ángel | GG | /dataset/100243 | Muñoz ÁGG |
Expand Down
53 changes: 53 additions & 0 deletions tests/features/bootstrap/AuthorWorkflowContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
*/
class AuthorWorkflowContext extends Behat\MinkExtension\Context\MinkContext implements Behat\YiiExtension\Context\YiiAwareContextInterface
{
private $surname = null;
private $first_name = null;
private $middle_name = null;

/**
* Initializes context.
Expand Down Expand Up @@ -53,7 +56,57 @@ public function getYii()
// doSomethingWith($argument);
// }
//

/**
* @Given /^author has surname "([^"]*)"$/
*/
public function authorHasSurname($arg1)
{
$this->surname = $arg1 ;
}

/**
* @Given /^author has first name "([^"]*)"$/
*/
public function authorHasFirstName($arg1)
{
$this->first_name = $arg1 ;
}

/**
* @Given /^author has middle name "([^"]*)"$/
*/
public function authorHasMiddleName($arg1)
{
$this->middle_name = $arg1 ;
}



/**
* @BeforeScenario
*/
public function reset()
{
$this->surname = null;
$this->first_name = null;
$this->middle_name = null;
}



/**
* @BeforeSuite
*/
public static function initialize_databaes()
{
print_r("Initializing the database... ");
exec("vagrant ssh -c \"sudo -Hiu postgres /usr/bin/psql < /vagrant/sql/kill_drop_recreate.sql\"",$kill_output);
// var_dump($kill_output);
exec("vagrant ssh -c \"pg_restore -i -h localhost -p 5432 -U gigadb -d gigadb -v /vagrant/sql/author-names-80-81-82.pgdmp
\"",$output);
// var_dump($output);
}


}

0 comments on commit 5b76328

Please sign in to comment.