-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of QAToolsExtension for Behat. | ||
* This file is part of BehatExtension for Behat. | ||
This comment has been minimized.
Sorry, something went wrong.
aik099
Member
|
||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @copyright Michael Geppert <[email protected]> | ||
*/ | ||
|
||
spl_autoload_register(function($class) { | ||
echo 1; | ||
if (false !== strpos($class, 'evangelion1204\\QAToolsExtension')) { | ||
require_once(__DIR__.'/src/'.str_replace('\\', '/', $class).'.php'); | ||
spl_autoload_register(function ($class) { | ||
if ( false !== strpos($class, 'QATools\\BehatExtension') ) { | ||
require_once (__DIR__ . '/src/' . str_replace('\\', '/', $class) . '.php'); | ||
|
||
return true; | ||
} | ||
}, true, false); | ||
|
||
return new evangelion1204\QAToolsExtension\ServiceContainer\Extension; | ||
return new QATools\BehatExtension\ServiceContainer\BehatExtension(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="true" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
strict="true" | ||
verbose="true"> | ||
|
||
<testsuites> | ||
<testsuite name="PageObject"> | ||
<directory>tests/QATools/BehatExtension</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<listeners> | ||
<listener class="\Mockery\Adapter\Phpunit\TestListener"/> | ||
</listeners> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>src/QATools/BehatExtension</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
<?php | ||
/* | ||
* This file is part of QAToolsExtension for Behat. | ||
* This file is part of BehatExtension for Behat. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @copyright Michael Geppert <[email protected]> | ||
*/ | ||
|
||
namespace evangelion1204\QAToolsExtension\Context; | ||
namespace QATools\BehatExtension\Context; | ||
|
||
|
||
use evangelion1204\QAToolsExtension\QATools; | ||
use QATools\BehatExtension\QATools; | ||
|
||
interface IQAToolsAwareContext | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
<?php | ||
/* | ||
* This file is part of QAToolsExtension for Behat. | ||
* This file is part of BehatExtension for Behat. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @copyright Michael Geppert <[email protected]> | ||
*/ | ||
|
||
namespace evangelion1204\QAToolsExtension\Context\Initializer; | ||
namespace QATools\BehatExtension\Context\Initializer; | ||
|
||
|
||
use Behat\Behat\Context\Context; | ||
use Behat\Behat\Context\Initializer\ContextInitializer; | ||
use evangelion1204\QAToolsExtension\Context\IQAToolsAwareContext; | ||
use evangelion1204\QAToolsExtension\QATools; | ||
use QATools\BehatExtension\Context\IQAToolsAwareContext; | ||
use QATools\BehatExtension\QATools; | ||
|
||
class QAToolsInitializer implements ContextInitializer | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
<?php | ||
/* | ||
* This file is part of QAToolsExtension for Behat. | ||
* This file is part of BehatExtension for Behat. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @copyright Michael Geppert <[email protected]> | ||
*/ | ||
|
||
namespace evangelion1204\QAToolsExtension\Context; | ||
namespace QATools\BehatExtension\Context; | ||
|
||
|
||
use Behat\Behat\Context\Context; | ||
use evangelion1204\QAToolsExtension\QATools; | ||
use QATools\BehatExtension\QATools; | ||
|
||
class IQAToolsContext implements Context, IQAToolsAwareContext | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<?php | ||
/* | ||
* This file is part of QAToolsExtension for Behat. | ||
* This file is part of BehatExtension for Behat. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @copyright Michael Geppert <[email protected]> | ||
*/ | ||
|
||
namespace evangelion1204\QAToolsExtension; | ||
namespace QATools\BehatExtension; | ||
|
||
|
||
use Behat\Mink\Mink; | ||
|
@@ -38,7 +38,7 @@ class QATools | |
/** | ||
* The used page factory. | ||
* | ||
* @var PageFactory | ||
* @var IPageFactory | ||
*/ | ||
protected $pageFactory; | ||
|
||
|
@@ -76,7 +76,7 @@ public function __construct(Mink $mink, array $config) | |
public function init() | ||
{ | ||
$this->session = $this->mink->getSession(); | ||
$this->pageFactory = new TypifiedPageFactory($this->session, new Config($this->config['qa_tools'])); | ||
$this->pageFactory = $this->createPageFactory(); | ||
|
||
if ( isset($this->config['users']) ) { | ||
foreach ( $this->config['users'] as $id => $user ) { | ||
|
@@ -114,4 +114,14 @@ public function getActivePage() | |
return $this->activePage; | ||
} | ||
|
||
/** | ||
* Creates a page factory. | ||
* | ||
* @return IPageFactory | ||
*/ | ||
public function createPageFactory() | ||
{ | ||
return new TypifiedPageFactory($this->session, new Config($this->config['qa_tools'])); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
<?php | ||
/* | ||
* This file is part of QAToolsExtension for Behat. | ||
* This file is part of BehatExtension for Behat. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @copyright Michael Geppert <[email protected]> | ||
*/ | ||
|
||
namespace evangelion1204\QAToolsExtension\ServiceContainer; | ||
namespace QATools\BehatExtension\ServiceContainer; | ||
|
||
|
||
use Behat\Behat\Context\ServiceContainer\ContextExtension; | ||
use Behat\Mink\Mink; | ||
use Behat\Testwork\ServiceContainer\Extension; | ||
use Behat\Testwork\ServiceContainer\ExtensionManager; | ||
use evangelion1204\QAToolsExtension\QATools; | ||
use QATools\BehatExtension\QATools; | ||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
class QAToolsExtension implements Extension | ||
class BehatExtension implements Extension | ||
{ | ||
|
||
const INITIALIZER_CLASS = 'evangelion1204\\QAToolsExtension\\Context\\Initializer\\QAToolsInitializer'; | ||
const INITIALIZER_CLASS = 'QATools\\BehatExtension\\Context\\Initializer\\QAToolsInitializer'; | ||
|
||
/** | ||
* QA-Tools instance. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<?php | ||
/* | ||
* This file is part of QAToolsExtension for Behat. | ||
* This file is part of BehatExtension for Behat. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @copyright Michael Geppert <[email protected]> | ||
*/ | ||
|
||
namespace evangelion1204\QAToolsExtension; | ||
namespace QATools\BehatExtension; | ||
|
||
|
||
class User | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/* | ||
* This file is part of BehatExtension for Behat. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @copyright Michael Geppert <[email protected]> | ||
*/ | ||
|
||
namespace tests\QATools\BehatExtension; | ||
|
||
|
||
use Behat\Mink\Mink; | ||
use Mockery as m; | ||
use QATools\BehatExtension\QATools; | ||
|
||
class QAToolsTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
/** | ||
* QATools instance. | ||
* | ||
* @var QATools | ||
*/ | ||
protected $qaTools; | ||
|
||
/** | ||
* Mink instance. | ||
* | ||
* @var Mink | ||
*/ | ||
protected $mink; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->mink = m::mock('\\Behat\\Mink\\Mink[getSession,stopSessions]'); | ||
$this->mink->shouldReceive('stopSessions')->andReturnNull(); | ||
$this->mink->shouldReceive('getSession')->andReturnNull(); | ||
} | ||
|
||
/** | ||
* @dataProvider getPageDataProvider | ||
*/ | ||
public function testGetPage($name, $class_with_namespace, $config) | ||
{ | ||
$page_factory = m::mock('\\QATools\\QATools\\PageObject\\IPageFactory'); | ||
|
||
$this->qaTools = m::mock('\\QATools\\BehatExtension\\QATools[createPageFactory]', array($this->mink, $config)); | ||
$this->qaTools->shouldReceive('createPageFactory')->once()->andReturn($page_factory); | ||
|
||
$this->qaTools->init(); | ||
|
||
$page_factory->shouldReceive('getPage')->with($class_with_namespace)->once()->andReturn(true); | ||
|
||
$this->assertEquals(true, $this->qaTools->getPage($name)); | ||
} | ||
|
||
public function getPageDataProvider() | ||
{ | ||
return array( | ||
array('TestPage', 'TestPage', array()), | ||
array( | ||
'TestPage', | ||
'\\QATools\\behat\\pages\\TestPage', | ||
array( | ||
'namespace' => array( | ||
'pages' => 'QATools\\behat\\pages', | ||
), | ||
), | ||
), | ||
); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<body> | ||
<input name="input1"> | ||
<input name="input2"> | ||
<input name="input3"> | ||
</body> | ||
</html> |
Shouldn't we use large
B
to makeBehat
notbehat
?