Skip to content

Commit 0654cd8

Browse files
author
Codeliner
committed
Merge branch 'development'
2 parents 93def45 + 20661a8 commit 0654cd8

File tree

4 files changed

+86
-2
lines changed

4 files changed

+86
-2
lines changed

features/book_new_cargo.feature

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Feature: Book new Cargo
2+
In order to manage a transport of a Cargo
3+
As a booking manager
4+
I need to be able to book the Cargo on a Voyage with enough free capacity
5+
6+
@javascript
7+
Scenario: Add a Cargo
8+
Given I am on "application/cargo/add"
9+
When I fill in "size" with "40"
10+
And I click the submit button
11+
Then the url should match "application/cargo/index"
12+
13+
@javascript
14+
Scenario: Add a Voyage with low capacity
15+
Given I am on "application/voyage/add"
16+
When I fill in "voyage_number" with "LOW123"
17+
And I fill in "name" with "Low Voyage"
18+
And I fill in "capacity" with "30"
19+
And I click the submit button
20+
Then the url should match "application/voyage/index"
21+
22+
@javascript
23+
Scenario: Add a Voyage with high capacity
24+
Given I am on "application/voyage/add"
25+
When I fill in "voyage_number" with "HIGH123"
26+
And I fill in "name" with "High Voyage"
27+
And I fill in "capacity" with "100"
28+
And I click the submit button
29+
Then the url should match "application/voyage/index"
30+
31+
@javascript
32+
Scenario: Try to book Cargo on Voyage with not enough capacity
33+
Given I am on "application/cargo/index"
34+
When I click on first item in the list "cargo-list"
35+
And I wait until I am on page "application/cargo/show"
36+
And I select "LOW123" from "voyage_number"
37+
And I click the submit button
38+
Then the url should match "application/booking/booking"
39+
And the response should contain "Voyage [LOW123] has not enough capacity"
40+
41+
@javascript
42+
Scenario: Book Cargo on Voyage with enough capacity
43+
Given I am on "application/cargo/index"
44+
When I click on first item in the list "cargo-list"
45+
And I wait until I am on page "application/cargo/show"
46+
And I select "HIGH123" from "voyage_number"
47+
And I click the submit button
48+
Then the url should match "application/booking/booking"
49+
And the response should contain "Cargo was successfully booked"

features/bootstrap/FeatureContext.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,40 @@ public function iClickTheSubmitButton()
7878
throw new \RuntimeException("Can not find the submit btn");
7979
}
8080
}
81+
82+
/**
83+
* @When /^I click on first item in the list "([^"]*)"$/
84+
*/
85+
public function iClickOnFirstItemInTheList($arg1)
86+
{
87+
$session = $this->getSession();
88+
$page = $session->getPage();
89+
90+
$ul = $page->find('css', '#cargo-list');
91+
92+
$li = $ul->find('css', 'li');
93+
94+
$li->find('css', 'a')->click();
95+
}
96+
97+
/**
98+
* @Given /^I wait until I am on page "(?P<page>[^"]+)"$/
99+
*/
100+
public function iWaitUntilIAmOnPage($page)
101+
{
102+
$matchingFound = false;
103+
104+
for($i=1;$i++;$i<=5) {
105+
if (strpos($this->getSession()->getCurrentUrl(), $this->locatePath($page)) !== false) {
106+
$matchingFound = true;
107+
break;
108+
}
109+
sleep(1);
110+
}
111+
112+
if (!$matchingFound) {
113+
throw new \Exception('Stoped waiting, timelimit reached!');
114+
}
115+
}
81116

82117
}

module/Application/src/Application/Service/BookingService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function bookNewCargo(Cargo\Cargo $cargo, Voyage\Voyage $voyage)
4141
if (!$this->overbookingPolicy->isAllowed($cargo, $voyage)) {
4242
throw new Exception\RuntimeException(
4343
sprintf(
44-
'Cargo <%s> can not be booked. Voyage <%s> has not enough capacity.',
44+
'Cargo [%s] can not be booked. Voyage [%s] has not enough capacity.',
4545
$cargo->getTrackingId()->toString(),
4646
$voyage->getVoyageNumber()->toString()
4747
)

module/Application/view/application/cargo/index.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<?php if (empty($this->cargos)): ?>
1717
<p class="alert-danger"><?php echo $this->translate('The list is empty. You have to add a cargo first!'); ?></p>
1818
<?php else: ?>
19-
<ul>
19+
<ul id="cargo-list">
2020
<?php foreach ($this->cargos as $cargo): ?>
2121
<li><a href="<?php echo $this->url('application/default/trackingid', array('controller' => 'cargo', 'action' => 'show', 'trackingid' => $cargo->getTrackingId()->toString())) ?>"><?php echo $cargo->getTrackingId() ?></a></li>
2222
<?php endforeach; ?>

0 commit comments

Comments
 (0)