Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Fixed coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed Nov 5, 2014
1 parent 203b046 commit 0cba40c
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 116 deletions.
2 changes: 1 addition & 1 deletion Coverage/globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
// the same directory in phpunit_coverage.php. Also note that the webserver
// needs write access to the directory.

$path = realpath(__DIR__ . '/../../../../../../app/logs') . '/coverage';
$path = realpath(__DIR__.'/../../../../../../app/logs').'/coverage';
@mkdir($path, 0777);
$GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = $path;
2 changes: 1 addition & 1 deletion Coverage/prepend.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
require __DIR__ . '/globals.php';
require __DIR__.'/globals.php';
require 'PHPUnit/Extensions/SeleniumCommon/prepend.php';
23 changes: 9 additions & 14 deletions DependencyInjection/Compiler/SelectorsHandlerPass.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
<?php

namespace Behat\MinkBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference,
Symfony\Component\DependencyInjection\ContainerBuilder,
Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/*
* This file is part of the Behat\MinkBundle
* This file is part of the Behat MinkBundle
*
* (c) Konstantin Kudryashov <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Behat\MinkBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/**
* Selectors handler compilation pass. Registers all avaiable Mink selector engines.
* Selectors handler compilation pass. Registers all available Mink selector engines.
*
* @author Konstantin Kudryashov <[email protected]>
* @author Konstantin Kudryashov <[email protected]>
*/
class SelectorsHandlerPass implements CompilerPassInterface
{
/**
* Processes container.
*
* @param Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('mink.selectors_handler')) {
Expand Down
21 changes: 8 additions & 13 deletions DependencyInjection/Compiler/SessionsPass.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
<?php

namespace Behat\MinkBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference,
Symfony\Component\DependencyInjection\ContainerBuilder,
Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/*
* This file is part of the Behat\MinkBundle
* This file is part of the Behat MinkBundle
*
* (c) Konstantin Kudryashov <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Behat\MinkBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/**
* Behat\Mink container compilation pass. Registers all available in controller Mink sessions.
*
* @author Konstantin Kudryashov <[email protected]>
* @author Konstantin Kudryashov <[email protected]>
*/
class SessionsPass implements CompilerPassInterface
{
/**
* Processes container.
*
* @param Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('behat.mink')) {
Expand Down
14 changes: 7 additions & 7 deletions DependencyInjection/Compiler/TestSessionListenerPass.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php

namespace Behat\MinkBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder,
Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/*
* This file is part of the Behat\MinkBundle
* This file is part of the Behat MinkBundle
*
* (c) Konstantin Kudryashov <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Behat\MinkBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/**
* Behat\Mink container compilation pass. Replaces test session listener for real session listener.
*
* @author Konstantin Kudryashov <[email protected]>
* @author Konstantin Kudryashov <[email protected]>
*/
class TestSessionListenerPass implements CompilerPassInterface
{
Expand Down
19 changes: 7 additions & 12 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
<?php

namespace Behat\MinkBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder,
Symfony\Component\Config\Definition\ConfigurationInterface;

/*
* This file is part of the Behat\MinkBundle
* This file is part of the Behat MinkBundle
*
* (c) Konstantin Kudryashov <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Behat\MinkBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* MinkBundle configuration manager.
*
* @author Konstantin Kudryashov <[email protected]>
* @author Konstantin Kudryashov <[email protected]>
*/
class Configuration implements ConfigurationInterface
{
/**
* Returns configuration tree.
*
* @return Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
Expand Down
28 changes: 11 additions & 17 deletions DependencyInjection/MinkExtension.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
<?php

namespace Behat\MinkBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Processor,
Symfony\Component\HttpKernel\DependencyInjection\Extension,
Symfony\Component\DependencyInjection\Loader\XmlFileLoader,
Symfony\Component\DependencyInjection\ContainerBuilder,
Symfony\Component\Config\FileLocator;

/*
* This file is part of the Behat\MinkBundle
* This file is part of the Behat MinkBundle
*
* (c) Konstantin Kudryashov <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Behat\MinkBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;

/**
* Symfony2 Behat\Mink extension.
*
* @author Konstantin Kudryashov <[email protected]>
* @author Konstantin Kudryashov <[email protected]>
*/
class MinkExtension extends Extension
{
/**
* Loads the services based on your application configuration.
*
* @param array $configs
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
Expand Down Expand Up @@ -91,7 +85,7 @@ public function load(array $configs, ContainerBuilder $container)

if (!$container->hasParameter('mink.paths.lib')) {
$minkReflection = new \ReflectionClass('Behat\Mink\Mink');
$minkLibPath = realpath(dirname($minkReflection->getFilename()) . '/../../../');
$minkLibPath = realpath(dirname($minkReflection->getFilename()).'/../../../');
$container->setParameter('mink.paths.lib', $minkLibPath);
}
}
Expand Down
23 changes: 8 additions & 15 deletions MinkBundle.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
<?php

namespace Behat\MinkBundle;

use Symfony\Component\DependencyInjection\ContainerBuilder,
Symfony\Component\HttpKernel\Bundle\Bundle;

use Behat\MinkBundle\DependencyInjection\Compiler\SessionsPass,
Behat\MinkBundle\DependencyInjection\Compiler\SelectorsHandlerPass,
Behat\MinkBundle\DependencyInjection\Compiler\TestSessionListenerPass;

/*
* This file is part of the Behat\MinkBundle
* This file is part of the Behat MinkBundle
*
* (c) Konstantin Kudryashov <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Behat\MinkBundle;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Behat\MinkBundle\DependencyInjection\Compiler\SessionsPass;
use Behat\MinkBundle\DependencyInjection\Compiler\SelectorsHandlerPass;

/**
* MinkBundle.
*
* @author Konstantin Kudryashov <[email protected]>
*/
class MinkBundle extends Bundle
{
/**
* Registers compilation passes.
*
* @param Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
Expand Down
7 changes: 3 additions & 4 deletions Resources/public/phpunit_coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@

require_once 'File/Iterator/Autoload.php';
require_once 'PHP/CodeCoverage/Autoload.php';
require __DIR__ . '/../../Coverage/globals.php';
require __DIR__.'/../../Coverage/globals.php';

if (isset($_GET['PHPUNIT_SELENIUM_TEST_ID'])) {
$facade = new File_Iterator_Facade;
$facade = new File_Iterator_Facade();
$files = $facade->getFilesAsArray(
$GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'],
$_GET['PHPUNIT_SELENIUM_TEST_ID']
Expand All @@ -65,7 +65,7 @@
if (!isset($coverage[$file])) {
$coverage[$file] = array(
'md5' => md5_file($file),
'coverage' => $lines
'coverage' => $lines,
);
} else {
foreach ($lines as $line => $flag) {
Expand All @@ -82,4 +82,3 @@

print serialize($coverage);
}

28 changes: 16 additions & 12 deletions Test/MinkTestCase.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<?php
namespace Behat\MinkBundle\Test;

use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Behat\Mink\Mink;

/*
* This file is part of the Behat\MinkBundle
* This file is part of the Behat MinkBundle
*
* (c) Konstantin Kudryashov <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Behat\MinkBundle\Test;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Behat\Mink\Mink;

/**
* Mink PHPUnit test case.
*
Expand Down Expand Up @@ -76,6 +75,7 @@ public function getMink()
$this->coverageScriptUrl = $container->getParameter('mink.coverage_script_url');
self::$mink = $container->get('behat.mink');
}

return self::$mink;
}

Expand All @@ -90,6 +90,7 @@ public static function getKernel()
if (!static::$kernel->getContainer()) {
static::$kernel->boot();
}

return static::$kernel;
}

Expand All @@ -103,7 +104,7 @@ public function getContainer()

protected function initTestCoverage()
{
$this->testId = get_class($this) . '__' . $this->getName();
$this->testId = get_class($this).'__'.$this->getName();
if ($this->collectCodeCoverageInformation && $this->coverageScriptUrl) {
$this->getMink()->getSession()->setCookie('PHPUNIT_SELENIUM_TEST_ID', $this->testId);
}
Expand All @@ -115,6 +116,7 @@ protected function initTestCoverage()
public function runTest()
{
$this->initTestCoverage();

return parent::runTest();
}

Expand All @@ -133,8 +135,10 @@ protected function findDirectorySeparator($path)
}

/**
* @param array $coverage
* @param array $coverage
*
* @return array
*
* @author Mattis Stordalen Flister <[email protected]>
*/
protected function matchLocalAndRemotePaths(array $coverage)
Expand All @@ -160,11 +164,12 @@ protected function matchLocalAndRemotePaths(array $coverage)

/**
* @param \PHPUnit_Framework_TestResult $result
*
* @return \PHPUnit_Framework_TestResult
*/
public function run(\PHPUnit_Framework_TestResult $result = null)
{
if ($result === null) {
if (null === $result) {
$result = $this->createResult();
}

Expand All @@ -177,7 +182,6 @@ public function run(\PHPUnit_Framework_TestResult $result = null)
$this->collectCodeCoverageInformation &&
$this->coverageScriptUrl
) {

$session = $mink->getSession('goutte');

$url = sprintf(
Expand All @@ -194,7 +198,7 @@ public function run(\PHPUnit_Framework_TestResult $result = null)
if (is_array($coverage)) {
$coverage = $this->matchLocalAndRemotePaths($coverage);
} else {
throw new \RuntimeException('Empty or invalid code coverage data received from url "' . $url . '"');
throw new \RuntimeException('Empty or invalid code coverage data received from url "'.$url.'"');
}
}

Expand Down
Loading

0 comments on commit 0cba40c

Please sign in to comment.