Skip to content

Commit

Permalink
minor #1418 Config for php cs fixer v2 (ogizanagi, javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

Config for php cs fixer v2

Php-cs-fixer v2 has been released a week ago.

Commits
-------

a124629 Removed the PSR-4 rule
ed71285 Review rules and allow risky to be executed
29c1851 Defined some new syntax rules
03deb24 Config for php cs fixer v2
  • Loading branch information
javiereguiluz committed Dec 10, 2016
2 parents d68b5e6 + a124629 commit 4b4613e
Show file tree
Hide file tree
Showing 32 changed files with 268 additions and 254 deletions.
22 changes: 18 additions & 4 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$finder = Symfony\CS\Finder::create()
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->ignoreDotFiles(true)
->ignoreVCS(true)
Expand All @@ -9,8 +9,22 @@ $finder = Symfony\CS\Finder::create()
->name('*.php')
;

return Symfony\CS\Config::create()
return PhpCsFixer\Config::create()
->setUsingCache(true)
->fixers(array('-unalign_double_arrow', '-phpdoc_short_description'))
->finder($finder)
->setRiskyAllowed(true)
->setFinder($finder)
->setRules(array(
'@Symfony' => true,
'array_syntax' => array('syntax' => 'long'),
'binary_operator_spaces' => array(
'align_double_arrow' => false,
),
'combine_consecutive_unsets' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'phpdoc_summary' => false,
'strict_comparison' => true,
))
;
2 changes: 1 addition & 1 deletion Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;

