Skip to content

Commit

Permalink
FlintCI integration
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh committed Jan 10, 2018
1 parent 65d150a commit ba8e654
Show file tree
Hide file tree
Showing 49 changed files with 343 additions and 289 deletions.
3 changes: 3 additions & 0 deletions .flintci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
services:
phpcsfixer: true
yamllint: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
composer.lock
vendor
.php_cs.cache

# Ignore files created during tests
/tests/App*/cache/*
Expand Down
32 changes: 32 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->notPath('/cache/')
;

return PhpCsFixer\Config::create()
->setFinder($finder)
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => [
'syntax' => 'short',
],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'no_extra_consecutive_blank_lines' => true,
'no_php4_constructor' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'@PHP56Migration' => true,
'@PHP56Migration:risky' => true,
'strict_comparison' => true,
'strict_param' => true,
'php_unit_strict' => true,
])
->setUsingCache(true)
;
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ build:
version: 5.6
dependencies:
override:
-
-
command: 'composer require --dev "symfony/symfony:2.8.*" --no-update'
-
command: 'composer update --no-interaction -vv --profile --no-progress'
Expand Down
20 changes: 20 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
extends: default

ignore: |
/vendor/

rules:
braces:
min-spaces-inside: 1
max-spaces-inside: 1
brackets:
min-spaces-inside: 0
max-spaces-inside: 1
colons:
max-spaces-after: -1
document-start: disable
line-length:
max: 120
level: warning
ignore: |
/.travis.yml
8 changes: 4 additions & 4 deletions ExampleTests/ExampleFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ExampleFunctionalTest extends WebTestCase
*/
public function testUserFooIndex()
{
$this->loadFixtures(array('Liip\FooBundle\Tests\Fixtures\LoadUserData'));
$this->loadFixtures(['Liip\FooBundle\Tests\Fixtures\LoadUserData']);

$client = $this->createClient();
$crawler = $client->request('GET', '/users/foo');
Expand All @@ -39,10 +39,10 @@ public function testUserFooIndex()
*/
public function testBasicAuthentication()
{
$this->loadFixtures(array('Liip\FooBundle\Tests\Fixtures\LoadUserData'));
$this->loadFixtures(['Liip\FooBundle\Tests\Fixtures\LoadUserData']);

$content = $this->fetchContent('/users/foo', 'GET', true);
$this->assertEquals('Hello foo!', $content);
$this->assertSame('Hello foo!', $content);

// check if the logout button is shown
$this->assertContains('logout', $content);
Expand All @@ -66,6 +66,6 @@ public function testValidationErrors()

$client->submit($crawler->selectButton('Save')->form());

$this->assertValidationErrors(array('data.username', 'data.email'), $client->getContainer());
$this->assertValidationErrors(['data.username', 'data.email'], $client->getContainer());
}
}
10 changes: 5 additions & 5 deletions ExampleTests/ExampleHtml5Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public function testIndex()

public function testBasicAuthentication()
{
$this->loadFixtures(array('Liip\FooBundle\Tests\Fixtures\LoadUserData'));
$this->loadFixtures(['Liip\FooBundle\Tests\Fixtures\LoadUserData']);

$content = $this->fetchContent('/', 'GET', true);
$this->assertEquals('Hello foo!', $content);
$this->assertSame('Hello foo!', $content);
}

public function testGenerateInMissingDir()
{
$this->runCommand('main:generate-html', array('output-dir' => './doesntexist'));
$this->assertFalse(file_exists($this->dir.'/index.html'));
$this->runCommand('main:generate-html', ['output-dir' => './doesntexist']);
$this->assertFileNotExists($this->dir.'/index.html');
}

public function testIndexAction()
Expand All @@ -60,6 +60,6 @@ public function testIndexAction()

$controller = new DefaultController($view);

$this->assertEquals('success', $controller->indexAction());
$this->assertSame('success', $controller->indexAction());
}
}
2 changes: 1 addition & 1 deletion ExampleTests/ExampleUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public function testIndexAction()

$controller = new DefaultController($view);

$this->assertEquals('success', $controller->indexAction());
$this->assertSame('success', $controller->indexAction());
}
}
4 changes: 2 additions & 2 deletions ExampleTests/Fixtures/LoadUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace Liip\FooBundle\Tests\Fixtures;

use Doctrine\ORM\EntityManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;

