@@ -51,6 +51,9 @@ discard block |
||
| 51 | 51 | $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | + /** |
|
| 55 | + * @param string $name |
|
| 56 | + */ |
|
| 54 | 57 | public function buildUrl($name, array $params=array(), array $options=array()) |
| 55 | 58 | { |
| 56 | 59 | $defaults = ['lang'=>'en']; |
@@ -71,7 +74,7 @@ discard block |
||
| 71 | 74 | } |
| 72 | 75 | |
| 73 | 76 | /** |
| 74 | - * @param $id |
|
| 77 | + * @param string $id |
|
| 75 | 78 | * @return mixed|object |
| 76 | 79 | */ |
| 77 | 80 | public function getService($id) |
@@ -80,7 +83,7 @@ discard block |
||
| 80 | 83 | } |
| 81 | 84 | |
| 82 | 85 | /** |
| 83 | - * @param $id |
|
| 86 | + * @param string $id |
|
| 84 | 87 | * |
| 85 | 88 | * @return RepositoryInterface |
| 86 | 89 | */ |
@@ -18,43 +18,43 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | trait CommonContextTrait |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @var MinkContext |
|
| 23 | - */ |
|
| 24 | - protected $minkContext; |
|
| 21 | + /** |
|
| 22 | + * @var MinkContext |
|
| 23 | + */ |
|
| 24 | + protected $minkContext; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var CoreContext |
|
| 28 | - */ |
|
| 29 | - protected $coreContext; |
|
| 26 | + /** |
|
| 27 | + * @var CoreContext |
|
| 28 | + */ |
|
| 29 | + protected $coreContext; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var UserContext |
|
| 33 | - */ |
|
| 34 | - protected $userContext; |
|
| 31 | + /** |
|
| 32 | + * @var UserContext |
|
| 33 | + */ |
|
| 34 | + protected $userContext; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var SummaryFormContext |
|
| 38 | - */ |
|
| 39 | - protected $summaryFormContext; |
|
| 36 | + /** |
|
| 37 | + * @var SummaryFormContext |
|
| 38 | + */ |
|
| 39 | + protected $summaryFormContext; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @BeforeScenario |
|
| 43 | - * |
|
| 44 | - * @param BeforeScenarioScope $scope |
|
| 45 | - */ |
|
| 46 | - final public function gatherContexts(BeforeScenarioScope $scope) |
|
| 47 | - { |
|
| 48 | - $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
| 49 | - $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
| 50 | - $this->userContext = $scope->getEnvironment()->getContext(UserContext::class); |
|
| 51 | - $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
|
| 52 | - } |
|
| 41 | + /** |
|
| 42 | + * @BeforeScenario |
|
| 43 | + * |
|
| 44 | + * @param BeforeScenarioScope $scope |
|
| 45 | + */ |
|
| 46 | + final public function gatherContexts(BeforeScenarioScope $scope) |
|
| 47 | + { |
|
| 48 | + $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
| 49 | + $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
| 50 | + $this->userContext = $scope->getEnvironment()->getContext(UserContext::class); |
|
| 51 | + $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function buildUrl($name, array $params=array(), array $options=array()) |
|
| 55 | - { |
|
| 56 | - $defaults = ['lang'=>'en']; |
|
| 57 | - $params = array_merge($defaults,$params); |
|
| 54 | + public function buildUrl($name, array $params=array(), array $options=array()) |
|
| 55 | + { |
|
| 56 | + $defaults = ['lang'=>'en']; |
|
| 57 | + $params = array_merge($defaults,$params); |
|
| 58 | 58 | /* @var Url $urlHelper */ |
| 59 | 59 | $urlHelper = $this |
| 60 | 60 | ->getService('ViewHelperManager') |
@@ -63,36 +63,36 @@ discard block |
||
| 63 | 63 | $url = $urlHelper($name,$params,$options); |
| 64 | 64 | |
| 65 | 65 | return $this->coreContext->generateUrl($url); |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function visit($url) |
|
| 69 | - { |
|
| 70 | - $this->coreContext->iVisit($url); |
|
| 71 | - } |
|
| 68 | + public function visit($url) |
|
| 69 | + { |
|
| 70 | + $this->coreContext->iVisit($url); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @param $id |
|
| 75 | - * @return mixed|object |
|
| 76 | - */ |
|
| 77 | - public function getService($id) |
|
| 78 | - { |
|
| 79 | - return $this->coreContext->getServiceManager()->get($id); |
|
| 80 | - } |
|
| 73 | + /** |
|
| 74 | + * @param $id |
|
| 75 | + * @return mixed|object |
|
| 76 | + */ |
|
| 77 | + public function getService($id) |
|
| 78 | + { |
|
| 79 | + return $this->coreContext->getServiceManager()->get($id); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @param $id |
|
| 84 | - * |
|
| 85 | - * @return RepositoryInterface |
|
| 86 | - */ |
|
| 87 | - public function getRepository($id) |
|
| 88 | - { |
|
| 89 | - return $this->coreContext->getRepositories()->get($id); |
|
| 90 | - } |
|
| 82 | + /** |
|
| 83 | + * @param $id |
|
| 84 | + * |
|
| 85 | + * @return RepositoryInterface |
|
| 86 | + */ |
|
| 87 | + public function getRepository($id) |
|
| 88 | + { |
|
| 89 | + return $this->coreContext->getRepositories()->get($id); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * @return UserContext |
| 94 | 94 | */ |
| 95 | - public function getUserContext() |
|
| 95 | + public function getUserContext() |
|
| 96 | 96 | { |
| 97 | 97 | return $this->userContext; |
| 98 | 98 | } |
@@ -51,16 +51,16 @@ |
||
| 51 | 51 | $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public function buildUrl($name, array $params=array(), array $options=array()) |
|
| 54 | + public function buildUrl($name, array $params = array(), array $options = array()) |
|
| 55 | 55 | { |
| 56 | 56 | $defaults = ['lang'=>'en']; |
| 57 | - $params = array_merge($defaults,$params); |
|
| 57 | + $params = array_merge($defaults, $params); |
|
| 58 | 58 | /* @var Url $urlHelper */ |
| 59 | 59 | $urlHelper = $this |
| 60 | 60 | ->getService('ViewHelperManager') |
| 61 | 61 | ->get('url') |
| 62 | 62 | ; |
| 63 | - $url = $urlHelper($name,$params,$options); |
|
| 63 | + $url = $urlHelper($name, $params, $options); |
|
| 64 | 64 | |
| 65 | 65 | return $this->coreContext->generateUrl($url); |
| 66 | 66 | } |
@@ -23,43 +23,43 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class OrganizationContext implements Context |
| 25 | 25 | { |
| 26 | - use CommonContextTrait; |
|
| 26 | + use CommonContextTrait; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @Given I go to my organization page |
|
| 30 | - */ |
|
| 31 | - public function iGoToMyOrganizationPage() |
|
| 32 | - { |
|
| 28 | + /** |
|
| 29 | + * @Given I go to my organization page |
|
| 30 | + */ |
|
| 31 | + public function iGoToMyOrganizationPage() |
|
| 32 | + { |
|
| 33 | 33 | $url = $this->buildUrl('lang/my-organization'); |
| 34 | - $this->visit($url); |
|
| 35 | - } |
|
| 34 | + $this->visit($url); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @When I hover over name form |
|
| 39 | - */ |
|
| 40 | - public function iMouseOverOrganizationNameForm() |
|
| 41 | - { |
|
| 42 | - $locator = '#sf-nameForm .sf-summary'; |
|
| 43 | - $this->coreContext->iHoverOverTheElement($locator); |
|
| 44 | - } |
|
| 37 | + /** |
|
| 38 | + * @When I hover over name form |
|
| 39 | + */ |
|
| 40 | + public function iMouseOverOrganizationNameForm() |
|
| 41 | + { |
|
| 42 | + $locator = '#sf-nameForm .sf-summary'; |
|
| 43 | + $this->coreContext->iHoverOverTheElement($locator); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @Given I go to create new organization page |
|
| 48 | - */ |
|
| 49 | - public function iGoToCreateNewOrganizationPage() |
|
| 50 | - { |
|
| 51 | - //$this->visit('/organizations/edit'); |
|
| 46 | + /** |
|
| 47 | + * @Given I go to create new organization page |
|
| 48 | + */ |
|
| 49 | + public function iGoToCreateNewOrganizationPage() |
|
| 50 | + { |
|
| 51 | + //$this->visit('/organizations/edit'); |
|
| 52 | 52 | $url = $this->buildUrl('lang/organizations/edit'); |
| 53 | 53 | $this->visit($url); |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @Given I go to organization overview page |
|
| 58 | - */ |
|
| 59 | - public function iGoToOrganizationOverviewPage() |
|
| 60 | - { |
|
| 61 | - //$this->visit('/organizations'); |
|
| 62 | - $url = $this->buildUrl('lang/organizations'); |
|
| 63 | - $this->visit($url); |
|
| 64 | - } |
|
| 56 | + /** |
|
| 57 | + * @Given I go to organization overview page |
|
| 58 | + */ |
|
| 59 | + public function iGoToOrganizationOverviewPage() |
|
| 60 | + { |
|
| 61 | + //$this->visit('/organizations'); |
|
| 62 | + $url = $this->buildUrl('lang/organizations'); |
|
| 63 | + $this->visit($url); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -25,283 +25,283 @@ |
||
| 25 | 25 | { |
| 26 | 26 | use CommonContextTrait; |
| 27 | 27 | |
| 28 | - static protected $application; |
|
| 28 | + static protected $application; |
|
| 29 | 29 | |
| 30 | - static private $jobCategoryChecked = false; |
|
| 30 | + static private $jobCategoryChecked = false; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @BeforeScenario |
|
| 34 | - * @param BeforeScenarioScope $scope |
|
| 35 | - */ |
|
| 36 | - public function setupContexts(BeforeScenarioScope $scope) |
|
| 37 | - { |
|
| 38 | - if(false === static::$jobCategoryChecked){ |
|
| 39 | - /* @var Categories $catRepo */ |
|
| 40 | - $catRepo = $this->getRepositories()->get('Jobs/Category'); |
|
| 41 | - $all = $catRepo->findAll(); |
|
| 42 | - if(count($all) <= 1){ |
|
| 43 | - $catRepo->createDefaultCategory('professions'); |
|
| 44 | - $catRepo->createDefaultCategory('industries'); |
|
| 45 | - $catRepo->createDefaultCategory('employmentTypes'); |
|
| 46 | - } |
|
| 47 | - static::$jobCategoryChecked = true; |
|
| 48 | - } |
|
| 49 | - } |
|
| 32 | + /** |
|
| 33 | + * @BeforeScenario |
|
| 34 | + * @param BeforeScenarioScope $scope |
|
| 35 | + */ |
|
| 36 | + public function setupContexts(BeforeScenarioScope $scope) |
|
| 37 | + { |
|
| 38 | + if(false === static::$jobCategoryChecked){ |
|
| 39 | + /* @var Categories $catRepo */ |
|
| 40 | + $catRepo = $this->getRepositories()->get('Jobs/Category'); |
|
| 41 | + $all = $catRepo->findAll(); |
|
| 42 | + if(count($all) <= 1){ |
|
| 43 | + $catRepo->createDefaultCategory('professions'); |
|
| 44 | + $catRepo->createDefaultCategory('industries'); |
|
| 45 | + $catRepo->createDefaultCategory('employmentTypes'); |
|
| 46 | + } |
|
| 47 | + static::$jobCategoryChecked = true; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return Application |
|
| 53 | - */ |
|
| 54 | - public function getApplication() |
|
| 55 | - { |
|
| 56 | - if(!is_object(static::$application)){ |
|
| 57 | - $configFile = realpath(__DIR__.'/../../../config/config.php'); |
|
| 58 | - $config = include($configFile); |
|
| 59 | - static::$application = Application::init($config); |
|
| 60 | - } |
|
| 61 | - return static::$application; |
|
| 62 | - } |
|
| 51 | + /** |
|
| 52 | + * @return Application |
|
| 53 | + */ |
|
| 54 | + public function getApplication() |
|
| 55 | + { |
|
| 56 | + if(!is_object(static::$application)){ |
|
| 57 | + $configFile = realpath(__DIR__.'/../../../config/config.php'); |
|
| 58 | + $config = include($configFile); |
|
| 59 | + static::$application = Application::init($config); |
|
| 60 | + } |
|
| 61 | + return static::$application; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @return \Zend\ServiceManager\ServiceManager |
|
| 66 | - */ |
|
| 67 | - public function getServiceManager() |
|
| 68 | - { |
|
| 69 | - return $this->getApplication()->getServiceManager(); |
|
| 70 | - } |
|
| 64 | + /** |
|
| 65 | + * @return \Zend\ServiceManager\ServiceManager |
|
| 66 | + */ |
|
| 67 | + public function getServiceManager() |
|
| 68 | + { |
|
| 69 | + return $this->getApplication()->getServiceManager(); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @return \Zend\EventManager\EventManagerInterface |
|
| 74 | - */ |
|
| 75 | - public function getEventManager() |
|
| 76 | - { |
|
| 77 | - return $this->getApplication()->getEventManager(); |
|
| 78 | - } |
|
| 72 | + /** |
|
| 73 | + * @return \Zend\EventManager\EventManagerInterface |
|
| 74 | + */ |
|
| 75 | + public function getEventManager() |
|
| 76 | + { |
|
| 77 | + return $this->getApplication()->getEventManager(); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @return RepositoryService |
|
| 82 | - */ |
|
| 83 | - public function getRepositories() |
|
| 84 | - { |
|
| 85 | - return $this->getServiceManager()->get('repositories'); |
|
| 86 | - } |
|
| 80 | + /** |
|
| 81 | + * @return RepositoryService |
|
| 82 | + */ |
|
| 83 | + public function getRepositories() |
|
| 84 | + { |
|
| 85 | + return $this->getServiceManager()->get('repositories'); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @param $name |
|
| 90 | - * @param array $params |
|
| 91 | - * |
|
| 92 | - * @return string |
|
| 93 | - */ |
|
| 94 | - public function generateUrl($name) |
|
| 95 | - { |
|
| 96 | - return $this->minkContext->locatePath($name); |
|
| 97 | - } |
|
| 88 | + /** |
|
| 89 | + * @param $name |
|
| 90 | + * @param array $params |
|
| 91 | + * |
|
| 92 | + * @return string |
|
| 93 | + */ |
|
| 94 | + public function generateUrl($name) |
|
| 95 | + { |
|
| 96 | + return $this->minkContext->locatePath($name); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * @When /^I hover over the element "([^"]*)"$/ |
|
| 101 | - */ |
|
| 102 | - public function iHoverOverTheElement($locator) |
|
| 103 | - { |
|
| 104 | - $session = $this->minkContext->getSession(); // get the mink session |
|
| 105 | - $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element |
|
| 99 | + /** |
|
| 100 | + * @When /^I hover over the element "([^"]*)"$/ |
|
| 101 | + */ |
|
| 102 | + public function iHoverOverTheElement($locator) |
|
| 103 | + { |
|
| 104 | + $session = $this->minkContext->getSession(); // get the mink session |
|
| 105 | + $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element |
|
| 106 | 106 | |
| 107 | - // errors must not pass silently |
|
| 108 | - if (null === $element) { |
|
| 109 | - throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator)); |
|
| 110 | - } |
|
| 107 | + // errors must not pass silently |
|
| 108 | + if (null === $element) { |
|
| 109 | + throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator)); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - // ok, let's hover it |
|
| 113 | - $element->mouseOver(); |
|
| 114 | - } |
|
| 112 | + // ok, let's hover it |
|
| 113 | + $element->mouseOver(); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * @Given /^I wait for (\d+) seconds$/ |
|
| 118 | - */ |
|
| 119 | - public function iWaitForSecond($second) |
|
| 120 | - { |
|
| 121 | - sleep($second); |
|
| 122 | - } |
|
| 116 | + /** |
|
| 117 | + * @Given /^I wait for (\d+) seconds$/ |
|
| 118 | + */ |
|
| 119 | + public function iWaitForSecond($second) |
|
| 120 | + { |
|
| 121 | + sleep($second); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * @Then /^I wait for the ajax response$/ |
|
| 126 | - */ |
|
| 127 | - public function iWaitForTheAjaxResponse() |
|
| 128 | - { |
|
| 129 | - $this->getSession()->wait(5000, '(0 === jQuery.active)'); |
|
| 130 | - } |
|
| 124 | + /** |
|
| 125 | + * @Then /^I wait for the ajax response$/ |
|
| 126 | + */ |
|
| 127 | + public function iWaitForTheAjaxResponse() |
|
| 128 | + { |
|
| 129 | + $this->getSession()->wait(5000, '(0 === jQuery.active)'); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Some forms do not have a Submit button just pass the ID |
|
| 134 | - * |
|
| 135 | - * @Given /^I submit the form with id "([^"]*)"$/ |
|
| 136 | - */ |
|
| 137 | - public function iSubmitTheFormWithId($arg) |
|
| 138 | - { |
|
| 139 | - $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
|
| 140 | - if($node) { |
|
| 141 | - $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
|
| 142 | - } else { |
|
| 143 | - throw new \Exception('Element not found'); |
|
| 144 | - } |
|
| 145 | - } |
|
| 132 | + /** |
|
| 133 | + * Some forms do not have a Submit button just pass the ID |
|
| 134 | + * |
|
| 135 | + * @Given /^I submit the form with id "([^"]*)"$/ |
|
| 136 | + */ |
|
| 137 | + public function iSubmitTheFormWithId($arg) |
|
| 138 | + { |
|
| 139 | + $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
|
| 140 | + if($node) { |
|
| 141 | + $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
|
| 142 | + } else { |
|
| 143 | + throw new \Exception('Element not found'); |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * @Then I switch to popup :name |
|
| 149 | - * |
|
| 150 | - * @param $name |
|
| 151 | - */ |
|
| 152 | - public function iSwitchToPopup($name) |
|
| 153 | - { |
|
| 154 | - $this->iSetMainWindowName(); |
|
| 155 | - $this->getSession()->switchToWindow($name); |
|
| 156 | - } |
|
| 147 | + /** |
|
| 148 | + * @Then I switch to popup :name |
|
| 149 | + * |
|
| 150 | + * @param $name |
|
| 151 | + */ |
|
| 152 | + public function iSwitchToPopup($name) |
|
| 153 | + { |
|
| 154 | + $this->iSetMainWindowName(); |
|
| 155 | + $this->getSession()->switchToWindow($name); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * @Then I set main window name |
|
| 160 | - */ |
|
| 161 | - public function iSetMainWindowName() |
|
| 162 | - { |
|
| 163 | - $window_name = 'main_window'; |
|
| 164 | - $script = 'window.name = "' . $window_name . '"'; |
|
| 165 | - $this->getSession()->executeScript($script); |
|
| 166 | - } |
|
| 158 | + /** |
|
| 159 | + * @Then I set main window name |
|
| 160 | + */ |
|
| 161 | + public function iSetMainWindowName() |
|
| 162 | + { |
|
| 163 | + $window_name = 'main_window'; |
|
| 164 | + $script = 'window.name = "' . $window_name . '"'; |
|
| 165 | + $this->getSession()->executeScript($script); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * @Then I switch back to main window |
|
| 170 | - */ |
|
| 171 | - public function iSwitchBackToMainWindow() |
|
| 172 | - { |
|
| 173 | - $this->getSession()->switchToWindow('main_window'); |
|
| 174 | - } |
|
| 168 | + /** |
|
| 169 | + * @Then I switch back to main window |
|
| 170 | + */ |
|
| 171 | + public function iSwitchBackToMainWindow() |
|
| 172 | + { |
|
| 173 | + $this->getSession()->switchToWindow('main_window'); |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - public function iVisit($url) |
|
| 177 | - { |
|
| 178 | - $this->minkContext->getSession()->visit($url); |
|
| 179 | - } |
|
| 176 | + public function iVisit($url) |
|
| 177 | + { |
|
| 178 | + $this->minkContext->getSession()->visit($url); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * @When I scroll :selector into view |
|
| 183 | - * |
|
| 184 | - * @param string $selector Allowed selectors: #id, .className, //xpath |
|
| 185 | - * |
|
| 186 | - * @throws \Exception |
|
| 187 | - */ |
|
| 188 | - public function scrollIntoView($selector) |
|
| 189 | - { |
|
| 190 | - $locator = substr($selector, 0, 1); |
|
| 181 | + /** |
|
| 182 | + * @When I scroll :selector into view |
|
| 183 | + * |
|
| 184 | + * @param string $selector Allowed selectors: #id, .className, //xpath |
|
| 185 | + * |
|
| 186 | + * @throws \Exception |
|
| 187 | + */ |
|
| 188 | + public function scrollIntoView($selector) |
|
| 189 | + { |
|
| 190 | + $locator = substr($selector, 0, 1); |
|
| 191 | 191 | |
| 192 | - switch ($locator) { |
|
| 193 | - case '/' : // XPath selector |
|
| 194 | - $function = <<<JS |
|
| 192 | + switch ($locator) { |
|
| 193 | + case '/' : // XPath selector |
|
| 194 | + $function = <<<JS |
|
| 195 | 195 | (function(){ |
| 196 | 196 | var elem = document.evaluate($selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; |
| 197 | 197 | elem.scrollIntoView(false); |
| 198 | 198 | })() |
| 199 | 199 | JS; |
| 200 | - break; |
|
| 200 | + break; |
|
| 201 | 201 | |
| 202 | - case '#' : // ID selector |
|
| 203 | - $selector = substr($selector, 1); |
|
| 204 | - $function = <<<JS |
|
| 202 | + case '#' : // ID selector |
|
| 203 | + $selector = substr($selector, 1); |
|
| 204 | + $function = <<<JS |
|
| 205 | 205 | (function(){ |
| 206 | 206 | var elem = document.getElementById("$selector"); |
| 207 | 207 | elem.scrollIntoView(false); |
| 208 | 208 | })() |
| 209 | 209 | JS; |
| 210 | - break; |
|
| 210 | + break; |
|
| 211 | 211 | |
| 212 | - case '.' : // Class selector |
|
| 213 | - $selector = substr($selector, 1); |
|
| 214 | - $function = <<<JS |
|
| 212 | + case '.' : // Class selector |
|
| 213 | + $selector = substr($selector, 1); |
|
| 214 | + $function = <<<JS |
|
| 215 | 215 | (function(){ |
| 216 | 216 | var elem = document.getElementsByClassName("$selector"); |
| 217 | 217 | elem[0].scrollIntoView(false); |
| 218 | 218 | })() |
| 219 | 219 | JS; |
| 220 | - break; |
|
| 220 | + break; |
|
| 221 | 221 | |
| 222 | - default: |
|
| 223 | - throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
| 224 | - break; |
|
| 225 | - } |
|
| 222 | + default: |
|
| 223 | + throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
| 224 | + break; |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - try { |
|
| 228 | - $this->getSession()->executeScript($function); |
|
| 229 | - } catch (\Exception $e) { |
|
| 230 | - throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"'); |
|
| 231 | - } |
|
| 232 | - } |
|
| 227 | + try { |
|
| 228 | + $this->getSession()->executeScript($function); |
|
| 229 | + } catch (\Exception $e) { |
|
| 230 | + throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"'); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * @When I click location selector |
|
| 236 | - */ |
|
| 237 | - public function iClickLocationSelector() |
|
| 238 | - { |
|
| 239 | - $locator = '#jobBase-geoLocation-span .select2'; |
|
| 240 | - $element = $this->getElement($locator); |
|
| 241 | - $element->click(); |
|
| 242 | - } |
|
| 234 | + /** |
|
| 235 | + * @When I click location selector |
|
| 236 | + */ |
|
| 237 | + public function iClickLocationSelector() |
|
| 238 | + { |
|
| 239 | + $locator = '#jobBase-geoLocation-span .select2'; |
|
| 240 | + $element = $this->getElement($locator); |
|
| 241 | + $element->click(); |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - /** |
|
| 245 | - * @param $locator |
|
| 246 | - * @param string $selector |
|
| 247 | - * |
|
| 248 | - * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
| 249 | - */ |
|
| 250 | - public function getElement($locator,$selector='css') |
|
| 251 | - { |
|
| 252 | - $page = $this->minkContext->getSession()->getPage(); |
|
| 253 | - $element = $page->find('css',$locator); |
|
| 254 | - return $element; |
|
| 255 | - } |
|
| 244 | + /** |
|
| 245 | + * @param $locator |
|
| 246 | + * @param string $selector |
|
| 247 | + * |
|
| 248 | + * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
| 249 | + */ |
|
| 250 | + public function getElement($locator,$selector='css') |
|
| 251 | + { |
|
| 252 | + $page = $this->minkContext->getSession()->getPage(); |
|
| 253 | + $element = $page->find('css',$locator); |
|
| 254 | + return $element; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - /** |
|
| 258 | - * @When I fill in location search with :term |
|
| 259 | - * @param $term |
|
| 260 | - */ |
|
| 261 | - public function iFillInLocationSearch($term) |
|
| 262 | - { |
|
| 263 | - $locator = '.select2-container--open .select2-search__field'; |
|
| 264 | - $element = $this->getElement($locator); |
|
| 265 | - $element->focus(); |
|
| 266 | - $element->setValue($term); |
|
| 267 | - $this->iWaitForTheAjaxResponse(); |
|
| 268 | - } |
|
| 257 | + /** |
|
| 258 | + * @When I fill in location search with :term |
|
| 259 | + * @param $term |
|
| 260 | + */ |
|
| 261 | + public function iFillInLocationSearch($term) |
|
| 262 | + { |
|
| 263 | + $locator = '.select2-container--open .select2-search__field'; |
|
| 264 | + $element = $this->getElement($locator); |
|
| 265 | + $element->focus(); |
|
| 266 | + $element->setValue($term); |
|
| 267 | + $this->iWaitForTheAjaxResponse(); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - public function iClickOn() |
|
| 271 | - { |
|
| 270 | + public function iClickOn() |
|
| 271 | + { |
|
| 272 | 272 | |
| 273 | - } |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - /** |
|
| 276 | - * Click some text |
|
| 277 | - * |
|
| 278 | - * @When /^I click on the text "([^"]*)"$/ |
|
| 279 | - */ |
|
| 280 | - public function iClickOnTheText($text) |
|
| 281 | - { |
|
| 282 | - $session = $this->getSession(); |
|
| 283 | - $element = $session->getPage()->find( |
|
| 284 | - 'xpath', |
|
| 285 | - $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]') |
|
| 286 | - ); |
|
| 287 | - if(null === $element){ |
|
| 288 | - $element = $session->getPage()->find( |
|
| 289 | - 'named', |
|
| 290 | - array('id',$text) |
|
| 291 | - ); |
|
| 292 | - } |
|
| 293 | - if (null === $element) { |
|
| 294 | - throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text)); |
|
| 295 | - } |
|
| 275 | + /** |
|
| 276 | + * Click some text |
|
| 277 | + * |
|
| 278 | + * @When /^I click on the text "([^"]*)"$/ |
|
| 279 | + */ |
|
| 280 | + public function iClickOnTheText($text) |
|
| 281 | + { |
|
| 282 | + $session = $this->getSession(); |
|
| 283 | + $element = $session->getPage()->find( |
|
| 284 | + 'xpath', |
|
| 285 | + $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]') |
|
| 286 | + ); |
|
| 287 | + if(null === $element){ |
|
| 288 | + $element = $session->getPage()->find( |
|
| 289 | + 'named', |
|
| 290 | + array('id',$text) |
|
| 291 | + ); |
|
| 292 | + } |
|
| 293 | + if (null === $element) { |
|
| 294 | + throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text)); |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - $element->click(); |
|
| 297 | + $element->click(); |
|
| 298 | 298 | |
| 299 | - } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | 301 | /** |
| 302 | 302 | * @Then /^(?:|I )should see translated text "(?P<text>(?:[^"]|\\")*)"$/ |
| 303 | 303 | */ |
| 304 | - public function iShouldSeeText($text) |
|
| 304 | + public function iShouldSeeText($text) |
|
| 305 | 305 | { |
| 306 | 306 | $translator = $this->getServiceManager()->get('translator'); |
| 307 | 307 | $translated = $translator->translate($text); |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function setupContexts(BeforeScenarioScope $scope) |
| 37 | 37 | { |
| 38 | - if(false === static::$jobCategoryChecked){ |
|
| 38 | + if (false === static::$jobCategoryChecked) { |
|
| 39 | 39 | /* @var Categories $catRepo */ |
| 40 | 40 | $catRepo = $this->getRepositories()->get('Jobs/Category'); |
| 41 | 41 | $all = $catRepo->findAll(); |
| 42 | - if(count($all) <= 1){ |
|
| 42 | + if (count($all) <= 1) { |
|
| 43 | 43 | $catRepo->createDefaultCategory('professions'); |
| 44 | 44 | $catRepo->createDefaultCategory('industries'); |
| 45 | 45 | $catRepo->createDefaultCategory('employmentTypes'); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function getApplication() |
| 55 | 55 | { |
| 56 | - if(!is_object(static::$application)){ |
|
| 56 | + if (!is_object(static::$application)) { |
|
| 57 | 57 | $configFile = realpath(__DIR__.'/../../../config/config.php'); |
| 58 | 58 | $config = include($configFile); |
| 59 | 59 | static::$application = Application::init($config); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | public function iSubmitTheFormWithId($arg) |
| 138 | 138 | { |
| 139 | 139 | $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
| 140 | - if($node) { |
|
| 140 | + if ($node) { |
|
| 141 | 141 | $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
| 142 | 142 | } else { |
| 143 | 143 | throw new \Exception('Element not found'); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | public function iSetMainWindowName() |
| 162 | 162 | { |
| 163 | 163 | $window_name = 'main_window'; |
| 164 | - $script = 'window.name = "' . $window_name . '"'; |
|
| 164 | + $script = 'window.name = "'.$window_name.'"'; |
|
| 165 | 165 | $this->getSession()->executeScript($script); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | break; |
| 221 | 221 | |
| 222 | 222 | default: |
| 223 | - throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
| 223 | + throw new \Exception(__METHOD__.' Couldn\'t find selector: '.$selector.' - Allowed selectors: #id, .className, //xpath'); |
|
| 224 | 224 | break; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | try { |
| 228 | 228 | $this->getSession()->executeScript($function); |
| 229 | 229 | } catch (\Exception $e) { |
| 230 | - throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"'); |
|
| 230 | + throw new \Exception(__METHOD__.' failed'.' Message: for this locator:"'.$selector.'"'); |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return \Behat\Mink\Element\NodeElement|mixed|null |
| 249 | 249 | */ |
| 250 | - public function getElement($locator,$selector='css') |
|
| 250 | + public function getElement($locator, $selector = 'css') |
|
| 251 | 251 | { |
| 252 | 252 | $page = $this->minkContext->getSession()->getPage(); |
| 253 | - $element = $page->find('css',$locator); |
|
| 253 | + $element = $page->find('css', $locator); |
|
| 254 | 254 | return $element; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -282,12 +282,12 @@ discard block |
||
| 282 | 282 | $session = $this->getSession(); |
| 283 | 283 | $element = $session->getPage()->find( |
| 284 | 284 | 'xpath', |
| 285 | - $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]') |
|
| 285 | + $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'.$text.'"]') |
|
| 286 | 286 | ); |
| 287 | - if(null === $element){ |
|
| 287 | + if (null === $element) { |
|
| 288 | 288 | $element = $session->getPage()->find( |
| 289 | 289 | 'named', |
| 290 | - array('id',$text) |
|
| 290 | + array('id', $text) |
|
| 291 | 291 | ); |
| 292 | 292 | } |
| 293 | 293 | if (null === $element) { |
@@ -33,324 +33,324 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class JobContext implements Context |
| 35 | 35 | { |
| 36 | - use CommonContextTrait; |
|
| 36 | + use CommonContextTrait; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var Select2Context |
|
| 40 | - */ |
|
| 41 | - private $select2Context; |
|
| 38 | + /** |
|
| 39 | + * @var Select2Context |
|
| 40 | + */ |
|
| 41 | + private $select2Context; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var Job |
|
| 45 | - */ |
|
| 46 | - private $currentJob; |
|
| 43 | + /** |
|
| 44 | + * @var Job |
|
| 45 | + */ |
|
| 46 | + private $currentJob; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var JobRepository |
|
| 50 | - */ |
|
| 51 | - static private $jobRepo; |
|
| 48 | + /** |
|
| 49 | + * @var JobRepository |
|
| 50 | + */ |
|
| 51 | + static private $jobRepo; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @param User $user |
|
| 55 | - */ |
|
| 56 | - static public function removeJobByUser(User $user) |
|
| 57 | - { |
|
| 58 | - $repo = static::$jobRepo; |
|
| 59 | - $results = $repo->findBy(['user' => $user]); |
|
| 60 | - foreach($results as $result){ |
|
| 61 | - $repo->remove($result,true); |
|
| 62 | - } |
|
| 63 | - } |
|
| 53 | + /** |
|
| 54 | + * @param User $user |
|
| 55 | + */ |
|
| 56 | + static public function removeJobByUser(User $user) |
|
| 57 | + { |
|
| 58 | + $repo = static::$jobRepo; |
|
| 59 | + $results = $repo->findBy(['user' => $user]); |
|
| 60 | + foreach($results as $result){ |
|
| 61 | + $repo->remove($result,true); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @BeforeScenario |
|
| 67 | - * |
|
| 68 | - * @param BeforeScenarioScope $scope |
|
| 69 | - */ |
|
| 70 | - public function beforeScenario(BeforeScenarioScope $scope) |
|
| 71 | - { |
|
| 72 | - $this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class); |
|
| 73 | - if(is_null(static::$jobRepo)){ |
|
| 74 | - $this->gatherContexts($scope); |
|
| 75 | - static::$jobRepo = $this->getJobRepository(); |
|
| 76 | - } |
|
| 77 | - } |
|
| 65 | + /** |
|
| 66 | + * @BeforeScenario |
|
| 67 | + * |
|
| 68 | + * @param BeforeScenarioScope $scope |
|
| 69 | + */ |
|
| 70 | + public function beforeScenario(BeforeScenarioScope $scope) |
|
| 71 | + { |
|
| 72 | + $this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class); |
|
| 73 | + if(is_null(static::$jobRepo)){ |
|
| 74 | + $this->gatherContexts($scope); |
|
| 75 | + static::$jobRepo = $this->getJobRepository(); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @Given I go to job board page |
|
| 81 | - */ |
|
| 82 | - public function iGoToJobBoardPage() |
|
| 83 | - { |
|
| 84 | - $this->visit('/jobboard'); |
|
| 85 | - } |
|
| 79 | + /** |
|
| 80 | + * @Given I go to job board page |
|
| 81 | + */ |
|
| 82 | + public function iGoToJobBoardPage() |
|
| 83 | + { |
|
| 84 | + $this->visit('/jobboard'); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * @Given I go to create job page |
|
| 89 | - */ |
|
| 90 | - public function iGoToCreateJob() |
|
| 91 | - { |
|
| 92 | - $url = $this->buildUrl('lang/jobs/manage',['action' => 'edit']); |
|
| 93 | - $this->visit($url); |
|
| 94 | - } |
|
| 87 | + /** |
|
| 88 | + * @Given I go to create job page |
|
| 89 | + */ |
|
| 90 | + public function iGoToCreateJob() |
|
| 91 | + { |
|
| 92 | + $url = $this->buildUrl('lang/jobs/manage',['action' => 'edit']); |
|
| 93 | + $this->visit($url); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * @Given I go to job overview page |
|
| 98 | - */ |
|
| 99 | - public function iGoToJobOverviewPage() |
|
| 100 | - { |
|
| 101 | - $this->visit('/jobs'); |
|
| 102 | - } |
|
| 96 | + /** |
|
| 97 | + * @Given I go to job overview page |
|
| 98 | + */ |
|
| 99 | + public function iGoToJobOverviewPage() |
|
| 100 | + { |
|
| 101 | + $this->visit('/jobs'); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * @Given I go to edit job draft with title :jobTitle |
|
| 106 | - * @param $jobTitle |
|
| 107 | - * @throws \Exception when job is not found |
|
| 108 | - */ |
|
| 109 | - public function iGoToEditJobWithTitle($jobTitle) |
|
| 110 | - { |
|
| 111 | - $job = $this->getJobRepository()->findOneBy(['title' => $jobTitle]); |
|
| 112 | - if(!$job instanceof Job){ |
|
| 113 | - throw new \Exception(sprintf('Job with title "%s" is not found',$jobTitle)); |
|
| 114 | - } |
|
| 115 | - $this->currentJob = $job; |
|
| 116 | - $url = $this->buildUrl('lang/jobs/manage',[ |
|
| 117 | - 'id' => $job->getId() |
|
| 104 | + /** |
|
| 105 | + * @Given I go to edit job draft with title :jobTitle |
|
| 106 | + * @param $jobTitle |
|
| 107 | + * @throws \Exception when job is not found |
|
| 108 | + */ |
|
| 109 | + public function iGoToEditJobWithTitle($jobTitle) |
|
| 110 | + { |
|
| 111 | + $job = $this->getJobRepository()->findOneBy(['title' => $jobTitle]); |
|
| 112 | + if(!$job instanceof Job){ |
|
| 113 | + throw new \Exception(sprintf('Job with title "%s" is not found',$jobTitle)); |
|
| 114 | + } |
|
| 115 | + $this->currentJob = $job; |
|
| 116 | + $url = $this->buildUrl('lang/jobs/manage',[ |
|
| 117 | + 'id' => $job->getId() |
|
| 118 | 118 | ]); |
| 119 | - $this->visit($url); |
|
| 120 | - } |
|
| 119 | + $this->visit($url); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * @Given I don't have any classification data |
|
| 124 | - */ |
|
| 125 | - public function iDonTHaveAnyClassificationData() |
|
| 126 | - { |
|
| 127 | - $this->currentJob->setClassifications(new Classifications()); |
|
| 128 | - $this->getJobRepository()->store($this->currentJob); |
|
| 129 | - } |
|
| 122 | + /** |
|
| 123 | + * @Given I don't have any classification data |
|
| 124 | + */ |
|
| 125 | + public function iDonTHaveAnyClassificationData() |
|
| 126 | + { |
|
| 127 | + $this->currentJob->setClassifications(new Classifications()); |
|
| 128 | + $this->getJobRepository()->store($this->currentJob); |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * @When I don't have any posted job |
|
| 133 | - */ |
|
| 134 | - public function iDonTHaveAnyPostedJob() |
|
| 135 | - { |
|
| 136 | - /* @var $jobRepository JobRepository */ |
|
| 137 | - /* @var $job Job */ |
|
| 138 | - $user = $this->getUserContext()->getCurrentUser(); |
|
| 131 | + /** |
|
| 132 | + * @When I don't have any posted job |
|
| 133 | + */ |
|
| 134 | + public function iDonTHaveAnyPostedJob() |
|
| 135 | + { |
|
| 136 | + /* @var $jobRepository JobRepository */ |
|
| 137 | + /* @var $job Job */ |
|
| 138 | + $user = $this->getUserContext()->getCurrentUser(); |
|
| 139 | 139 | |
| 140 | - $jobRepository = $this->getJobRepository(); |
|
| 141 | - $results = $jobRepository->getUserJobs($user->getId()); |
|
| 142 | - foreach($results as $job){ |
|
| 143 | - $jobRepository->remove($job,true); |
|
| 144 | - } |
|
| 145 | - $this->currentJob = null; |
|
| 146 | - } |
|
| 140 | + $jobRepository = $this->getJobRepository(); |
|
| 141 | + $results = $jobRepository->getUserJobs($user->getId()); |
|
| 142 | + foreach($results as $job){ |
|
| 143 | + $jobRepository->remove($job,true); |
|
| 144 | + } |
|
| 145 | + $this->currentJob = null; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * @When I fill job location search with :search and choose :choice |
|
| 150 | - * |
|
| 151 | - */ |
|
| 152 | - public function iFillJobLocationAndChoose($search,$choice) |
|
| 153 | - { |
|
| 154 | - $select2 = $this->select2Context; |
|
| 155 | - $select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice); |
|
| 156 | - } |
|
| 148 | + /** |
|
| 149 | + * @When I fill job location search with :search and choose :choice |
|
| 150 | + * |
|
| 151 | + */ |
|
| 152 | + public function iFillJobLocationAndChoose($search,$choice) |
|
| 153 | + { |
|
| 154 | + $select2 = $this->select2Context; |
|
| 155 | + $select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * @When I choose :value from :field |
|
| 160 | - */ |
|
| 161 | - public function iJobClassificationSelect($value,$field) |
|
| 162 | - { |
|
| 163 | - $field = Inflector::camelize($field); |
|
| 158 | + /** |
|
| 159 | + * @When I choose :value from :field |
|
| 160 | + */ |
|
| 161 | + public function iJobClassificationSelect($value,$field) |
|
| 162 | + { |
|
| 163 | + $field = Inflector::camelize($field); |
|
| 164 | 164 | |
| 165 | - $mapSelect2 = [ |
|
| 166 | - 'professions' => '#classifications-professions-span .select2-container', |
|
| 167 | - 'industries' => '#classifications-industries-span .select2-container', |
|
| 168 | - 'employmentTypes' => '#classifications-employmentTypes-span .select2-container', |
|
| 169 | - ]; |
|
| 165 | + $mapSelect2 = [ |
|
| 166 | + 'professions' => '#classifications-professions-span .select2-container', |
|
| 167 | + 'industries' => '#classifications-industries-span .select2-container', |
|
| 168 | + 'employmentTypes' => '#classifications-employmentTypes-span .select2-container', |
|
| 169 | + ]; |
|
| 170 | 170 | |
| 171 | - $mapMultiple = [ |
|
| 172 | - 'professions' => "select#classifications-professions", |
|
| 173 | - 'industries' => "select#classifications-industries", |
|
| 174 | - 'employmentTypes' => "select#classifications-employmentTypes", |
|
| 175 | - ]; |
|
| 171 | + $mapMultiple = [ |
|
| 172 | + 'professions' => "select#classifications-professions", |
|
| 173 | + 'industries' => "select#classifications-industries", |
|
| 174 | + 'employmentTypes' => "select#classifications-employmentTypes", |
|
| 175 | + ]; |
|
| 176 | 176 | |
| 177 | - if(!isset($mapSelect2[$field])){ |
|
| 178 | - throw new \Exception('Undefined field selection value "'.$field.'"'); |
|
| 179 | - } |
|
| 177 | + if(!isset($mapSelect2[$field])){ |
|
| 178 | + throw new \Exception('Undefined field selection value "'.$field.'"'); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - $multipleField = $mapMultiple[$field]; |
|
| 182 | - $page = $this->minkContext->getSession()->getPage(); |
|
| 183 | - $element = $page->find('css',$mapMultiple[$field]); |
|
| 184 | - if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){ |
|
| 185 | - $this->minkContext->selectOption($value,$multipleField); |
|
| 186 | - }else{ |
|
| 187 | - $locator = $mapSelect2[$field]; |
|
| 188 | - $this->select2Context->iFillInSelect2Field($locator,$value); |
|
| 189 | - } |
|
| 190 | - } |
|
| 181 | + $multipleField = $mapMultiple[$field]; |
|
| 182 | + $page = $this->minkContext->getSession()->getPage(); |
|
| 183 | + $element = $page->find('css',$mapMultiple[$field]); |
|
| 184 | + if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){ |
|
| 185 | + $this->minkContext->selectOption($value,$multipleField); |
|
| 186 | + }else{ |
|
| 187 | + $locator = $mapSelect2[$field]; |
|
| 188 | + $this->select2Context->iFillInSelect2Field($locator,$value); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * @return JobRepository |
|
| 194 | - */ |
|
| 195 | - public function getJobRepository() |
|
| 196 | - { |
|
| 197 | - return $this->getRepository('Jobs/Job'); |
|
| 198 | - } |
|
| 192 | + /** |
|
| 193 | + * @return JobRepository |
|
| 194 | + */ |
|
| 195 | + public function getJobRepository() |
|
| 196 | + { |
|
| 197 | + return $this->getRepository('Jobs/Job'); |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - /** |
|
| 201 | - * @return CategoriesRepo |
|
| 202 | - */ |
|
| 203 | - public function getCategoriesRepository() |
|
| 204 | - { |
|
| 205 | - return $this->getRepository('Jobs/Category'); |
|
| 206 | - } |
|
| 200 | + /** |
|
| 201 | + * @return CategoriesRepo |
|
| 202 | + */ |
|
| 203 | + public function getCategoriesRepository() |
|
| 204 | + { |
|
| 205 | + return $this->getRepository('Jobs/Category'); |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - /** |
|
| 209 | - * @When I have a :status job with the following: |
|
| 210 | - * @param TableNode $fields |
|
| 211 | - */ |
|
| 212 | - public function iHaveAJobWithTheFollowing($status,TableNode $fields) |
|
| 213 | - { |
|
| 214 | - $normalizedField = [ |
|
| 215 | - 'template' => 'modern', |
|
| 216 | - ]; |
|
| 217 | - foreach($fields->getRowsHash() as $field => $value){ |
|
| 218 | - $field = Inflector::camelize($field); |
|
| 219 | - if($field == 'professions' || $field == 'industries'){ |
|
| 220 | - $value = explode(',',$value); |
|
| 221 | - } |
|
| 222 | - $normalizedField[$field] = $value; |
|
| 223 | - } |
|
| 224 | - $jobRepo = $this->getJobRepository(); |
|
| 225 | - $job = $jobRepo->findOneBy(['title' => $normalizedField['title']]); |
|
| 226 | - if(!$job instanceof Job){ |
|
| 227 | - $job = new Job(); |
|
| 228 | - $job->setTitle($normalizedField['title']); |
|
| 229 | - } |
|
| 230 | - if(isset($normalizedField['user'])){ |
|
| 231 | - /* @var $userRepo UserRepository */ |
|
| 232 | - $user = $this->getUserContext()->getCurrentUser(); |
|
| 233 | - $jobRepo->getDocumentManager()->refresh($user); |
|
| 234 | - if($user instanceof User){ |
|
| 235 | - $job->setUser($user); |
|
| 236 | - $job->setOrganization($user->getOrganization()->getOrganization()); |
|
| 237 | - }else{ |
|
| 238 | - throw new \Exception('There is no user with this login:"'.$normalizedField['user'.'"']); |
|
| 239 | - } |
|
| 240 | - } |
|
| 208 | + /** |
|
| 209 | + * @When I have a :status job with the following: |
|
| 210 | + * @param TableNode $fields |
|
| 211 | + */ |
|
| 212 | + public function iHaveAJobWithTheFollowing($status,TableNode $fields) |
|
| 213 | + { |
|
| 214 | + $normalizedField = [ |
|
| 215 | + 'template' => 'modern', |
|
| 216 | + ]; |
|
| 217 | + foreach($fields->getRowsHash() as $field => $value){ |
|
| 218 | + $field = Inflector::camelize($field); |
|
| 219 | + if($field == 'professions' || $field == 'industries'){ |
|
| 220 | + $value = explode(',',$value); |
|
| 221 | + } |
|
| 222 | + $normalizedField[$field] = $value; |
|
| 223 | + } |
|
| 224 | + $jobRepo = $this->getJobRepository(); |
|
| 225 | + $job = $jobRepo->findOneBy(['title' => $normalizedField['title']]); |
|
| 226 | + if(!$job instanceof Job){ |
|
| 227 | + $job = new Job(); |
|
| 228 | + $job->setTitle($normalizedField['title']); |
|
| 229 | + } |
|
| 230 | + if(isset($normalizedField['user'])){ |
|
| 231 | + /* @var $userRepo UserRepository */ |
|
| 232 | + $user = $this->getUserContext()->getCurrentUser(); |
|
| 233 | + $jobRepo->getDocumentManager()->refresh($user); |
|
| 234 | + if($user instanceof User){ |
|
| 235 | + $job->setUser($user); |
|
| 236 | + $job->setOrganization($user->getOrganization()->getOrganization()); |
|
| 237 | + }else{ |
|
| 238 | + throw new \Exception('There is no user with this login:"'.$normalizedField['user'.'"']); |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - if($status == 'draft'){ |
|
| 243 | - $job->setIsDraft(true); |
|
| 244 | - }elseif($status == 'published'){ |
|
| 245 | - $job->setIsDraft(false); |
|
| 246 | - $job->setDatePublishStart(new \DateTime()); |
|
| 247 | - } |
|
| 248 | - $job->setStatus(Status::ACTIVE); |
|
| 242 | + if($status == 'draft'){ |
|
| 243 | + $job->setIsDraft(true); |
|
| 244 | + }elseif($status == 'published'){ |
|
| 245 | + $job->setIsDraft(false); |
|
| 246 | + $job->setDatePublishStart(new \DateTime()); |
|
| 247 | + } |
|
| 248 | + $job->setStatus(Status::ACTIVE); |
|
| 249 | 249 | |
| 250 | - if(isset($normalizedField['location'])){ |
|
| 251 | - $this->setLocation($job,$normalizedField['location']); |
|
| 252 | - } |
|
| 253 | - if(isset($normalizedField['companyName'])){ |
|
| 254 | - //$job->setCompany($normalizedField['companyName']); |
|
| 255 | - } |
|
| 256 | - if(isset($normalizedField['professions'])){ |
|
| 257 | - $this->addProfessions($job,$normalizedField['professions']); |
|
| 258 | - } |
|
| 250 | + if(isset($normalizedField['location'])){ |
|
| 251 | + $this->setLocation($job,$normalizedField['location']); |
|
| 252 | + } |
|
| 253 | + if(isset($normalizedField['companyName'])){ |
|
| 254 | + //$job->setCompany($normalizedField['companyName']); |
|
| 255 | + } |
|
| 256 | + if(isset($normalizedField['professions'])){ |
|
| 257 | + $this->addProfessions($job,$normalizedField['professions']); |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - if(isset($normalizedField['industries'])){ |
|
| 261 | - $this->addIndustries($job,$normalizedField['industries']); |
|
| 262 | - } |
|
| 263 | - if(isset($normalizedField['employmentTypes'])){ |
|
| 264 | - $types = $this->getCategories([$normalizedField['employmentTypes']]); |
|
| 265 | - $type = array_shift($types); |
|
| 266 | - $values = $job->getClassifications()->getEmploymentTypes()->getValues(); |
|
| 267 | - if(!is_array($values) || !in_array($type,$values)){ |
|
| 268 | - $job->getClassifications()->getEmploymentTypes()->getItems()->add($type); |
|
| 269 | - } |
|
| 270 | - } |
|
| 260 | + if(isset($normalizedField['industries'])){ |
|
| 261 | + $this->addIndustries($job,$normalizedField['industries']); |
|
| 262 | + } |
|
| 263 | + if(isset($normalizedField['employmentTypes'])){ |
|
| 264 | + $types = $this->getCategories([$normalizedField['employmentTypes']]); |
|
| 265 | + $type = array_shift($types); |
|
| 266 | + $values = $job->getClassifications()->getEmploymentTypes()->getValues(); |
|
| 267 | + if(!is_array($values) || !in_array($type,$values)){ |
|
| 268 | + $job->getClassifications()->getEmploymentTypes()->getItems()->add($type); |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - $jobRepo->store($job); |
|
| 273 | - $this->currentJob = $job; |
|
| 274 | - } |
|
| 272 | + $jobRepo->store($job); |
|
| 273 | + $this->currentJob = $job; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - private function setLocation(Job $job, $term) |
|
| 277 | - { |
|
| 278 | - /* @var $client Photon */ |
|
| 279 | - $client = $this->coreContext->getServiceManager()->get('Geo/Client'); |
|
| 280 | - $result = $client->queryOne($term); |
|
| 281 | - $location = new Location(); |
|
| 282 | - $serialized = Json::encode($result); |
|
| 283 | - $location->fromString($serialized); |
|
| 276 | + private function setLocation(Job $job, $term) |
|
| 277 | + { |
|
| 278 | + /* @var $client Photon */ |
|
| 279 | + $client = $this->coreContext->getServiceManager()->get('Geo/Client'); |
|
| 280 | + $result = $client->queryOne($term); |
|
| 281 | + $location = new Location(); |
|
| 282 | + $serialized = Json::encode($result); |
|
| 283 | + $location->fromString($serialized); |
|
| 284 | 284 | |
| 285 | - $locations = $job->getLocations(); |
|
| 286 | - if(count($locations)){ |
|
| 287 | - $locations->clear(); |
|
| 288 | - } |
|
| 289 | - $job->getLocations()->add($location); |
|
| 290 | - } |
|
| 285 | + $locations = $job->getLocations(); |
|
| 286 | + if(count($locations)){ |
|
| 287 | + $locations->clear(); |
|
| 288 | + } |
|
| 289 | + $job->getLocations()->add($location); |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - private function addProfessions(Job &$job,$terms) |
|
| 293 | - { |
|
| 294 | - $professions = $this->getCategories($terms); |
|
| 295 | - foreach($professions as $profession){ |
|
| 296 | - $values = $job->getClassifications()->getProfessions()->getValues(); |
|
| 297 | - if(!is_array($values) || !in_array($profession,$values)){ |
|
| 298 | - $job->getClassifications()->getProfessions()->getItems()->add($profession); |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 292 | + private function addProfessions(Job &$job,$terms) |
|
| 293 | + { |
|
| 294 | + $professions = $this->getCategories($terms); |
|
| 295 | + foreach($professions as $profession){ |
|
| 296 | + $values = $job->getClassifications()->getProfessions()->getValues(); |
|
| 297 | + if(!is_array($values) || !in_array($profession,$values)){ |
|
| 298 | + $job->getClassifications()->getProfessions()->getItems()->add($profession); |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - private function addIndustries(Job &$job, $terms) |
|
| 304 | - { |
|
| 305 | - $industries = $this->getCategories($terms); |
|
| 306 | - foreach($industries as $industry){ |
|
| 307 | - $values = $job->getClassifications()->getIndustries()->getValues(); |
|
| 308 | - if(!is_array($values) || !in_array($industry,$values)){ |
|
| 309 | - $job->getClassifications()->getIndustries()->getItems()->add($industry); |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - } |
|
| 303 | + private function addIndustries(Job &$job, $terms) |
|
| 304 | + { |
|
| 305 | + $industries = $this->getCategories($terms); |
|
| 306 | + foreach($industries as $industry){ |
|
| 307 | + $values = $job->getClassifications()->getIndustries()->getValues(); |
|
| 308 | + if(!is_array($values) || !in_array($industry,$values)){ |
|
| 309 | + $job->getClassifications()->getIndustries()->getItems()->add($industry); |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - /** |
|
| 315 | - * @param array $categories |
|
| 316 | - * |
|
| 317 | - * @return mixed |
|
| 318 | - */ |
|
| 319 | - private function getCategories(array $categories) |
|
| 320 | - { |
|
| 321 | - $catRepo = $this->getCategoriesRepository(); |
|
| 314 | + /** |
|
| 315 | + * @param array $categories |
|
| 316 | + * |
|
| 317 | + * @return mixed |
|
| 318 | + */ |
|
| 319 | + private function getCategories(array $categories) |
|
| 320 | + { |
|
| 321 | + $catRepo = $this->getCategoriesRepository(); |
|
| 322 | 322 | |
| 323 | - // get a professions |
|
| 324 | - $qb = $catRepo->createQueryBuilder() |
|
| 325 | - ->field('name')->in($categories) |
|
| 326 | - ->getQuery() |
|
| 327 | - ; |
|
| 328 | - $results = $qb->execute(); |
|
| 329 | - return $results->toArray(); |
|
| 330 | - } |
|
| 323 | + // get a professions |
|
| 324 | + $qb = $catRepo->createQueryBuilder() |
|
| 325 | + ->field('name')->in($categories) |
|
| 326 | + ->getQuery() |
|
| 327 | + ; |
|
| 328 | + $results = $qb->execute(); |
|
| 329 | + return $results->toArray(); |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | 332 | |
| 333 | - /** |
|
| 334 | - * @return Job |
|
| 335 | - */ |
|
| 336 | - private function getCurrentUserJobDraft($jobTitle) |
|
| 337 | - { |
|
| 338 | - $repo = $this->getJobRepository(); |
|
| 339 | - $user = $this->getCurrentUser(); |
|
| 333 | + /** |
|
| 334 | + * @return Job |
|
| 335 | + */ |
|
| 336 | + private function getCurrentUserJobDraft($jobTitle) |
|
| 337 | + { |
|
| 338 | + $repo = $this->getJobRepository(); |
|
| 339 | + $user = $this->getCurrentUser(); |
|
| 340 | 340 | |
| 341 | - $job = $repo->findDraft($user); |
|
| 341 | + $job = $repo->findDraft($user); |
|
| 342 | 342 | |
| 343 | - if(is_null($job)){ |
|
| 344 | - $job = new Job(); |
|
| 345 | - $job |
|
| 346 | - ->setUser($user) |
|
| 347 | - ->setOrganization($user->getOrganization()->getOrganization()) |
|
| 348 | - ->setStatus(StatusInterface::CREATED) |
|
| 349 | - ; |
|
| 350 | - $job->setIsDraft(true); |
|
| 351 | - } |
|
| 352 | - $job->setTitle($jobTitle); |
|
| 353 | - $repo->store($job); |
|
| 354 | - return $job; |
|
| 355 | - } |
|
| 343 | + if(is_null($job)){ |
|
| 344 | + $job = new Job(); |
|
| 345 | + $job |
|
| 346 | + ->setUser($user) |
|
| 347 | + ->setOrganization($user->getOrganization()->getOrganization()) |
|
| 348 | + ->setStatus(StatusInterface::CREATED) |
|
| 349 | + ; |
|
| 350 | + $job->setIsDraft(true); |
|
| 351 | + } |
|
| 352 | + $job->setTitle($jobTitle); |
|
| 353 | + $repo->store($job); |
|
| 354 | + return $job; |
|
| 355 | + } |
|
| 356 | 356 | } |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $repo = static::$jobRepo; |
| 59 | 59 | $results = $repo->findBy(['user' => $user]); |
| 60 | - foreach($results as $result){ |
|
| 61 | - $repo->remove($result,true); |
|
| 60 | + foreach ($results as $result) { |
|
| 61 | + $repo->remove($result, true); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function beforeScenario(BeforeScenarioScope $scope) |
| 71 | 71 | { |
| 72 | 72 | $this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class); |
| 73 | - if(is_null(static::$jobRepo)){ |
|
| 73 | + if (is_null(static::$jobRepo)) { |
|
| 74 | 74 | $this->gatherContexts($scope); |
| 75 | 75 | static::$jobRepo = $this->getJobRepository(); |
| 76 | 76 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function iGoToCreateJob() |
| 91 | 91 | { |
| 92 | - $url = $this->buildUrl('lang/jobs/manage',['action' => 'edit']); |
|
| 92 | + $url = $this->buildUrl('lang/jobs/manage', ['action' => 'edit']); |
|
| 93 | 93 | $this->visit($url); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | public function iGoToEditJobWithTitle($jobTitle) |
| 110 | 110 | { |
| 111 | 111 | $job = $this->getJobRepository()->findOneBy(['title' => $jobTitle]); |
| 112 | - if(!$job instanceof Job){ |
|
| 113 | - throw new \Exception(sprintf('Job with title "%s" is not found',$jobTitle)); |
|
| 112 | + if (!$job instanceof Job) { |
|
| 113 | + throw new \Exception(sprintf('Job with title "%s" is not found', $jobTitle)); |
|
| 114 | 114 | } |
| 115 | 115 | $this->currentJob = $job; |
| 116 | - $url = $this->buildUrl('lang/jobs/manage',[ |
|
| 116 | + $url = $this->buildUrl('lang/jobs/manage', [ |
|
| 117 | 117 | 'id' => $job->getId() |
| 118 | 118 | ]); |
| 119 | 119 | $this->visit($url); |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $jobRepository = $this->getJobRepository(); |
| 141 | 141 | $results = $jobRepository->getUserJobs($user->getId()); |
| 142 | - foreach($results as $job){ |
|
| 143 | - $jobRepository->remove($job,true); |
|
| 142 | + foreach ($results as $job) { |
|
| 143 | + $jobRepository->remove($job, true); |
|
| 144 | 144 | } |
| 145 | 145 | $this->currentJob = null; |
| 146 | 146 | } |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | * @When I fill job location search with :search and choose :choice |
| 150 | 150 | * |
| 151 | 151 | */ |
| 152 | - public function iFillJobLocationAndChoose($search,$choice) |
|
| 152 | + public function iFillJobLocationAndChoose($search, $choice) |
|
| 153 | 153 | { |
| 154 | 154 | $select2 = $this->select2Context; |
| 155 | - $select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice); |
|
| 155 | + $select2->iFillInSelect2FieldWith('jobBase[geoLocation]', $search, $choice); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * @When I choose :value from :field |
| 160 | 160 | */ |
| 161 | - public function iJobClassificationSelect($value,$field) |
|
| 161 | + public function iJobClassificationSelect($value, $field) |
|
| 162 | 162 | { |
| 163 | 163 | $field = Inflector::camelize($field); |
| 164 | 164 | |
@@ -174,18 +174,18 @@ discard block |
||
| 174 | 174 | 'employmentTypes' => "select#classifications-employmentTypes", |
| 175 | 175 | ]; |
| 176 | 176 | |
| 177 | - if(!isset($mapSelect2[$field])){ |
|
| 177 | + if (!isset($mapSelect2[$field])) { |
|
| 178 | 178 | throw new \Exception('Undefined field selection value "'.$field.'"'); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $multipleField = $mapMultiple[$field]; |
| 182 | 182 | $page = $this->minkContext->getSession()->getPage(); |
| 183 | - $element = $page->find('css',$mapMultiple[$field]); |
|
| 184 | - if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){ |
|
| 185 | - $this->minkContext->selectOption($value,$multipleField); |
|
| 186 | - }else{ |
|
| 183 | + $element = $page->find('css', $mapMultiple[$field]); |
|
| 184 | + if (!is_null($element) && $element->getAttribute('multiple') == 'multiple') { |
|
| 185 | + $this->minkContext->selectOption($value, $multipleField); |
|
| 186 | + } else { |
|
| 187 | 187 | $locator = $mapSelect2[$field]; |
| 188 | - $this->select2Context->iFillInSelect2Field($locator,$value); |
|
| 188 | + $this->select2Context->iFillInSelect2Field($locator, $value); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
@@ -209,62 +209,62 @@ discard block |
||
| 209 | 209 | * @When I have a :status job with the following: |
| 210 | 210 | * @param TableNode $fields |
| 211 | 211 | */ |
| 212 | - public function iHaveAJobWithTheFollowing($status,TableNode $fields) |
|
| 212 | + public function iHaveAJobWithTheFollowing($status, TableNode $fields) |
|
| 213 | 213 | { |
| 214 | 214 | $normalizedField = [ |
| 215 | 215 | 'template' => 'modern', |
| 216 | 216 | ]; |
| 217 | - foreach($fields->getRowsHash() as $field => $value){ |
|
| 217 | + foreach ($fields->getRowsHash() as $field => $value) { |
|
| 218 | 218 | $field = Inflector::camelize($field); |
| 219 | - if($field == 'professions' || $field == 'industries'){ |
|
| 220 | - $value = explode(',',$value); |
|
| 219 | + if ($field == 'professions' || $field == 'industries') { |
|
| 220 | + $value = explode(',', $value); |
|
| 221 | 221 | } |
| 222 | 222 | $normalizedField[$field] = $value; |
| 223 | 223 | } |
| 224 | 224 | $jobRepo = $this->getJobRepository(); |
| 225 | 225 | $job = $jobRepo->findOneBy(['title' => $normalizedField['title']]); |
| 226 | - if(!$job instanceof Job){ |
|
| 226 | + if (!$job instanceof Job) { |
|
| 227 | 227 | $job = new Job(); |
| 228 | 228 | $job->setTitle($normalizedField['title']); |
| 229 | 229 | } |
| 230 | - if(isset($normalizedField['user'])){ |
|
| 230 | + if (isset($normalizedField['user'])) { |
|
| 231 | 231 | /* @var $userRepo UserRepository */ |
| 232 | 232 | $user = $this->getUserContext()->getCurrentUser(); |
| 233 | 233 | $jobRepo->getDocumentManager()->refresh($user); |
| 234 | - if($user instanceof User){ |
|
| 234 | + if ($user instanceof User) { |
|
| 235 | 235 | $job->setUser($user); |
| 236 | 236 | $job->setOrganization($user->getOrganization()->getOrganization()); |
| 237 | - }else{ |
|
| 237 | + } else { |
|
| 238 | 238 | throw new \Exception('There is no user with this login:"'.$normalizedField['user'.'"']); |
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - if($status == 'draft'){ |
|
| 242 | + if ($status == 'draft') { |
|
| 243 | 243 | $job->setIsDraft(true); |
| 244 | - }elseif($status == 'published'){ |
|
| 244 | + }elseif ($status == 'published') { |
|
| 245 | 245 | $job->setIsDraft(false); |
| 246 | 246 | $job->setDatePublishStart(new \DateTime()); |
| 247 | 247 | } |
| 248 | 248 | $job->setStatus(Status::ACTIVE); |
| 249 | 249 | |
| 250 | - if(isset($normalizedField['location'])){ |
|
| 251 | - $this->setLocation($job,$normalizedField['location']); |
|
| 250 | + if (isset($normalizedField['location'])) { |
|
| 251 | + $this->setLocation($job, $normalizedField['location']); |
|
| 252 | 252 | } |
| 253 | - if(isset($normalizedField['companyName'])){ |
|
| 253 | + if (isset($normalizedField['companyName'])) { |
|
| 254 | 254 | //$job->setCompany($normalizedField['companyName']); |
| 255 | 255 | } |
| 256 | - if(isset($normalizedField['professions'])){ |
|
| 257 | - $this->addProfessions($job,$normalizedField['professions']); |
|
| 256 | + if (isset($normalizedField['professions'])) { |
|
| 257 | + $this->addProfessions($job, $normalizedField['professions']); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if(isset($normalizedField['industries'])){ |
|
| 261 | - $this->addIndustries($job,$normalizedField['industries']); |
|
| 260 | + if (isset($normalizedField['industries'])) { |
|
| 261 | + $this->addIndustries($job, $normalizedField['industries']); |
|
| 262 | 262 | } |
| 263 | - if(isset($normalizedField['employmentTypes'])){ |
|
| 263 | + if (isset($normalizedField['employmentTypes'])) { |
|
| 264 | 264 | $types = $this->getCategories([$normalizedField['employmentTypes']]); |
| 265 | 265 | $type = array_shift($types); |
| 266 | 266 | $values = $job->getClassifications()->getEmploymentTypes()->getValues(); |
| 267 | - if(!is_array($values) || !in_array($type,$values)){ |
|
| 267 | + if (!is_array($values) || !in_array($type, $values)) { |
|
| 268 | 268 | $job->getClassifications()->getEmploymentTypes()->getItems()->add($type); |
| 269 | 269 | } |
| 270 | 270 | } |
@@ -283,18 +283,18 @@ discard block |
||
| 283 | 283 | $location->fromString($serialized); |
| 284 | 284 | |
| 285 | 285 | $locations = $job->getLocations(); |
| 286 | - if(count($locations)){ |
|
| 286 | + if (count($locations)) { |
|
| 287 | 287 | $locations->clear(); |
| 288 | 288 | } |
| 289 | 289 | $job->getLocations()->add($location); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - private function addProfessions(Job &$job,$terms) |
|
| 292 | + private function addProfessions(Job &$job, $terms) |
|
| 293 | 293 | { |
| 294 | 294 | $professions = $this->getCategories($terms); |
| 295 | - foreach($professions as $profession){ |
|
| 295 | + foreach ($professions as $profession) { |
|
| 296 | 296 | $values = $job->getClassifications()->getProfessions()->getValues(); |
| 297 | - if(!is_array($values) || !in_array($profession,$values)){ |
|
| 297 | + if (!is_array($values) || !in_array($profession, $values)) { |
|
| 298 | 298 | $job->getClassifications()->getProfessions()->getItems()->add($profession); |
| 299 | 299 | } |
| 300 | 300 | } |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | private function addIndustries(Job &$job, $terms) |
| 304 | 304 | { |
| 305 | 305 | $industries = $this->getCategories($terms); |
| 306 | - foreach($industries as $industry){ |
|
| 306 | + foreach ($industries as $industry) { |
|
| 307 | 307 | $values = $job->getClassifications()->getIndustries()->getValues(); |
| 308 | - if(!is_array($values) || !in_array($industry,$values)){ |
|
| 308 | + if (!is_array($values) || !in_array($industry, $values)) { |
|
| 309 | 309 | $job->getClassifications()->getIndustries()->getItems()->add($industry); |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | $job = $repo->findDraft($user); |
| 342 | 342 | |
| 343 | - if(is_null($job)){ |
|
| 343 | + if (is_null($job)) { |
|
| 344 | 344 | $job = new Job(); |
| 345 | 345 | $job |
| 346 | 346 | ->setUser($user) |
@@ -14,26 +14,26 @@ |
||
| 14 | 14 | |
| 15 | 15 | class SettingsContext implements Context |
| 16 | 16 | { |
| 17 | - use CommonContextTrait; |
|
| 17 | + use CommonContextTrait; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @Given I go to settings page |
|
| 21 | - */ |
|
| 22 | - public function iGoToSettingsPage() |
|
| 23 | - { |
|
| 24 | - //$this->visit('/settings'); |
|
| 19 | + /** |
|
| 20 | + * @Given I go to settings page |
|
| 21 | + */ |
|
| 22 | + public function iGoToSettingsPage() |
|
| 23 | + { |
|
| 24 | + //$this->visit('/settings'); |
|
| 25 | 25 | $url = $this->buildUrl('lang/settings'); |
| 26 | 26 | $this->visit($url); |
| 27 | - } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @Given I go to email template settings page |
|
| 31 | - */ |
|
| 32 | - public function iGoToEmailTemplatePage() |
|
| 33 | - { |
|
| 34 | - $url = $this->buildUrl('lang/settings',[ |
|
| 35 | - 'module' => 'Applications' |
|
| 29 | + /** |
|
| 30 | + * @Given I go to email template settings page |
|
| 31 | + */ |
|
| 32 | + public function iGoToEmailTemplatePage() |
|
| 33 | + { |
|
| 34 | + $url = $this->buildUrl('lang/settings',[ |
|
| 35 | + 'module' => 'Applications' |
|
| 36 | 36 | ]); |
| 37 | - $this->visit($url); |
|
| 38 | - } |
|
| 37 | + $this->visit($url); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function iGoToEmailTemplatePage() |
| 33 | 33 | { |
| 34 | - $url = $this->buildUrl('lang/settings',[ |
|
| 34 | + $url = $this->buildUrl('lang/settings', [ |
|
| 35 | 35 | 'module' => 'Applications' |
| 36 | 36 | ]); |
| 37 | 37 | $this->visit($url); |
@@ -22,37 +22,37 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class ApplicationContext implements Context |
| 24 | 24 | { |
| 25 | - use CommonContextTrait; |
|
| 25 | + use CommonContextTrait; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @Given I apply for :title job |
|
| 29 | - * |
|
| 30 | - * @param string $title |
|
| 31 | - * @throws \Exception when the titled job not exists |
|
| 32 | - */ |
|
| 33 | - public function iApplyAJob($title) |
|
| 34 | - { |
|
| 35 | - /* @var $repo JobRepository */ |
|
| 36 | - $repo = $this->getRepository('Jobs/Job'); |
|
| 37 | - $job = $repo->findOneBy(['title' => $title]); |
|
| 38 | - if(!$job instanceof Job){ |
|
| 39 | - throw new \Exception('There is no job titled: "'.$title.'"'); |
|
| 40 | - } |
|
| 41 | - $job->setApplyId($job->getId()); |
|
| 42 | - $repo->store($job); |
|
| 27 | + /** |
|
| 28 | + * @Given I apply for :title job |
|
| 29 | + * |
|
| 30 | + * @param string $title |
|
| 31 | + * @throws \Exception when the titled job not exists |
|
| 32 | + */ |
|
| 33 | + public function iApplyAJob($title) |
|
| 34 | + { |
|
| 35 | + /* @var $repo JobRepository */ |
|
| 36 | + $repo = $this->getRepository('Jobs/Job'); |
|
| 37 | + $job = $repo->findOneBy(['title' => $title]); |
|
| 38 | + if(!$job instanceof Job){ |
|
| 39 | + throw new \Exception('There is no job titled: "'.$title.'"'); |
|
| 40 | + } |
|
| 41 | + $job->setApplyId($job->getId()); |
|
| 42 | + $repo->store($job); |
|
| 43 | 43 | |
| 44 | - $url = $this->buildUrl('lang/apply',[ |
|
| 45 | - 'applyId' => $job->getApplyId() |
|
| 44 | + $url = $this->buildUrl('lang/apply',[ |
|
| 45 | + 'applyId' => $job->getApplyId() |
|
| 46 | 46 | ]); |
| 47 | - $this->visit($url); |
|
| 48 | - } |
|
| 47 | + $this->visit($url); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @Given I visit job categories |
|
| 52 | - */ |
|
| 53 | - public function visitJobsCategories() |
|
| 54 | - { |
|
| 55 | - $url = '/admin/jobs/categories'; |
|
| 56 | - $this->visit($url); |
|
| 57 | - } |
|
| 50 | + /** |
|
| 51 | + * @Given I visit job categories |
|
| 52 | + */ |
|
| 53 | + public function visitJobsCategories() |
|
| 54 | + { |
|
| 55 | + $url = '/admin/jobs/categories'; |
|
| 56 | + $this->visit($url); |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -35,13 +35,13 @@ |
||
| 35 | 35 | /* @var $repo JobRepository */ |
| 36 | 36 | $repo = $this->getRepository('Jobs/Job'); |
| 37 | 37 | $job = $repo->findOneBy(['title' => $title]); |
| 38 | - if(!$job instanceof Job){ |
|
| 38 | + if (!$job instanceof Job) { |
|
| 39 | 39 | throw new \Exception('There is no job titled: "'.$title.'"'); |
| 40 | 40 | } |
| 41 | 41 | $job->setApplyId($job->getId()); |
| 42 | 42 | $repo->store($job); |
| 43 | 43 | |
| 44 | - $url = $this->buildUrl('lang/apply',[ |
|
| 44 | + $url = $this->buildUrl('lang/apply', [ |
|
| 45 | 45 | 'applyId' => $job->getApplyId() |
| 46 | 46 | ]); |
| 47 | 47 | $this->visit($url); |
@@ -22,23 +22,23 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class CvContext implements Context |
| 24 | 24 | { |
| 25 | - use CommonContextTrait; |
|
| 25 | + use CommonContextTrait; |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @Given I go to manage my resume page |
|
| 30 | - */ |
|
| 31 | - public function iGoToManageResumePage() |
|
| 32 | - { |
|
| 33 | - $url = $this->buildUrl('lang/my-cv'); |
|
| 34 | - $this->visit($url); |
|
| 35 | - } |
|
| 28 | + /** |
|
| 29 | + * @Given I go to manage my resume page |
|
| 30 | + */ |
|
| 31 | + public function iGoToManageResumePage() |
|
| 32 | + { |
|
| 33 | + $url = $this->buildUrl('lang/my-cv'); |
|
| 34 | + $this->visit($url); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @When I click edit on my personal information |
|
| 39 | - */ |
|
| 40 | - public function iClickEditOnPersonalInformations() |
|
| 41 | - { |
|
| 42 | - $this->summaryFormContext->iClickEditOnForm('resumePersonalInformations'); |
|
| 43 | - } |
|
| 37 | + /** |
|
| 38 | + * @When I click edit on my personal information |
|
| 39 | + */ |
|
| 40 | + public function iClickEditOnPersonalInformations() |
|
| 41 | + { |
|
| 42 | + $this->summaryFormContext->iClickEditOnForm('resumePersonalInformations'); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -37,380 +37,380 @@ |
||
| 37 | 37 | { |
| 38 | 38 | use CommonContextTrait; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var User[] |
|
| 42 | - */ |
|
| 43 | - static private $users = []; |
|
| 40 | + /** |
|
| 41 | + * @var User[] |
|
| 42 | + */ |
|
| 43 | + static private $users = []; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var UserRepository |
|
| 47 | - */ |
|
| 48 | - static private $userRepo; |
|
| 45 | + /** |
|
| 46 | + * @var UserRepository |
|
| 47 | + */ |
|
| 48 | + static private $userRepo; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 53 | - static private $currentSession; |
|
| 50 | + /** |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | + static private $currentSession; |
|
| 54 | 54 | |
| 55 | - private $socialLoginInfo = []; |
|
| 55 | + private $socialLoginInfo = []; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var UserInterface |
|
| 59 | - */ |
|
| 60 | - private $loggedInUser; |
|
| 57 | + /** |
|
| 58 | + * @var UserInterface |
|
| 59 | + */ |
|
| 60 | + private $loggedInUser; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @var User |
| 64 | 64 | */ |
| 65 | 65 | protected $currentUser; |
| 66 | 66 | |
| 67 | - public function __construct($parameters=[]) |
|
| 68 | - { |
|
| 69 | - $defaultLoginInfo = [ |
|
| 70 | - 'facebook' => [ |
|
| 71 | - 'email' => getenv('FACEBOOK_USER_EMAIL'), |
|
| 72 | - 'pass' => getenv('FACEBOOK_USER_PASSWORD') |
|
| 73 | - ], |
|
| 74 | - 'linkedin' => [ |
|
| 75 | - 'session_key-login' => getenv('LINKEDIN_USER_EMAIL'), |
|
| 76 | - 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
|
| 77 | - ], |
|
| 78 | - ]; |
|
| 79 | - $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
| 80 | - $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
| 81 | - } |
|
| 67 | + public function __construct($parameters=[]) |
|
| 68 | + { |
|
| 69 | + $defaultLoginInfo = [ |
|
| 70 | + 'facebook' => [ |
|
| 71 | + 'email' => getenv('FACEBOOK_USER_EMAIL'), |
|
| 72 | + 'pass' => getenv('FACEBOOK_USER_PASSWORD') |
|
| 73 | + ], |
|
| 74 | + 'linkedin' => [ |
|
| 75 | + 'session_key-login' => getenv('LINKEDIN_USER_EMAIL'), |
|
| 76 | + 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
|
| 77 | + ], |
|
| 78 | + ]; |
|
| 79 | + $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
| 80 | + $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @AfterSuite |
|
| 85 | - * @param AfterSuiteScope $scope |
|
| 86 | - */ |
|
| 87 | - static public function afterSuite(AfterSuiteScope $scope) |
|
| 88 | - { |
|
| 89 | - $repo = static::$userRepo; |
|
| 90 | - foreach(static::$users as $user){ |
|
| 91 | - if($repo->findByLogin($user->getLogin())){ |
|
| 92 | - try{ |
|
| 93 | - JobContext::removeJobByUser($user); |
|
| 94 | - $repo->remove($user,true); |
|
| 95 | - $repo->getDocumentManager()->refresh($user); |
|
| 96 | - }catch (\Exception $e){ |
|
| 83 | + /** |
|
| 84 | + * @AfterSuite |
|
| 85 | + * @param AfterSuiteScope $scope |
|
| 86 | + */ |
|
| 87 | + static public function afterSuite(AfterSuiteScope $scope) |
|
| 88 | + { |
|
| 89 | + $repo = static::$userRepo; |
|
| 90 | + foreach(static::$users as $user){ |
|
| 91 | + if($repo->findByLogin($user->getLogin())){ |
|
| 92 | + try{ |
|
| 93 | + JobContext::removeJobByUser($user); |
|
| 94 | + $repo->remove($user,true); |
|
| 95 | + $repo->getDocumentManager()->refresh($user); |
|
| 96 | + }catch (\Exception $e){ |
|
| 97 | 97 | |
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @BeforeScenario |
|
| 105 | - * @param BeforeScenarioScope $scope |
|
| 106 | - */ |
|
| 107 | - public function beforeScenario(BeforeScenarioScope $scope) |
|
| 108 | - { |
|
| 109 | - $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
| 110 | - $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
| 111 | - static::$userRepo = $this->getUserRepository(); |
|
| 112 | - } |
|
| 103 | + /** |
|
| 104 | + * @BeforeScenario |
|
| 105 | + * @param BeforeScenarioScope $scope |
|
| 106 | + */ |
|
| 107 | + public function beforeScenario(BeforeScenarioScope $scope) |
|
| 108 | + { |
|
| 109 | + $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
| 110 | + $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
| 111 | + static::$userRepo = $this->getUserRepository(); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * @When I fill in login form with :provider user |
|
| 116 | - */ |
|
| 117 | - public function iSignInWithSocialUser($provider) |
|
| 118 | - { |
|
| 119 | - $provider = strtolower($provider); |
|
| 120 | - $mink = $this->minkContext; |
|
| 121 | - foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
| 122 | - $mink->fillField($field,$value); |
|
| 123 | - } |
|
| 124 | - } |
|
| 114 | + /** |
|
| 115 | + * @When I fill in login form with :provider user |
|
| 116 | + */ |
|
| 117 | + public function iSignInWithSocialUser($provider) |
|
| 118 | + { |
|
| 119 | + $provider = strtolower($provider); |
|
| 120 | + $mink = $this->minkContext; |
|
| 121 | + foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
| 122 | + $mink->fillField($field,$value); |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * @Given I am logged in as a recruiter |
|
| 128 | - * @Given I am logged in as a recruiter with :organization as organization |
|
| 129 | - */ |
|
| 130 | - public function iAmLoggedInAsARecruiter($organization=null) |
|
| 131 | - { |
|
| 132 | - $user = $this->thereIsAUserIdentifiedBy( |
|
| 133 | - '[email protected]', |
|
| 134 | - 'test',User::ROLE_RECRUITER, |
|
| 135 | - 'Test Recruiter', |
|
| 136 | - $organization |
|
| 137 | - ); |
|
| 138 | - $this->startLogin($user,'test'); |
|
| 139 | - } |
|
| 126 | + /** |
|
| 127 | + * @Given I am logged in as a recruiter |
|
| 128 | + * @Given I am logged in as a recruiter with :organization as organization |
|
| 129 | + */ |
|
| 130 | + public function iAmLoggedInAsARecruiter($organization=null) |
|
| 131 | + { |
|
| 132 | + $user = $this->thereIsAUserIdentifiedBy( |
|
| 133 | + '[email protected]', |
|
| 134 | + 'test',User::ROLE_RECRUITER, |
|
| 135 | + 'Test Recruiter', |
|
| 136 | + $organization |
|
| 137 | + ); |
|
| 138 | + $this->startLogin($user,'test'); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * @Given I don't have :login user |
|
| 143 | - * @param string $login |
|
| 144 | - */ |
|
| 145 | - public function iDonTHaveUser($login) |
|
| 146 | - { |
|
| 147 | - $repo = $this->getUserRepository(); |
|
| 148 | - $user=$repo->findByLogin($login); |
|
| 149 | - if($user instanceof UserInterface){ |
|
| 150 | - $repo->remove($user,true); |
|
| 151 | - } |
|
| 152 | - } |
|
| 141 | + /** |
|
| 142 | + * @Given I don't have :login user |
|
| 143 | + * @param string $login |
|
| 144 | + */ |
|
| 145 | + public function iDonTHaveUser($login) |
|
| 146 | + { |
|
| 147 | + $repo = $this->getUserRepository(); |
|
| 148 | + $user=$repo->findByLogin($login); |
|
| 149 | + if($user instanceof UserInterface){ |
|
| 150 | + $repo->remove($user,true); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * @Given I have a :role with the following: |
|
| 156 | - * @param $role |
|
| 157 | - * @param TableNode $fields |
|
| 158 | - */ |
|
| 159 | - public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
| 160 | - { |
|
| 161 | - $normalizedFields = [ |
|
| 162 | - 'login' => '[email protected]', |
|
| 163 | - 'fullname' => 'Test Login', |
|
| 164 | - 'role' => User::ROLE_USER, |
|
| 165 | - 'password' => 'test', |
|
| 166 | - 'organization' => 'Cross Solution' |
|
| 167 | - ]; |
|
| 168 | - foreach($fields->getRowsHash() as $field=>$value){ |
|
| 169 | - $field = Inflector::camelize($field); |
|
| 170 | - $normalizedFields[$field] = $value; |
|
| 171 | - } |
|
| 154 | + /** |
|
| 155 | + * @Given I have a :role with the following: |
|
| 156 | + * @param $role |
|
| 157 | + * @param TableNode $fields |
|
| 158 | + */ |
|
| 159 | + public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
| 160 | + { |
|
| 161 | + $normalizedFields = [ |
|
| 162 | + 'login' => '[email protected]', |
|
| 163 | + 'fullname' => 'Test Login', |
|
| 164 | + 'role' => User::ROLE_USER, |
|
| 165 | + 'password' => 'test', |
|
| 166 | + 'organization' => 'Cross Solution' |
|
| 167 | + ]; |
|
| 168 | + foreach($fields->getRowsHash() as $field=>$value){ |
|
| 169 | + $field = Inflector::camelize($field); |
|
| 170 | + $normalizedFields[$field] = $value; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $this->currentUser = $this->thereIsAUserIdentifiedBy( |
|
| 174 | - $normalizedFields['login'], |
|
| 175 | - $normalizedFields['password'], |
|
| 176 | - $role, |
|
| 177 | - $normalizedFields['fullname'], |
|
| 178 | - $normalizedFields['organization'] |
|
| 179 | - ); |
|
| 180 | - } |
|
| 173 | + $this->currentUser = $this->thereIsAUserIdentifiedBy( |
|
| 174 | + $normalizedFields['login'], |
|
| 175 | + $normalizedFields['password'], |
|
| 176 | + $role, |
|
| 177 | + $normalizedFields['fullname'], |
|
| 178 | + $normalizedFields['organization'] |
|
| 179 | + ); |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * @Given I am logged in as an administrator |
|
| 184 | - */ |
|
| 185 | - public function iAmLoggedInAsAnAdmin() |
|
| 186 | - { |
|
| 187 | - $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
| 188 | - $this->startLogin($user,'test'); |
|
| 189 | - } |
|
| 182 | + /** |
|
| 183 | + * @Given I am logged in as an administrator |
|
| 184 | + */ |
|
| 185 | + public function iAmLoggedInAsAnAdmin() |
|
| 186 | + { |
|
| 187 | + $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
| 188 | + $this->startLogin($user,'test'); |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - private function startLogin(UserInterface $user, $password) |
|
| 192 | - { |
|
| 193 | - $currentUser = $this->currentUser; |
|
| 194 | - if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
| 195 | - $this->iWantToLogIn(); |
|
| 196 | - $this->iSpecifyTheUsernameAs($user->getLogin()); |
|
| 197 | - $this->iSpecifyThePasswordAs($password); |
|
| 198 | - $this->iLogIn(); |
|
| 199 | - $this->currentUser = $user; |
|
| 200 | - } |
|
| 201 | - } |
|
| 191 | + private function startLogin(UserInterface $user, $password) |
|
| 192 | + { |
|
| 193 | + $currentUser = $this->currentUser; |
|
| 194 | + if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
| 195 | + $this->iWantToLogIn(); |
|
| 196 | + $this->iSpecifyTheUsernameAs($user->getLogin()); |
|
| 197 | + $this->iSpecifyThePasswordAs($password); |
|
| 198 | + $this->iLogIn(); |
|
| 199 | + $this->currentUser = $user; |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - /** |
|
| 204 | - * @return UserRepository |
|
| 205 | - */ |
|
| 206 | - public function getUserRepository() |
|
| 207 | - { |
|
| 208 | - return $this->coreContext->getRepositories()->get('Auth\Entity\User'); |
|
| 209 | - } |
|
| 203 | + /** |
|
| 204 | + * @return UserRepository |
|
| 205 | + */ |
|
| 206 | + public function getUserRepository() |
|
| 207 | + { |
|
| 208 | + return $this->coreContext->getRepositories()->get('Auth\Entity\User'); |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - /** |
|
| 212 | - * @Given there is a user :email identified by :password |
|
| 213 | - */ |
|
| 214 | - public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
| 215 | - { |
|
| 216 | - $repo = $this->getUserRepository(); |
|
| 211 | + /** |
|
| 212 | + * @Given there is a user :email identified by :password |
|
| 213 | + */ |
|
| 214 | + public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
| 215 | + { |
|
| 216 | + $repo = $this->getUserRepository(); |
|
| 217 | 217 | |
| 218 | - if(!is_object($user=$repo->findByEmail($email))){ |
|
| 219 | - $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
| 220 | - } |
|
| 218 | + if(!is_object($user=$repo->findByEmail($email))){ |
|
| 219 | + $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - if(!is_null($organization)){ |
|
| 223 | - $this->iHaveMainOrganization($user,$organization); |
|
| 224 | - } |
|
| 225 | - $this->addCreatedUser($user); |
|
| 226 | - return $user; |
|
| 227 | - } |
|
| 222 | + if(!is_null($organization)){ |
|
| 223 | + $this->iHaveMainOrganization($user,$organization); |
|
| 224 | + } |
|
| 225 | + $this->addCreatedUser($user); |
|
| 226 | + return $user; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * @param $email |
|
| 231 | - * @param $password |
|
| 232 | - * @param $username |
|
| 233 | - * @param string $fullname |
|
| 234 | - * @param string $role |
|
| 235 | - * |
|
| 236 | - * @return \Auth\Entity\UserInterface |
|
| 237 | - */ |
|
| 238 | - public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
| 239 | - { |
|
| 240 | - /* @var Register $service */ |
|
| 241 | - /* @var User $user */ |
|
| 242 | - $repo = $this->getUserRepository(); |
|
| 243 | - $user = $repo->create([]); |
|
| 244 | - $user->setLogin($email); |
|
| 245 | - $user->setPassword($password); |
|
| 246 | - $user->setRole($role); |
|
| 247 | - $settings = $user->getSettings('Applications'); |
|
| 229 | + /** |
|
| 230 | + * @param $email |
|
| 231 | + * @param $password |
|
| 232 | + * @param $username |
|
| 233 | + * @param string $fullname |
|
| 234 | + * @param string $role |
|
| 235 | + * |
|
| 236 | + * @return \Auth\Entity\UserInterface |
|
| 237 | + */ |
|
| 238 | + public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
| 239 | + { |
|
| 240 | + /* @var Register $service */ |
|
| 241 | + /* @var User $user */ |
|
| 242 | + $repo = $this->getUserRepository(); |
|
| 243 | + $user = $repo->create([]); |
|
| 244 | + $user->setLogin($email); |
|
| 245 | + $user->setPassword($password); |
|
| 246 | + $user->setRole($role); |
|
| 247 | + $settings = $user->getSettings('Applications'); |
|
| 248 | 248 | |
| 249 | - $expFullName = explode(' ',$fullname); |
|
| 250 | - $info = $user->getInfo(); |
|
| 251 | - $info->setFirstName(array_shift($expFullName)); |
|
| 252 | - $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
| 253 | - $info->setEmail($email); |
|
| 254 | - $info->setEmailVerified(true); |
|
| 255 | - $repo->store($user); |
|
| 249 | + $expFullName = explode(' ',$fullname); |
|
| 250 | + $info = $user->getInfo(); |
|
| 251 | + $info->setFirstName(array_shift($expFullName)); |
|
| 252 | + $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
| 253 | + $info->setEmail($email); |
|
| 254 | + $info->setEmailVerified(true); |
|
| 255 | + $repo->store($user); |
|
| 256 | 256 | |
| 257 | - $repo->getDocumentManager()->refresh($user); |
|
| 257 | + $repo->getDocumentManager()->refresh($user); |
|
| 258 | 258 | |
| 259 | - $eventArgs = new LifecycleEventArgs($user, $repo->getDocumentManager()); |
|
| 260 | - $repo->getDocumentManager()->getEventManager()->dispatchEvent( |
|
| 261 | - Events::postLoad, |
|
| 262 | - $eventArgs |
|
| 263 | - ); |
|
| 259 | + $eventArgs = new LifecycleEventArgs($user, $repo->getDocumentManager()); |
|
| 260 | + $repo->getDocumentManager()->getEventManager()->dispatchEvent( |
|
| 261 | + Events::postLoad, |
|
| 262 | + $eventArgs |
|
| 263 | + ); |
|
| 264 | 264 | |
| 265 | - return $user; |
|
| 266 | - } |
|
| 265 | + return $user; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * @When I have :organization as my main organization |
|
| 270 | - * @param $orgName |
|
| 271 | - */ |
|
| 272 | - public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
| 273 | - { |
|
| 274 | - /* @var $repoOrganization OrganizationRepository */ |
|
| 275 | - $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
|
| 276 | - $organization=$repoOrganization->findByName($orgName); |
|
| 277 | - if(!$organization instanceof Organization){ |
|
| 278 | - $organization = new Organization(); |
|
| 279 | - $organizationName = new OrganizationName($orgName); |
|
| 280 | - $organization->setOrganizationName($organizationName); |
|
| 281 | - $permissions = $organization->getPermissions(); |
|
| 282 | - $permissions->grant($user,Permissions::PERMISSION_ALL); |
|
| 283 | - }else { |
|
| 284 | - $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL); |
|
| 285 | - } |
|
| 286 | - $organization->setUser($user); |
|
| 287 | - $repoOrganization->store($organization); |
|
| 288 | - $repoOrganization->getDocumentManager()->refresh($organization); |
|
| 289 | - } |
|
| 268 | + /** |
|
| 269 | + * @When I have :organization as my main organization |
|
| 270 | + * @param $orgName |
|
| 271 | + */ |
|
| 272 | + public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
| 273 | + { |
|
| 274 | + /* @var $repoOrganization OrganizationRepository */ |
|
| 275 | + $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
|
| 276 | + $organization=$repoOrganization->findByName($orgName); |
|
| 277 | + if(!$organization instanceof Organization){ |
|
| 278 | + $organization = new Organization(); |
|
| 279 | + $organizationName = new OrganizationName($orgName); |
|
| 280 | + $organization->setOrganizationName($organizationName); |
|
| 281 | + $permissions = $organization->getPermissions(); |
|
| 282 | + $permissions->grant($user,Permissions::PERMISSION_ALL); |
|
| 283 | + }else { |
|
| 284 | + $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL); |
|
| 285 | + } |
|
| 286 | + $organization->setUser($user); |
|
| 287 | + $repoOrganization->store($organization); |
|
| 288 | + $repoOrganization->getDocumentManager()->refresh($organization); |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - /** |
|
| 292 | - * @When I want to log in |
|
| 293 | - */ |
|
| 294 | - public function iWantToLogIn() |
|
| 295 | - { |
|
| 296 | - $session = $this->minkContext->getSession(); |
|
| 297 | - $url = $this->buildUrl('lang/auth'); |
|
| 298 | - $session->visit($url); |
|
| 299 | - } |
|
| 291 | + /** |
|
| 292 | + * @When I want to log in |
|
| 293 | + */ |
|
| 294 | + public function iWantToLogIn() |
|
| 295 | + { |
|
| 296 | + $session = $this->minkContext->getSession(); |
|
| 297 | + $url = $this->buildUrl('lang/auth'); |
|
| 298 | + $session->visit($url); |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - /** |
|
| 302 | - * @When I specify the username as :username |
|
| 303 | - */ |
|
| 304 | - public function iSpecifyTheUsernameAs($username) |
|
| 305 | - { |
|
| 306 | - $this->minkContext->fillField('Login name',$username); |
|
| 307 | - } |
|
| 301 | + /** |
|
| 302 | + * @When I specify the username as :username |
|
| 303 | + */ |
|
| 304 | + public function iSpecifyTheUsernameAs($username) |
|
| 305 | + { |
|
| 306 | + $this->minkContext->fillField('Login name',$username); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - /** |
|
| 310 | - * @When I specify the password as :password |
|
| 311 | - */ |
|
| 312 | - public function iSpecifyThePasswordAs($password) |
|
| 313 | - { |
|
| 314 | - $this->minkContext->fillField('Password',$password); |
|
| 315 | - } |
|
| 309 | + /** |
|
| 310 | + * @When I specify the password as :password |
|
| 311 | + */ |
|
| 312 | + public function iSpecifyThePasswordAs($password) |
|
| 313 | + { |
|
| 314 | + $this->minkContext->fillField('Password',$password); |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * @Given I am logged in as :username identified by :password |
|
| 319 | - */ |
|
| 320 | - public function iAmLoggedInAsIdentifiedBy($username, $password) |
|
| 321 | - { |
|
| 322 | - $repo = $this->getUserRepository(); |
|
| 323 | - $user = $repo->findByLogin($username); |
|
| 317 | + /** |
|
| 318 | + * @Given I am logged in as :username identified by :password |
|
| 319 | + */ |
|
| 320 | + public function iAmLoggedInAsIdentifiedBy($username, $password) |
|
| 321 | + { |
|
| 322 | + $repo = $this->getUserRepository(); |
|
| 323 | + $user = $repo->findByLogin($username); |
|
| 324 | 324 | |
| 325 | - if(!$user instanceof User){ |
|
| 326 | - throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
| 327 | - } |
|
| 328 | - $this->iWantToLogIn(); |
|
| 329 | - $this->iSpecifyTheUsernameAs($username); |
|
| 330 | - $this->iSpecifyThePasswordAs($password); |
|
| 331 | - $this->iLogIn(); |
|
| 325 | + if(!$user instanceof User){ |
|
| 326 | + throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
| 327 | + } |
|
| 328 | + $this->iWantToLogIn(); |
|
| 329 | + $this->iSpecifyTheUsernameAs($username); |
|
| 330 | + $this->iSpecifyThePasswordAs($password); |
|
| 331 | + $this->iLogIn(); |
|
| 332 | 332 | $this->currentUser = $user; |
| 333 | - } |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * @When I log in |
|
| 337 | - */ |
|
| 338 | - public function iLogIn() |
|
| 339 | - { |
|
| 340 | - $this->minkContext->pressButton('login'); |
|
| 341 | - } |
|
| 335 | + /** |
|
| 336 | + * @When I log in |
|
| 337 | + */ |
|
| 338 | + public function iLogIn() |
|
| 339 | + { |
|
| 340 | + $this->minkContext->pressButton('login'); |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - /** |
|
| 344 | - * @When I press logout link |
|
| 345 | - */ |
|
| 346 | - public function iPressLogoutLink() |
|
| 347 | - { |
|
| 348 | - $url = $this->buildUrl('auth-logout'); |
|
| 349 | - $this->visit($url); |
|
| 350 | - } |
|
| 343 | + /** |
|
| 344 | + * @When I press logout link |
|
| 345 | + */ |
|
| 346 | + public function iPressLogoutLink() |
|
| 347 | + { |
|
| 348 | + $url = $this->buildUrl('auth-logout'); |
|
| 349 | + $this->visit($url); |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - /** |
|
| 353 | - * @Given I log in with username :username and password :password |
|
| 354 | - */ |
|
| 355 | - public function iLogInWith($username, $password) |
|
| 356 | - { |
|
| 357 | - $repo = $this->getUserRepository(); |
|
| 358 | - $user = $repo->findByLogin($username); |
|
| 359 | - $this->iWantToLogIn(); |
|
| 360 | - $this->iSpecifyTheUsernameAs($username); |
|
| 361 | - $this->iSpecifyThePasswordAs($password); |
|
| 362 | - $this->iLogIn(); |
|
| 363 | - $this->loggedInUser = $user; |
|
| 364 | - } |
|
| 352 | + /** |
|
| 353 | + * @Given I log in with username :username and password :password |
|
| 354 | + */ |
|
| 355 | + public function iLogInWith($username, $password) |
|
| 356 | + { |
|
| 357 | + $repo = $this->getUserRepository(); |
|
| 358 | + $user = $repo->findByLogin($username); |
|
| 359 | + $this->iWantToLogIn(); |
|
| 360 | + $this->iSpecifyTheUsernameAs($username); |
|
| 361 | + $this->iSpecifyThePasswordAs($password); |
|
| 362 | + $this->iLogIn(); |
|
| 363 | + $this->loggedInUser = $user; |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | - /** |
|
| 367 | - * @When I go to profile page |
|
| 368 | - */ |
|
| 369 | - public function iGoToProfilePage() |
|
| 370 | - { |
|
| 371 | - $url = $this->buildUrl('lang/my'); |
|
| 372 | - $this->visit($url); |
|
| 373 | - } |
|
| 366 | + /** |
|
| 367 | + * @When I go to profile page |
|
| 368 | + */ |
|
| 369 | + public function iGoToProfilePage() |
|
| 370 | + { |
|
| 371 | + $url = $this->buildUrl('lang/my'); |
|
| 372 | + $this->visit($url); |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - /** |
|
| 376 | - * @Given there is a user with the following: |
|
| 377 | - */ |
|
| 378 | - public function thereIsAUserWithTheFollowing(TableNode $table) |
|
| 379 | - { |
|
| 380 | - $repo = $this->getUserRepository(); |
|
| 381 | - $data = $table->getRowsHash(); |
|
| 382 | - $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
| 383 | - $password = isset($data['password']) ? $data['password']:'test'; |
|
| 384 | - $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
| 385 | - $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
| 375 | + /** |
|
| 376 | + * @Given there is a user with the following: |
|
| 377 | + */ |
|
| 378 | + public function thereIsAUserWithTheFollowing(TableNode $table) |
|
| 379 | + { |
|
| 380 | + $repo = $this->getUserRepository(); |
|
| 381 | + $data = $table->getRowsHash(); |
|
| 382 | + $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
| 383 | + $password = isset($data['password']) ? $data['password']:'test'; |
|
| 384 | + $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
| 385 | + $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
| 386 | 386 | |
| 387 | - if(!is_object($user=$repo->findByLogin($email))){ |
|
| 388 | - $user = $this->createUser($email,$password,$role,$fullname); |
|
| 389 | - } |
|
| 390 | - $this->currentUser = $user; |
|
| 391 | - $this->addCreatedUser($user); |
|
| 392 | - } |
|
| 387 | + if(!is_object($user=$repo->findByLogin($email))){ |
|
| 388 | + $user = $this->createUser($email,$password,$role,$fullname); |
|
| 389 | + } |
|
| 390 | + $this->currentUser = $user; |
|
| 391 | + $this->addCreatedUser($user); |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - private function addCreatedUser(UserInterface $user) |
|
| 395 | - { |
|
| 396 | - if(!in_array($user,static::$users)){ |
|
| 397 | - static::$users[] = $user; |
|
| 398 | - } |
|
| 399 | - } |
|
| 394 | + private function addCreatedUser(UserInterface $user) |
|
| 395 | + { |
|
| 396 | + if(!in_array($user,static::$users)){ |
|
| 397 | + static::$users[] = $user; |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | - /** |
|
| 402 | - * @When I want to change my password |
|
| 403 | - */ |
|
| 404 | - public function iWantToChangeMyPassword() |
|
| 405 | - { |
|
| 406 | - $url = $this->buildUrl('lang/my-password'); |
|
| 407 | - $this->visit($url); |
|
| 408 | - } |
|
| 401 | + /** |
|
| 402 | + * @When I want to change my password |
|
| 403 | + */ |
|
| 404 | + public function iWantToChangeMyPassword() |
|
| 405 | + { |
|
| 406 | + $url = $this->buildUrl('lang/my-password'); |
|
| 407 | + $this->visit($url); |
|
| 408 | + } |
|
| 409 | 409 | |
| 410 | 410 | /** |
| 411 | 411 | * @return User |
| 412 | 412 | */ |
| 413 | - public function getCurrentUser() |
|
| 413 | + public function getCurrentUser() |
|
| 414 | 414 | { |
| 415 | 415 | return $this->currentUser; |
| 416 | 416 | } |
@@ -27,48 +27,48 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | class LazyControllerFactory implements AbstractFactoryInterface |
| 29 | 29 | { |
| 30 | - protected $aliases = [ |
|
| 31 | - FormElementManager::class => 'FormElementManager', |
|
| 32 | - ValidatorPluginManager::class => 'ValidatorManager', |
|
| 33 | - Translator::class => 'translator', |
|
| 34 | - ModuleManagerInterface::class => 'ModuleManager', |
|
| 35 | - EventManager::class => 'Core/EventManager', |
|
| 30 | + protected $aliases = [ |
|
| 31 | + FormElementManager::class => 'FormElementManager', |
|
| 32 | + ValidatorPluginManager::class => 'ValidatorManager', |
|
| 33 | + Translator::class => 'translator', |
|
| 34 | + ModuleManagerInterface::class => 'ModuleManager', |
|
| 35 | + EventManager::class => 'Core/EventManager', |
|
| 36 | 36 | RepositoryService::class => 'repositories', |
| 37 | - ]; |
|
| 37 | + ]; |
|
| 38 | 38 | |
| 39 | - public function canCreate( ContainerInterface $container, $requestedName ) |
|
| 40 | - { |
|
| 41 | - return strstr( $requestedName,'\Controller') !== false; |
|
| 42 | - } |
|
| 39 | + public function canCreate( ContainerInterface $container, $requestedName ) |
|
| 40 | + { |
|
| 41 | + return strstr( $requestedName,'\Controller') !== false; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
| 45 | - { |
|
| 44 | + public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
| 45 | + { |
|
| 46 | 46 | $className = $this->getClassName($requestedName); |
| 47 | - $class = new \ReflectionClass($className); |
|
| 47 | + $class = new \ReflectionClass($className); |
|
| 48 | 48 | |
| 49 | - if( $constructor = $class->getConstructor() ) |
|
| 50 | - { |
|
| 51 | - if( $params = $constructor->getParameters() ) |
|
| 52 | - { |
|
| 53 | - $constructorArgs = []; |
|
| 54 | - foreach( $params as $p ) |
|
| 55 | - { |
|
| 56 | - $serviceName = ''; |
|
| 57 | - if( $p->getClass() ) { |
|
| 58 | - $serviceName = $p->getClass()->getName(); |
|
| 59 | - if (array_key_exists($serviceName, $this->aliases)) { |
|
| 60 | - $serviceName = $this->aliases[$serviceName]; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - else{ |
|
| 64 | - if( $p->getName() == 'config' ){ |
|
| 49 | + if( $constructor = $class->getConstructor() ) |
|
| 50 | + { |
|
| 51 | + if( $params = $constructor->getParameters() ) |
|
| 52 | + { |
|
| 53 | + $constructorArgs = []; |
|
| 54 | + foreach( $params as $p ) |
|
| 55 | + { |
|
| 56 | + $serviceName = ''; |
|
| 57 | + if( $p->getClass() ) { |
|
| 58 | + $serviceName = $p->getClass()->getName(); |
|
| 59 | + if (array_key_exists($serviceName, $this->aliases)) { |
|
| 60 | + $serviceName = $this->aliases[$serviceName]; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + else{ |
|
| 64 | + if( $p->getName() == 'config' ){ |
|
| 65 | 65 | $serviceName = 'config'; |
| 66 | 66 | } |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - if(!$container->has($serviceName)){ |
|
| 70 | - throw new ServiceNotCreatedException(sprintf( |
|
| 71 | - 'Can\'t create constructor argument "%s" for service "%s"', |
|
| 69 | + if(!$container->has($serviceName)){ |
|
| 70 | + throw new ServiceNotCreatedException(sprintf( |
|
| 71 | + 'Can\'t create constructor argument "%s" for service "%s"', |
|
| 72 | 72 | $p->getName(),$requestedName |
| 73 | 73 | )); |
| 74 | 74 | } |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | echo __CLASS__ . " couldn't create an instance of {$p->getName()} to satisfy the constructor for $requestedName."; |
| 80 | 80 | exit; |
| 81 | 81 | } |
| 82 | - } |
|
| 83 | - return $class->newInstanceArgs($constructorArgs); |
|
| 84 | - } |
|
| 85 | - } |
|
| 82 | + } |
|
| 83 | + return $class->newInstanceArgs($constructorArgs); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return new $className; |
|
| 88 | - } |
|
| 87 | + return new $className; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Generate class name |
@@ -36,47 +36,47 @@ discard block |
||
| 36 | 36 | RepositoryService::class => 'repositories', |
| 37 | 37 | ]; |
| 38 | 38 | |
| 39 | - public function canCreate( ContainerInterface $container, $requestedName ) |
|
| 39 | + public function canCreate(ContainerInterface $container, $requestedName) |
|
| 40 | 40 | { |
| 41 | - return strstr( $requestedName,'\Controller') !== false; |
|
| 41 | + return strstr($requestedName, '\Controller') !== false; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
| 44 | + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
| 45 | 45 | { |
| 46 | 46 | $className = $this->getClassName($requestedName); |
| 47 | 47 | $class = new \ReflectionClass($className); |
| 48 | 48 | |
| 49 | - if( $constructor = $class->getConstructor() ) |
|
| 49 | + if ($constructor = $class->getConstructor()) |
|
| 50 | 50 | { |
| 51 | - if( $params = $constructor->getParameters() ) |
|
| 51 | + if ($params = $constructor->getParameters()) |
|
| 52 | 52 | { |
| 53 | 53 | $constructorArgs = []; |
| 54 | - foreach( $params as $p ) |
|
| 54 | + foreach ($params as $p) |
|
| 55 | 55 | { |
| 56 | 56 | $serviceName = ''; |
| 57 | - if( $p->getClass() ) { |
|
| 57 | + if ($p->getClass()) { |
|
| 58 | 58 | $serviceName = $p->getClass()->getName(); |
| 59 | 59 | if (array_key_exists($serviceName, $this->aliases)) { |
| 60 | 60 | $serviceName = $this->aliases[$serviceName]; |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | - else{ |
|
| 64 | - if( $p->getName() == 'config' ){ |
|
| 63 | + else { |
|
| 64 | + if ($p->getName() == 'config') { |
|
| 65 | 65 | $serviceName = 'config'; |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if(!$container->has($serviceName)){ |
|
| 69 | + if (!$container->has($serviceName)) { |
|
| 70 | 70 | throw new ServiceNotCreatedException(sprintf( |
| 71 | 71 | 'Can\'t create constructor argument "%s" for service "%s"', |
| 72 | - $p->getName(),$requestedName |
|
| 72 | + $p->getName(), $requestedName |
|
| 73 | 73 | )); |
| 74 | 74 | } |
| 75 | 75 | try { |
| 76 | 76 | $constructorArgs[] = $container->get($serviceName); |
| 77 | 77 | } |
| 78 | 78 | catch (\Exception $x) { |
| 79 | - echo __CLASS__ . " couldn't create an instance of {$p->getName()} to satisfy the constructor for $requestedName."; |
|
| 79 | + echo __CLASS__." couldn't create an instance of {$p->getName()} to satisfy the constructor for $requestedName."; |
|
| 80 | 80 | exit; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | private function getClassName($requestedName) |
| 97 | 97 | { |
| 98 | - $exp = explode('/',$requestedName); |
|
| 98 | + $exp = explode('/', $requestedName); |
|
| 99 | 99 | |
| 100 | - $className = array_shift($exp).'\\Controller\\'.implode('\\',$exp).'Controller'; |
|
| 101 | - if(!class_exists($className)){ |
|
| 100 | + $className = array_shift($exp).'\\Controller\\'.implode('\\', $exp).'Controller'; |
|
| 101 | + if (!class_exists($className)) { |
|
| 102 | 102 | throw new ServiceNotCreatedException( |
| 103 | 103 | sprintf( |
| 104 | 104 | 'Can\'t find correct controller class for "%s"', |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | if (array_key_exists($serviceName, $this->aliases)) { |
| 60 | 60 | $serviceName = $this->aliases[$serviceName]; |
| 61 | 61 | } |
| 62 | - } |
|
| 63 | - else{ |
|
| 62 | + } else{ |
|
| 64 | 63 | if( $p->getName() == 'config' ){ |
| 65 | 64 | $serviceName = 'config'; |
| 66 | 65 | } |
@@ -74,8 +73,7 @@ discard block |
||
| 74 | 73 | } |
| 75 | 74 | try { |
| 76 | 75 | $constructorArgs[] = $container->get($serviceName); |
| 77 | - } |
|
| 78 | - catch (\Exception $x) { |
|
| 76 | + } catch (\Exception $x) { |
|
| 79 | 77 | echo __CLASS__ . " couldn't create an instance of {$p->getName()} to satisfy the constructor for $requestedName."; |
| 80 | 78 | exit; |
| 81 | 79 | } |