Skip to content

Commit 5c2e90c

Browse files
authored
Merge pull request #36 from pilot/task-33
Store call for paper request in the admin panel, #33
2 parents 0976fc9 + 8f0dbb2 commit 5c2e90c

31 files changed

+1391
-23
lines changed

app/AppKernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public function registerBundles()
1717
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
1818
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
1919
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
20+
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
2021

2122
new Event\EventBundle\EventEventBundle(),
2223
);

app/config/routing.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ _event:
44
# to the available site it's easy to point event to the specified url like
55
# prefix: /event
66
prefix: /
7+
8+
fos_js_routing:
9+
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"doctrine/dbal": "^2.5",
2626
"doctrine/common": "^2.6",
2727
"doctrine/orm": "^2.5",
28-
"doctrine/doctrine-bundle": "^1.6"
28+
"doctrine/doctrine-bundle": "^1.6",
29+
"friendsofsymfony/jsrouting-bundle": "^1.6"
2930
},
3031
"require-dev": {
3132
"behat/behat": "2.5.*",

composer.lock

Lines changed: 113 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/Context/BackendContext.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ public function iWaitForAForm()
7474
$this->getSession()->wait(10000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))');
7575
}
7676

77+
/**
78+
* @Then /^I wait "([^"]*)" seconds$/
79+
*/
80+
public function iWaitSeconds($seconds)
81+
{
82+
$this->getSession()->wait(($seconds * 1000));
83+
}
84+
7785
/**
7886
* @When /^I should see the row containing "([^"]*)"$/
7987
*/
@@ -180,6 +188,71 @@ public function iDeleteRecordOf($index)
180188
}
181189
}
182190

191+
/**
192+
* @Given /^I approve the call with id "([^"]*)"$/
193+
*/
194+
public function iApproveCallOf($index)
195+
{
196+
/**
197+
* @var $nodes \Behat\Mink\Element\NodeElement
198+
* @var $node \Behat\Mink\Element\NodeElement
199+
*/
200+
$nodes = $this->getSession()->getPage()->findAll('css', sprintf('table tr > td:first-child:contains("%s")', $index));
201+
if (!$nodes) {
202+
throw new \Exception(sprintf('Cannot find any row with id "%s"', $index));
203+
}
204+
205+
$findedNode = false;
206+
foreach ($nodes as $node) {
207+
$parent = $node->getParent();
208+
$rowId = explode(' ', $parent->getText())[0];
209+
210+
if ($rowId == $index) {
211+
$findedNode = $parent;
212+
213+
break;
214+
}
215+
}
216+
217+
if (!$findedNode) {
218+
throw new \Exception(sprintf('Cannot find any row with id "%s"', $index));
219+
}
220+
221+
$linksSelectors = $findedNode->findAll('css', 'ul.dropdown-menu li a');
222+
foreach ($linksSelectors as $link) {
223+
if (strpos($link->getHtml(), 'Approve')) {
224+
$this->getSession()->visit($link->getAttribute('href'));
225+
}
226+
}
227+
}
228+
229+
/**
230+
* Click on the element with the provided CSS Selector
231+
*
232+
* @When /^I click on the element with css selector "([^"]*)"$/
233+
*/
234+
public function iClickOnTheElementWithCSSSelector($cssSelector)
235+
{
236+
$session = $this->getSession();
237+
$element = $session->getPage()->find(
238+
'xpath',
239+
$session->getSelectorsHandler()->selectorToXpath('css', $cssSelector) // just changed xpath to css
240+
);
241+
if (null === $element) {
242+
throw new \InvalidArgumentException(sprintf('Could not evaluate CSS Selector: "%s"', $cssSelector));
243+
}
244+
245+
$element->click();
246+
}
247+
248+
/**
249+
* @When /^I click to confirm action$/
250+
*/
251+
public function iClickToConfirmAction()
252+
{
253+
$this->getSession()->getDriver()->click("(//a[@id='modal-confirm-action'])");
254+
}
255+
183256
/**
184257
* @When /^I click "([^"]*)" on the row containing "([^"]*)"$/
185258
*/

0 commit comments

Comments
 (0)