1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of `Composer as a service`. |
5
|
|
|
* |
6
|
|
|
* (c) Pascal Borreli <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ayaline\Bundle\ComposerBundle\Features; |
13
|
|
|
|
14
|
|
|
use Behat\Behat\Context\Step\When; |
15
|
|
|
use Behat\Mink\Element\NodeElement; |
16
|
|
|
use Behat\Mink\Exception\ExpectationException; |
17
|
|
|
use Behat\MinkExtension\Context\MinkContext; |
18
|
|
|
use Behat\Symfony2Extension\Context\KernelAwareInterface; |
19
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
20
|
|
|
|
21
|
|
|
class FeatureContext extends MinkContext implements KernelAwareInterface |
22
|
|
|
{ |
23
|
|
|
private $kernel; |
24
|
|
|
private $parameters; |
25
|
|
|
|
26
|
|
|
public function __construct(array $parameters) |
27
|
|
|
{ |
28
|
|
|
$this->parameters = $parameters; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Sets HttpKernel instance. |
33
|
|
|
* This method will be automatically called by Symfony2Extension ContextInitializer. |
34
|
|
|
* |
35
|
|
|
* @param KernelInterface $kernel |
36
|
|
|
*/ |
37
|
|
|
public function setKernel(KernelInterface $kernel) |
38
|
|
|
{ |
39
|
|
|
$this->kernel = $kernel; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @When /^I press "([^"]*)" after it is ready$/ |
44
|
|
|
*/ |
45
|
|
|
public function iPressAfterItIsReady($buttonLabel) |
46
|
|
|
{ |
47
|
|
|
$this->getSession()->wait(7000, '!$("button").hasClass("disabled")'); |
48
|
|
|
|
49
|
|
|
return new When("I press \"$buttonLabel\""); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @When /^I wait until the download button shows up$/ |
54
|
|
|
*/ |
55
|
|
|
public function waitUntilTheDownloadButtonShowsUp() |
56
|
|
|
{ |
57
|
|
|
$this->getSession()->wait(25000, '$("#download-link").is(":visible")'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @Given /^I should see "([^"]*)" link$/ |
62
|
|
|
*/ |
63
|
|
|
public function iShouldSeeLink($buttonLabel) |
|
|
|
|
64
|
|
|
{ |
65
|
|
|
/** @var NodeElement $linkNode */ |
66
|
|
|
$linkNode = $this->getSession()->getPage()->findLink('download-link'); |
67
|
|
|
|
68
|
|
|
$hrefValue = $linkNode->getAttribute('href'); |
69
|
|
|
if (empty($hrefValue)) { |
70
|
|
|
$message = 'Download link was not generated successfully.'; |
71
|
|
|
throw new ExpectationException($message, $this->getSession()); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.