/**
* @author Lea Haensenberger
Expand Down
10 changes: 5 additions & 5 deletions src/Command/RunParatestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace Liip\FunctionalTestBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Process;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Bundle\FrameworkBundle\Console\Application;

/**
* Command used to update the project.
Expand Down Expand Up @@ -49,15 +49,15 @@ protected function prepare()
$cleanProcess->run();
$this->output->writeln("Creating Schema in $this->testDbPath ...");
$application = new Application($this->getContainer()->get('kernel'));
$input = new ArrayInput(array('doctrine:schema:create', '--env' => 'test'));
$input = new ArrayInput(['doctrine:schema:create', '--env' => 'test']);
$application->run($input, $this->output);

$this->output->writeln('Initial schema created');
$input = new ArrayInput(array(
$input = new ArrayInput([
'doctrine:fixtures:load',
'-n' => '',
'--env' => 'test',
));
]);
$application->run($input, $this->output);

$this->output->writeln('Initial schema populated, duplicating....');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('Verbosity level: VERY_VERBOSE');
}

if (OutputInterface::VERBOSITY_DEBUG == $output->getVerbosity()) {
if (OutputInterface::VERBOSITY_DEBUG === $output->getVerbosity()) {
$output->writeln('Verbosity level: DEBUG');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/OptionalValidatorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Liip\FunctionalTestBundle\DependencyInjection\Compiler;

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

class OptionalValidatorPass implements CompilerPassInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Compiler/SetTestClientPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Liip\FunctionalTestBundle\DependencyInjection\Compiler;

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

class SetTestClientPass implements CompilerPassInterface
{
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace Liip\FunctionalTestBundle\DependencyInjection;

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

/**
* This class contains the configuration information for the bundle.
Expand Down Expand Up @@ -71,11 +71,11 @@ public function getConfigTreeBuilder()
->end()
->arrayNode('ignores')
->prototype('scalar')->end()
->defaultValue(array())
->defaultValue([])
->end()
->arrayNode('ignores_extract')
->prototype('scalar')->end()
->defaultValue(array())
->defaultValue([])
->end()
->end()
->end()
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/LiipFunctionalTestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace Liip\FunctionalTestBundle\DependencyInjection;

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

class LiipFunctionalTestExtension extends Extension
{
Expand Down
10 changes: 5 additions & 5 deletions src/EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function setException(GetResponseForExceptionEvent $event)

public function clearLastException(GetResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST == $event->getRequestType()) {
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
$this->lastException = null;
}
}
Expand All @@ -43,9 +43,9 @@ public function getLastException()

public static function getSubscribedEvents()
{
return array(
KernelEvents::EXCEPTION => array('setException', 99999),
KernelEvents::REQUEST => array('clearLastException', 99999),
);
return [
KernelEvents::EXCEPTION => ['setException', 99999],
KernelEvents::REQUEST => ['clearLastException', 99999],
];
}
}
2 changes: 1 addition & 1 deletion src/Factory/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ConnectionFactory extends BaseConnectionFactory
*
* @return \Doctrine\DBAL\Connection
*/
public function createConnection(array $params, Configuration $config = null, EventManager $eventManager = null, array $mappingTypes = array())
public function createConnection(array $params, Configuration $config = null, EventManager $eventManager = null, array $mappingTypes = [])
{
$dbName = $this->getDbNameFromEnv($params['dbname']);

Expand Down
6 changes: 3 additions & 3 deletions src/LiipFunctionalTestBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace Liip\FunctionalTestBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Liip\FunctionalTestBundle\DependencyInjection\Compiler\SetTestClientPass;
use Liip\FunctionalTestBundle\DependencyInjection\Compiler\OptionalValidatorPass;
use Liip\FunctionalTestBundle\DependencyInjection\Compiler\SetTestClientPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class LiipFunctionalTestBundle extends Bundle
{
Expand Down
6 changes: 3 additions & 3 deletions src/QueryCountClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public function setQueryCounter(QueryCounter $queryCounter)
public function request(
$method,
$uri,
array $parameters = array(),
array $files = array(),
array $server = array(),
array $parameters = [],
array $files = [],
array $server = [],
$content = null,
$changeHistory = true
) {
Expand Down
12 changes: 6 additions & 6 deletions src/Test/Html5WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class Html5WebTestCase extends WebTestCase

protected $validationServiceAvailable = false;

public function __construct($name = null, array $data = array(), $dataName = '')
public function __construct($name = null, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);

Expand Down Expand Up @@ -105,11 +105,11 @@ public function validateHtml5($content)
curl_setopt($ch, CURLOPT_URL, $validationUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'out' => 'json',
'parser' => 'html5',
'content' => $content,
));
]);

$res = curl_exec($ch);

Expand Down Expand Up @@ -152,7 +152,7 @@ public function assertIsValidHtml5($content, $message = '')

$err_count = 0;
$err_msg = 'HTML5 validation failed';
if ('' != $message) {
if ('' !== $message) {
$err_msg .= " [$message]";
}
$err_msg .= ":\n";
Expand All @@ -165,7 +165,7 @@ public function assertIsValidHtml5($content, $message = '')
$ignores_extract = $this->getContainer()->getParameter('liip_functional_test.html5validation.ignores_extract');

foreach ($res->messages as $row) {
if ('error' == $row->type) {
if ('error' === $row->type) {
foreach ($ignores as $ignore) {
if (preg_match($ignore, $row->message)) {
continue 2;
Expand All @@ -185,7 +185,7 @@ public function assertIsValidHtml5($content, $message = '')
}
}
}
$this->assertTrue(0 == $err_count, $err_msg);
$this->assertTrue(0 === $err_count, $err_msg);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Test/ValidationErrorsConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public function __construct(array $expect)
*/
public function evaluate($other, $description = '', $returnResult = false)
{
$actual = array();
$actual = [];

foreach ($other as $error) {
$actual[$error->getPropertyPath()][] = $error->getMessage();
}

ksort($actual);

if (array_keys($actual) == $this->expect) {
if (array_keys($actual) === $this->expect) {
return true;
}

Expand All @@ -71,7 +71,7 @@ public function evaluate($other, $description = '', $returnResult = false)
);
sort($mismatchedKeys);

$lines = array();
$lines = [];

foreach ($mismatchedKeys as $key) {
if (isset($actual[$key])) {
Expand Down
Loading

0 comments on commit ba8e654

Please sign in to comment.