/**
* The controller used to render all the default EasyAdmin actions.
Expand Down
2 changes: 1 addition & 1 deletion DataCollector/EasyAdminDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace JavierEguiluz\Bundle\EasyAdminBundle\DataCollector;

use JavierEguiluz\Bundle\EasyAdminBundle\Configuration\ConfigManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use JavierEguiluz\Bundle\EasyAdminBundle\Configuration\ConfigManager;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
use Symfony\Component\Yaml\Yaml;
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/EasyAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

namespace JavierEguiluz\Bundle\EasyAdminBundle\DependencyInjection;

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

/**
* Resolves all the backend configuration values and most of the entities
Expand Down
2 changes: 1 addition & 1 deletion Form/Type/EasyAdminFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace JavierEguiluz\Bundle\EasyAdminBundle\Form\Type;

use JavierEguiluz\Bundle\EasyAdminBundle\Form\Type\Configurator\TypeConfiguratorInterface;
use JavierEguiluz\Bundle\EasyAdminBundle\Configuration\ConfigManager;
use JavierEguiluz\Bundle\EasyAdminBundle\Form\Type\Configurator\TypeConfiguratorInterface;
use JavierEguiluz\Bundle\EasyAdminBundle\Form\Util\LegacyFormHelper;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Configuration/ConfigManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function ($filePath) {

private function isTestCompatible($filePath)
{
if (2 != Kernel::MAJOR_VERSION || 3 != Kernel::MINOR_VERSION) {
if (2 !== Kernel::MAJOR_VERSION || 3 !== Kernel::MINOR_VERSION) {
return true;
}

Expand Down
36 changes: 18 additions & 18 deletions Tests/Controller/ActionTargetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,42 @@ public function testListViewActions()
{
$crawler = $this->requestListView();

$this->assertEquals('_top', $crawler->filter('.global-actions form button[type="submit"]')->attr('formtarget'));
$this->assertEquals('custom_target', $crawler->filter('.button-action a:contains("Add Category")')->attr('target'));
$this->assertSame('_top', $crawler->filter('.global-actions form button[type="submit"]')->attr('formtarget'));
$this->assertSame('custom_target', $crawler->filter('.button-action a:contains("Add Category")')->attr('target'));

$this->assertEquals('_blank', $crawler->filter('table a:contains("Edit")')->attr('target'));
$this->assertEquals('_parent', $crawler->filter('table a:contains("Custom action")')->attr('target'));
$this->assertEquals('_self', $crawler->filter('table a:contains("Another custom action")')->attr('target'));
$this->assertEquals('_self', $crawler->filter('table a:contains("Delete")')->attr('target'));
$this->assertEquals('_self', $crawler->filter('#modal-delete-button')->attr('formtarget'));
$this->assertSame('_blank', $crawler->filter('table a:contains("Edit")')->attr('target'));
$this->assertSame('_parent', $crawler->filter('table a:contains("Custom action")')->attr('target'));
$this->assertSame('_self', $crawler->filter('table a:contains("Another custom action")')->attr('target'));
$this->assertSame('_self', $crawler->filter('table a:contains("Delete")')->attr('target'));
$this->assertSame('_self', $crawler->filter('#modal-delete-button')->attr('formtarget'));
}

public function testEditViewActions()
{
$crawler = $this->requestEditView();

$this->assertEquals('_parent', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
$this->assertEquals('_blank', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
$this->assertEquals('_blank', $crawler->filter('.form-actions a:contains("Delete")')->attr('target'));
$this->assertEquals('_blank', $crawler->filter('#modal-delete-button')->attr('formtarget'));
$this->assertSame('_parent', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
$this->assertSame('_blank', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
$this->assertSame('_blank', $crawler->filter('.form-actions a:contains("Delete")')->attr('target'));
$this->assertSame('_blank', $crawler->filter('#modal-delete-button')->attr('formtarget'));
}

public function testShowViewActions()
{
$crawler = $this->requestShowView();

$this->assertEquals('_self', $crawler->filter('.form-actions a:contains("Edit")')->attr('target'));
$this->assertEquals('_self', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
$this->assertEquals('custom_target', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
$this->assertEquals('_self', $crawler->filter('.form-actions a:contains("Delete")')->attr('target'));
$this->assertEquals('_self', $crawler->filter('#modal-delete-button')->attr('formtarget'));
$this->assertSame('_self', $crawler->filter('.form-actions a:contains("Edit")')->attr('target'));
$this->assertSame('_self', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
$this->assertSame('custom_target', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
$this->assertSame('_self', $crawler->filter('.form-actions a:contains("Delete")')->attr('target'));
$this->assertSame('_self', $crawler->filter('#modal-delete-button')->attr('formtarget'));
}

public function testNewViewActions()
{
$crawler = $this->requestNewView();

$this->assertEquals('_top', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
$this->assertEquals('_parent', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
$this->assertSame('_top', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
$this->assertSame('_parent', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
}
}
4 changes: 2 additions & 2 deletions Tests/Controller/AutocompleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function testAutocompleteText()
// the results are the first 10 parent categories
$response = json_decode($this->client->getResponse()->getContent(), true);
foreach (range(1, 10) as $i) {
$this->assertEquals($i, $response['results'][$i - 1]['id']);
$this->assertEquals('Parent Category #'.$i, $response['results'][$i - 1]['text']);
$this->assertSame($i, $response['results'][$i - 1]['id']);
$this->assertSame('Parent Category #'.$i, $response['results'][$i - 1]['text']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Controller/BackendErrorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testUndefinedEntityError()
'view' => 'list',
));

$this->assertEquals(500, $this->client->getResponse()->getStatusCode());
$this->assertSame(500, $this->client->getResponse()->getStatusCode());
$this->assertContains('Entity "InexistentEntity" is not managed by EasyAdmin.', $crawler->filter('head title')->text());
}
}
36 changes: 18 additions & 18 deletions Tests/Controller/CustomMenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ public function testCustomBackendHomepage()
{
$this->client->request('GET', '/admin/');

$this->assertEquals(
$this->assertSame(
'/admin/?action=list&entity=Category&menuIndex=0&submenuIndex=3',
$this->client->getResponse()->headers->get('location')
);

$crawler = $this->client->followRedirect();

$this->assertEquals(
$this->assertSame(
'Products',
trim($crawler->filter('.sidebar-menu li.active.submenu-active a')->text())
);

$this->assertEquals(
$this->assertSame(
'Categories',
trim($crawler->filter('.sidebar-menu .treeview-menu li.active a')->text())
);
Expand Down Expand Up @@ -86,13 +86,13 @@ public function testMenuIcons()
{
$crawler = $this->getBackendHomepage();

$this->assertEquals(
$this->assertSame(
'fa fa-shopping-basket',
$crawler->filter('.sidebar-menu li:contains("Products") i')->attr('class'),
'First level menu item with custom icon'
);

$this->assertEquals(
$this->assertSame(
'fa fa-chevron-circle-right',
$crawler->filter('.sidebar-menu li:contains("Images") i')->attr('class'),
'First level menu item with default icon'
Expand All @@ -104,13 +104,13 @@ public function testMenuIcons()
'First level menu item without icon'
);

$this->assertEquals(
$this->assertSame(
'fa fa-th-list',
$crawler->filter('.sidebar-menu .treeview-menu li:contains("List Products") i')->attr('class'),
'Second level menu item with custom icon'
);

$this->assertEquals(
$this->assertSame(
'fa fa-chevron-right',
$crawler->filter('.sidebar-menu .treeview-menu li:contains("Add Product") i')->attr('class'),
'Second level menu item with default icon'
Expand All @@ -127,17 +127,17 @@ public function testMenuTargets()
{
$crawler = $this->getBackendHomepage();

$this->assertEquals(
$this->assertSame(
'_blank',
$crawler->filter('.sidebar-menu li:contains("Project Home") a')->attr('target')
);

$this->assertEquals(
$this->assertSame(
'_self',
$crawler->filter('.sidebar-menu li:contains("Documentation") a')->attr('target')
);

$this->assertEquals(
$this->assertSame(
'arbitrary_value',
$crawler->filter('.sidebar-menu li:contains("Report Issues") a')->attr('target')
);
Expand All @@ -147,25 +147,25 @@ public function testMenuUrls()
{
$crawler = $this->getBackendHomepage();

$this->assertEquals(
$this->assertSame(
'#',
$crawler->filter('.sidebar-menu li:contains("Products") a')->attr('href'),
'First level menu, empty item'
);

$this->assertEquals(
$this->assertSame(
'/admin/?entity=Image&action=list&menuIndex=1&submenuIndex=-1',
$crawler->filter('.sidebar-menu li:contains("Images") a')->attr('href'),
'First level menu, default link'
);

$this->assertEquals(
$this->assertSame(
'/admin/?entity=Purchase&action=list&menuIndex=2&submenuIndex=-1&sortField=deliveryDate',
$crawler->filter('.sidebar-menu li:contains("Purchases") a')->attr('href'),
'First level menu, customized link'
);

$this->assertEquals(
$this->assertSame(
'https://github.com/javiereguiluz/EasyAdminBundle',
$crawler->filter('.sidebar-menu li:contains("Project Home") a')->attr('href'),
'First level menu, absolute URL'
Expand All @@ -182,24 +182,24 @@ public function testMenuItemTypes()
$menuConfig = $backendConfig['design']['menu'];

foreach ($menuConfig as $i => $itemConfig) {
$this->assertEquals($expectedTypesMainMenu[$i], $itemConfig['type']);
$this->assertSame($expectedTypesMainMenu[$i], $itemConfig['type']);
}

foreach ($menuConfig[0]['children'] as $i => $itemConfig) {
$this->assertEquals($expectedTypesSubMenu[$i], $itemConfig['type']);
$this->assertSame($expectedTypesSubMenu[$i], $itemConfig['type']);
}
}

public function testExternalRoutesDontIncludeIndexParameters()
{
$crawler = $this->getBackendHomepage();

$this->assertEquals(
$this->assertSame(
'/custom-route?custom_parameter=Lorem+Ipsum',
$crawler->filter('.sidebar-menu li:contains("Custom External Route") a')->attr('href')
);

$this->assertEquals(
$this->assertSame(
'/admin/?menuIndex=9&submenuIndex=-1',
$crawler->filter('.sidebar-menu li:contains("Custom Internal Route") a')->attr('href')
);
Expand Down

0 comments on commit 4b4613e

Please sign in to comment.