forked from sensiolabs/BehatPageObjectExtension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sensiolabs#70 from jakzal/proxies-target-dir
Proxies target dir
- Loading branch information
Showing
14 changed files
with
208 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<?php error_reporting(-1); ?> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
use Behat\Behat\Hook\Scope\BeforeScenarioScope; | ||
use Behat\Behat\Context\Context; | ||
|
||
final class InjectingPageObjectsContext implements Context | ||
{ | ||
/** | ||
* @var BehatRunnerContext|null | ||
*/ | ||
private $behatRunnerContext; | ||
|
||
/** | ||
* @BeforeScenario | ||
*/ | ||
public function gatherContexts(BeforeScenarioScope $scope) | ||
{ | ||
$this->behatRunnerContext = $scope->getEnvironment()->getContext('BehatRunnerContext'); | ||
} | ||
|
||
/** | ||
* @Given a feature with a context file that uses page objects | ||
*/ | ||
public function aFeatureWithAContextFileThatUsesPageObjects() | ||
{ | ||
$this->behatRunnerContext->givenBehatProject('features/fixtures/default/'); | ||
} | ||
|
||
/** | ||
* @Then the proxies should be generated in the :path directory | ||
*/ | ||
public function theProxiesShouldBeGeneratedInTheDirectory($path) | ||
{ | ||
$filesCount = $this->behatRunnerContext->listWorkingDir($path)->count(); | ||
|
||
if ($filesCount < 1) { | ||
throw new \LogicException('Expected at least one proxy to be generated but found none.'); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
features/fixtures/default/features/bootstrap/Page/Element/SearchResultsNavigation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Page\Element; | ||
|
||
use SensioLabs\Behat\PageObjectExtension\PageObject\Element; | ||
|
||
class SearchResultsNavigation extends Element | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $selector = 'div.tabs'; | ||
|
||
/** | ||
* @return boolean | ||
*/ | ||
public function hasTab($name) | ||
{ | ||
return $this->hasLink($name); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
features/fixtures/default/features/bootstrap/Page/Homepage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Page; | ||
|
||
use SensioLabs\Behat\PageObjectExtension\PageObject\Page; | ||
|
||
class Homepage extends Page | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $path = '/'; | ||
} |
46 changes: 46 additions & 0 deletions
46
features/fixtures/default/features/bootstrap/SearchContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
use Behat\Behat\Context\Context; | ||
use Page\Homepage; | ||
use Page\Element\SearchResultsNavigation; | ||
|
||
class SearchContext implements Context | ||
{ | ||
/** | ||
* @var Homepage | ||
*/ | ||
private $homepage; | ||
|
||
/** | ||
* @var SearchResultsNavigation | ||
*/ | ||
private $searchResultsNavigation; | ||
|
||
/** | ||
* @param Homepage $homepage | ||
* @param SearchResultsNavigation $searchResultsNavigation | ||
*/ | ||
public function __construct(Homepage $homepage, SearchResultsNavigation $searchResultsNavigation) | ||
{ | ||
$this->homepage = $homepage; | ||
$this->searchResultsNavigation = $searchResultsNavigation; | ||
} | ||
|
||
/** | ||
* @Given /^I visited the homepage$/ | ||
*/ | ||
public function iVisitedTheHomepage() | ||
{ | ||
$this->homepage->open(); | ||
} | ||
|
||
/** | ||
* @When /^I should not see the "(?P<tab>[^"]*)" tab$/ | ||
*/ | ||
public function iShouldSeeNotTheTab($tab) | ||
{ | ||
if ($this->searchResultsNavigation->hasTab($tab)) { | ||
throw new \LogicException(sprintf('%s tab is present on the page', $tab)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@fixtures | ||
Feature: Search | ||
In order to find lolcats | ||
As a Cat Lover | ||
I want to search the internetz | ||
|
||
Scenario: Searching for lolcats | ||
Given I visited the homepage | ||
Then I should not see the "Images" tab |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters