Skip to content

Commit

Permalink
Changed namespace and composer.json. Added one basic Unittest.
Browse files Browse the repository at this point in the history
  • Loading branch information
evangelion1204 committed Jul 7, 2014
1 parent 9c7bf44 commit 432e6b5
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 53 deletions.
23 changes: 10 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"name": "evangelion1204/BehatQAToolsExtension",
"name": "qa-tools/behat-extension",
"description": "QA-Tools extension for Behat",
"type": "library",
"keywords": ["behat","bdd","page","qa-tools","PageObject","HtmlElements"],
"homepage": "https://github.com/evangelion1204/BehatQAToolsExtension",
"homepage": "https://github.com/qa-tools/behat-extension",
"license": "BSD-3-Clause",
"require": {
"php": ">=5.3.1",
"behat/mink": "dev-master",
"behat/mink-extension": "*",
"qa-tools/qa-tools": "dev-master"
"qa-tools/qa-tools": "*@dev"
},
"minimum-stability": "dev",
"config": {
Expand All @@ -19,21 +18,19 @@
"aik099/coding-standard": "dev-master",
"mockery/mockery": "~0.9"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/qa-tools/qa-tools"
}
],
"autoload": {
"psr-0": {
"evangelion1204\\QAToolsExtension": "src/",
"evangelion1204\\behat": "tests/"
"QATools\\BehatExtension": "src/"
}
},
"autoload-dev": {
"psr-0": {
"QATools\\behat": "tests/"

This comment has been minimized.

Copy link
@aik099

aik099 Jul 7, 2014

Member

Shouldn't we use large B to make Behat not behat?

This comment has been minimized.

Copy link
@evangelion1204

evangelion1204 Jul 7, 2014

Author Contributor

I will fix this with #4 and provide an example.

This comment has been minimized.

Copy link
@aik099

aik099 Jul 7, 2014

Member

OK.

}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.0.x-dev"
}
}
}
12 changes: 6 additions & 6 deletions init.php
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.

Copy link
@aik099

aik099 Jul 7, 2014

Member

BehatExtension for Behat you say 😄 . This needs some rewording. Maybe BehatExtension for QA-Tools? Of course licensing block needs to be fixed in all files.

This comment has been minimized.

Copy link
@evangelion1204

evangelion1204 Jul 7, 2014

Author Contributor

Ok, I will add another task for this, same license block as in qa-tools\qa-tools I guess?

This comment has been minimized.

Copy link
@aik099

aik099 Jul 7, 2014

Member

Ok, I will add another task for this

Sure.

same license block as in qa-tools\qa-tools I guess?

Same format, but only package name is different. Name BehatExtension for QA-Tools seems ok to me, unless you have something else in mind.

This comment has been minimized.

Copy link
@evangelion1204

evangelion1204 Jul 7, 2014

Author Contributor

No thats perfect 😄 just made a refactor of the name and it did also hit the composer.json file. This morning I was prob. too sleepy to see it.

*
* 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();
29 changes: 29 additions & 0 deletions phpunit.xml.dist
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
{
Expand Down
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
{
Expand Down
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
{
Expand Down
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;
Expand Down Expand Up @@ -38,7 +38,7 @@ class QATools
/**
* The used page factory.
*
* @var PageFactory
* @var IPageFactory
*/
protected $pageFactory;

Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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.
Expand Down
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
Expand Down
77 changes: 77 additions & 0 deletions tests/QATools/BehatExtension/QAToolsTest.php
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
Expand Up @@ -15,7 +15,7 @@ default:
qa_tools:
base_url: 'http://localhost'
namespace:
pages: evangelion1204\behat\pages
pages: QATools\behat\pages
users:
test:
firstname: michael
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use evangelion1204\QAToolsExtension\Context\IQAToolsContext;
use lounge\testing\Manager;
use QATools\BehatExtension\Context\IQAToolsContext;

class MainContext extends IQAToolsContext
{
Expand All @@ -22,4 +21,5 @@ public function waitFor($seconds)
{
sleep($seconds);
}
}

}
File renamed without changes.
7 changes: 7 additions & 0 deletions tests/QATools/behat/fixtures/index.html
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>
Loading

0 comments on commit 432e6b5

Please sign in to comment.