Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
"license": "BSD-3-Clause",
"require": {
"php": ">=5.3.1",
"behat/mink-extension": "~2.0@dev",
"qa-tools/qa-tools": "*@dev"
"behat/mink-extension": "~2.0",
"qa-tools/qa-tools": "dev-develop",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I change it to ~1.0? or keep it on dev-develop till we released the new version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can set to ~1.0@dev to allow usage of develop branch because I bet new PageLocator will be used within this package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, committed and pushed.

"mindplay/annotations": "~1.2@dev",
"symfony/yaml": "2.6.4"
},
"require-dev": {
"aik099/coding-standard": "dev-master",
Expand Down
23 changes: 0 additions & 23 deletions example/behat.yml

This file was deleted.

26 changes: 0 additions & 26 deletions example/composer.json

This file was deleted.

25 changes: 0 additions & 25 deletions example/features/bootstrap/MainContext.php

This file was deleted.

10 changes: 0 additions & 10 deletions example/features/test.feature

This file was deleted.

7 changes: 0 additions & 7 deletions example/fixtures/index.html

This file was deleted.

48 changes: 0 additions & 48 deletions example/pages/TestPage.php

This file was deleted.

41 changes: 37 additions & 4 deletions src/QATools/BehatExtension/Context/QAToolsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use Behat\Behat\Context\Context;
use QATools\BehatExtension\QATools;
use QATools\QATools\PageObject\IPageFactory;
use QATools\QATools\PageObject\Page;

class QAToolsContext implements Context, IQAToolsAwareContext
{
Expand All @@ -25,9 +27,23 @@ class QAToolsContext implements Context, IQAToolsAwareContext
protected $qaTools;

/**
* Sets the QA-Tools instance.
* The used page factory.
*
* @param QATools $qa_tools QA-Tools instance.
* @var IPageFactory
*/
protected $pageFactory;

/**
* The current page.
*
* @var Page
*/
protected $page;

/**
* Set QA-Tools instance.
*
* @param QATools $qa_tools Instance of QA-Tools.
*
* @return static
*/
Expand All @@ -38,6 +54,20 @@ public function setQATools(QATools $qa_tools)
return $this;
}

/**
* Set page factory.
*
* @param IPageFactory $page_factory Used page factory.
*
* @return static
*/
public function setPageFactory(IPageFactory $page_factory)
{
$this->pageFactory = $page_factory;

return $this;
}

/**
* BeforeStep hook to init QA-Tools.
*
Expand All @@ -49,6 +79,8 @@ public function initSession()
{
$this->qaTools->init();

$this->pageFactory = $this->qaTools->getPageFactory();

return $this;
}

Expand All @@ -57,14 +89,15 @@ public function initSession()
*
* @param string $page Name of page.
*
* @Given /^I visit the "([^"]+)"$/
* @Given /^the user visits the "([^"]+)"$/
*
* @return void
*/
public function visitPage($page)
{
$page = $this->qaTools->getPage($page);
$page->open();
$this->page = $this->pageFactory->getPage($page);
$this->page->open();
}

}
41 changes: 9 additions & 32 deletions src/QATools/BehatExtension/QATools.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@

use Behat\Mink\Mink;
use Behat\Mink\Session;
use QATools\QATools\HtmlElements\TypifiedPageFactory;
use QATools\QATools\PageObject\Config\Config;
use QATools\QATools\PageObject\Page;
use QATools\QATools\PageObject\IPageFactory;

class QATools
{
Expand Down Expand Up @@ -48,13 +47,6 @@ class QATools
*/
protected $users = array();

/**
* The current active page.
*
* @var Page
*/
protected $activePage;

/**
* Default constructor.
*
Expand Down Expand Up @@ -87,40 +79,25 @@ public function init()
}

/**
* Get page with given name.
*
* @param string $name Name of the page.
* Creates a page factory.
*
* @return Page
* @return IPageFactory
*/
public function getPage($name)
protected function createPageFactory()
{
$class = (isset($this->config['namespace']['pages']) ?
'\\' . $this->config['namespace']['pages'] . '\\' : '') . $name;

$this->activePage = $this->pageFactory->getPage($class);
$page_factory = $this->config['page_factory'];

return $this->activePage;
return new $page_factory($this->session, new Config($this->config['qa_tools']));
}

/**
* Get active page.
*
* @return Page
*/
public function getActivePage()
{
return $this->activePage;
}

/**
* Creates a page factory.
* Get active page factory.
*
* @return IPageFactory
*/
public function createPageFactory()
public function getPageFactory()
{
return new TypifiedPageFactory($this->session, new Config($this->config['qa_tools']));
return $this->pageFactory;
}

}
Loading