diff --git a/Coverage/globals.php b/Coverage/globals.php index 82746a2..b9cf909 100644 --- a/Coverage/globals.php +++ b/Coverage/globals.php @@ -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; diff --git a/Coverage/prepend.php b/Coverage/prepend.php index 5494deb..8757461 100644 --- a/Coverage/prepend.php +++ b/Coverage/prepend.php @@ -1,3 +1,3 @@ * @@ -15,18 +9,19 @@ * 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 + * @author Konstantin Kudryashov */ class SelectorsHandlerPass implements CompilerPassInterface { - /** - * Processes container. - * - * @param Symfony\Component\DependencyInjection\ContainerBuilder $container - */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('mink.selectors_handler')) { diff --git a/DependencyInjection/Compiler/SessionsPass.php b/DependencyInjection/Compiler/SessionsPass.php index 8c346ef..c09fced 100644 --- a/DependencyInjection/Compiler/SessionsPass.php +++ b/DependencyInjection/Compiler/SessionsPass.php @@ -1,13 +1,7 @@ * @@ -15,18 +9,19 @@ * 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 + * @author Konstantin Kudryashov */ class SessionsPass implements CompilerPassInterface { - /** - * Processes container. - * - * @param Symfony\Component\DependencyInjection\ContainerBuilder $container - */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('behat.mink')) { diff --git a/DependencyInjection/Compiler/TestSessionListenerPass.php b/DependencyInjection/Compiler/TestSessionListenerPass.php index 848ab38..6f68c76 100644 --- a/DependencyInjection/Compiler/TestSessionListenerPass.php +++ b/DependencyInjection/Compiler/TestSessionListenerPass.php @@ -1,12 +1,7 @@ * @@ -14,10 +9,15 @@ * 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 + * @author Konstantin Kudryashov */ class TestSessionListenerPass implements CompilerPassInterface { diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 6d526a5..3712ea3 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1,12 +1,7 @@ * @@ -14,18 +9,18 @@ * 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 + * @author Konstantin Kudryashov */ class Configuration implements ConfigurationInterface { - /** - * Returns configuration tree. - * - * @return Symfony\Component\Config\Definition\Builder\TreeBuilder - */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); diff --git a/DependencyInjection/MinkExtension.php b/DependencyInjection/MinkExtension.php index 1b6da50..f846867 100644 --- a/DependencyInjection/MinkExtension.php +++ b/DependencyInjection/MinkExtension.php @@ -1,15 +1,7 @@ * @@ -17,19 +9,21 @@ * 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 + * @author Konstantin Kudryashov */ 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(); @@ -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); } } diff --git a/MinkBundle.php b/MinkBundle.php index 82ca639..3bf33d4 100644 --- a/MinkBundle.php +++ b/MinkBundle.php @@ -1,16 +1,7 @@ * @@ -18,6 +9,13 @@ * 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. * @@ -25,11 +23,6 @@ */ class MinkBundle extends Bundle { - /** - * Registers compilation passes. - * - * @param Symfony\Component\DependencyInjection\ContainerBuilder $container - */ public function build(ContainerBuilder $container) { parent::build($container); diff --git a/Resources/public/phpunit_coverage.php b/Resources/public/phpunit_coverage.php index 5254e4f..548b207 100644 --- a/Resources/public/phpunit_coverage.php +++ b/Resources/public/phpunit_coverage.php @@ -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'] @@ -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) { @@ -82,4 +82,3 @@ print serialize($coverage); } - diff --git a/Test/MinkTestCase.php b/Test/MinkTestCase.php index f9ed759..2a26677 100644 --- a/Test/MinkTestCase.php +++ b/Test/MinkTestCase.php @@ -1,13 +1,7 @@ * @@ -15,6 +9,11 @@ * 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. * @@ -76,6 +75,7 @@ public function getMink() $this->coverageScriptUrl = $container->getParameter('mink.coverage_script_url'); self::$mink = $container->get('behat.mink'); } + return self::$mink; } @@ -90,6 +90,7 @@ public static function getKernel() if (!static::$kernel->getContainer()) { static::$kernel->boot(); } + return static::$kernel; } @@ -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); } @@ -115,6 +116,7 @@ protected function initTestCoverage() public function runTest() { $this->initTestCoverage(); + return parent::runTest(); } @@ -133,8 +135,10 @@ protected function findDirectorySeparator($path) } /** - * @param array $coverage + * @param array $coverage + * * @return array + * * @author Mattis Stordalen Flister */ protected function matchLocalAndRemotePaths(array $coverage) @@ -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(); } @@ -177,7 +182,6 @@ public function run(\PHPUnit_Framework_TestResult $result = null) $this->collectCodeCoverageInformation && $this->coverageScriptUrl ) { - $session = $mink->getSession('goutte'); $url = sprintf( @@ -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.'"'); } } diff --git a/Tests/BaseSessionTestCase.php b/Tests/BaseSessionTestCase.php index 7df0e4a..cd574b0 100644 --- a/Tests/BaseSessionTestCase.php +++ b/Tests/BaseSessionTestCase.php @@ -1,6 +1,8 @@ getMink()->getSession(); - $session->visit($this->base . '/_behat/tests/page/page1'); + $session->visit($this->base.'/_behat/tests/page/page1'); $this->wait(); $this->assertTrue($session->getPage()->hasContent('Page N1')); $this->assertFalse($session->getPage()->hasContent('Page N2')); - $session->visit($this->base . '/_behat/tests/page/page2'); + $session->visit($this->base.'/_behat/tests/page/page2'); $this->wait(); $this->assertTrue($session->getPage()->hasContent('Page N2')); $this->assertFalse($session->getPage()->hasContent('Page N1')); - $session->visit($this->base . '/_behat/tests/page/page1'); + $session->visit($this->base.'/_behat/tests/page/page1'); $this->wait(); $session->getPage()->clickLink('p10'); $this->wait(); @@ -45,14 +47,15 @@ public function testSimpleBrowsing() try { $session->getPage()->clickLink('p100'); $this->fail('Unexisting link should throw exception onClick'); - } catch (\Behat\Mink\Exception\ElementNotFoundException $e) {} + } catch (ElementNotFoundException $e) { + } } public function testRedirects() { $session = $this->getMink()->getSession(); - $session->visit($this->base . '/_behat/tests/redirect'); + $session->visit($this->base.'/_behat/tests/redirect'); $this->wait(); $this->assertTrue($session->getPage()->hasContent('Page N1')); } @@ -61,7 +64,7 @@ public function testForms() { $session = $this->getMink()->getSession(); - $session->visit($this->base . '/_behat/tests/form'); + $session->visit($this->base.'/_behat/tests/form'); $this->wait(); $page = $session->getPage(); diff --git a/Tests/Controller/TestsController.php b/Tests/Controller/TestsController.php index d8c492a..37a86fb 100644 --- a/Tests/Controller/TestsController.php +++ b/Tests/Controller/TestsController.php @@ -1,17 +1,19 @@ * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. */ +namespace Behat\MinkBundle\Tests\Controller; + +use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\RedirectResponse; + /** * MinkBundle test actions controller. * @@ -46,7 +48,7 @@ public function submitAction() 'method' => $this->get('request')->getMethod(), 'name' => $data['name'], 'age' => $data['age'], - 'speciality' => $data['speciality'] + 'speciality' => $data['speciality'], )); } @@ -55,7 +57,7 @@ public function headersAction() $headers = $this->getRequest()->headers->all(); return $this->render('MinkBundle::headers.html.php', array( - 'headers' => var_export($headers, true) + 'headers' => var_export($headers, true), )); } } diff --git a/Tests/Functional/GoutteSessionTest.php b/Tests/Functional/GoutteSessionTest.php index 6c9240f..56fdf45 100644 --- a/Tests/Functional/GoutteSessionTest.php +++ b/Tests/Functional/GoutteSessionTest.php @@ -1,4 +1,5 @@ getMink()->getSession(); $session->setRequestHeader('Accept-Language', 'fr'); - $session->visit($this->base . '/_behat/tests/headers'); + $session->visit($this->base.'/_behat/tests/headers'); $this->assertContains("'accept-language' =>", $session->getPage()->getContent()); $this->assertContains("'fr'", $session->getPage()->getContent()); $session->setRequestHeader('Accept-Language', 'ru'); - $session->visit($this->base . '/_behat/tests/headers'); + $session->visit($this->base.'/_behat/tests/headers'); $this->assertContains("'accept-language' =>", $session->getPage()->getContent()); $this->assertContains("'ru'", $session->getPage()->getContent()); } diff --git a/Tests/Functional/SahiSessionTest.php b/Tests/Functional/SahiSessionTest.php index 62bce60..ada64e6 100644 --- a/Tests/Functional/SahiSessionTest.php +++ b/Tests/Functional/SahiSessionTest.php @@ -1,4 +1,5 @@ setMink(); + return 'sahi'; } } diff --git a/Tests/Functional/Selenium2SessionTest.php b/Tests/Functional/Selenium2SessionTest.php index 6dda64c..d15cb88 100644 --- a/Tests/Functional/Selenium2SessionTest.php +++ b/Tests/Functional/Selenium2SessionTest.php @@ -1,4 +1,5 @@ getMink()->getSession(); $session->setRequestHeader('Accept-Language', 'fr'); - $session->visit($this->base . '/_behat/tests/headers'); + $session->visit($this->base.'/_behat/tests/headers'); $this->assertContains("'accept-language' =>", $session->getPage()->getContent()); $this->assertContains("'fr'", $session->getPage()->getContent()); $session->setRequestHeader('Accept-Language', 'ru'); - $session->visit($this->base . '/_behat/tests/headers'); + $session->visit($this->base.'/_behat/tests/headers'); $this->assertContains("'accept-language' =>", $session->getPage()->getContent()); $this->assertContains("'ru'", $session->getPage()->getContent()); } diff --git a/Tests/Functional/ZombieSessionTest.php b/Tests/Functional/ZombieSessionTest.php index 52c0c98..e3161b6 100644 --- a/Tests/Functional/ZombieSessionTest.php +++ b/Tests/Functional/ZombieSessionTest.php @@ -1,4 +1,5 @@ setMink(); + return 'zombie'; } } diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index a1f5ba5..37ef933 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -5,4 +5,4 @@ } umask(0000); -require($vendor.'/autoload.php'); +require $vendor.'/autoload.php';