1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* YAWIK |
4
|
|
|
* |
5
|
|
|
* @filesource |
6
|
|
|
* @license MIT |
7
|
|
|
* @copyright 2013 - 2017 Cross Solution <http://cross-solution.de> |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Yawik\Behat; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
use Behat\Behat\Context\Context; |
14
|
|
|
use Doctrine\Common\Util\Inflector; |
15
|
|
|
|
16
|
|
|
class SummaryFormContext implements Context |
17
|
|
|
{ |
18
|
|
|
use CommonContextTrait; |
19
|
|
|
|
20
|
|
|
private $elementMap = array( |
21
|
|
|
'name' => '#sf-nameForm', |
22
|
|
|
'location' => '#sf-locationForm', |
23
|
|
|
'employees' => '#sf-employeesManagement', |
24
|
|
|
'workflow' => '#sf-workflowSettings', |
25
|
|
|
'jobTitleAndLocation' => '#general-locationForm', |
26
|
|
|
'jobClassification' => '#sf-general-classifications', |
27
|
|
|
'customerNote' => '#sf-general-customerNote', |
28
|
|
|
'personalInformations' => '#sf-contact-contact', |
29
|
|
|
'resumePersonalInformations' => '#sf-contact', |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @When I click edit on :name form |
34
|
|
|
* @TODO: [ZF3] move this method to CoreContext |
35
|
|
|
*/ |
36
|
|
|
public function iClickEditOnForm($name) |
37
|
|
|
{ |
38
|
|
|
$this->iClickForm($name); |
39
|
|
|
$name = Inflector::camelize($name); |
40
|
|
|
$type = $this->elementMap[$name]; |
41
|
|
|
$locator = $type.' .sf-summary .sf-controls button'; |
42
|
|
|
$element = $this->minkContext->getSession()->getPage()->find('css',$locator); |
43
|
|
|
if(!$element){ |
44
|
|
|
throw new \Exception('No element found with this locator: "'.$locator.'"'); |
45
|
|
|
} |
46
|
|
|
$element->click(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @When I click :form form |
51
|
|
|
*/ |
52
|
|
|
public function iClickForm($name) |
53
|
|
|
{ |
54
|
|
|
$name = Inflector::camelize($name); |
55
|
|
|
$type = $this->elementMap[$name]; |
56
|
|
|
$locator = $type.' .sf-summary'; |
57
|
|
|
$session = $this->minkContext->getSession(); |
58
|
|
|
$script = <<<EOC |
59
|
|
|
var tElement = jQuery("$locator .sf-controls"); |
60
|
|
|
tElement.css('display','block'); |
61
|
|
|
tElement.css('visibility','visible'); |
62
|
|
|
EOC; |
63
|
|
|
$session->executeScript($script); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @When I save :type form |
68
|
|
|
*/ |
69
|
|
|
public function iSaveForm($type) |
70
|
|
|
{ |
71
|
|
|
$type = Inflector::camelize($type); |
72
|
|
|
$method = 'iSave'.$type; |
73
|
|
|
if(method_exists($this,$method)){ |
74
|
|
|
call_user_func([$this,$method]); |
75
|
|
|
}else{ |
76
|
|
|
$locator = $this->elementMap[$type].'-buttons-submit'; |
77
|
|
|
$this->coreContext->scrollIntoView($locator); |
78
|
|
|
$element = $this->minkContext->getSession()->getPage()->find('css',$locator); |
79
|
|
|
$element->click(); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function iSaveJobClassification() |
84
|
|
|
{ |
85
|
|
|
$locator = '#general-classifications-buttons-submit'; |
86
|
|
|
$this->coreContext->scrollIntoView($locator); |
87
|
|
|
$element = $this->minkContext->getSession()->getPage()->find('css',$locator); |
88
|
|
|
$element->click(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
} |