Skip to content

Commit

Permalink
Add cs-fixer rules for PHPUnit
Browse files Browse the repository at this point in the history
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
   1) Tests/Generator/AdminGeneratorTest.php (php_unit_strict)
   2) Tests/Generator/ControllerGeneratorTest.php (php_unit_strict)
   3) Tests/Event/PersistenceEventTest.php (php_unit_strict)
   4) Tests/Event/ConfigureQueryEventTest.php (php_unit_strict)
   5) Tests/Event/ConfigureEventTest.php (php_unit_strict)
   6) Tests/Route/RouteCollectionTest.php (php_unit_strict)
   7) Tests/Route/DefaultRouteGeneratorTest.php (php_unit_strict)
   8) Tests/Admin/AdminTest.php (php_unit_strict)
   9) Tests/Admin/PoolTest.php (php_unit_strict)
  10) Tests/Admin/BaseFieldDescriptionTest.php (php_unit_strict)
  11) Tests/Manipulator/ServicesManipulatorTest.php (php_unit_strict)
  12) Tests/Datagrid/DatagridMapperTest.php (php_unit_strict)
  13) Tests/Datagrid/ListMapperTest.php (php_unit_strict)
  14) Tests/Datagrid/PagerTest.php (php_unit_strict)
  15) Tests/Datagrid/DatagridTest.php (php_unit_strict)
  16) Tests/Controller/HelperControllerTest.php (php_unit_strict)
  17) Tests/Controller/CRUDControllerTest.php (php_unit_strict)
  18) Tests/Form/DataTransformer/ModelsToArrayTransformerTest.php (php_unit_strict)
  19) Tests/Form/DataTransformer/ArrayToModelTransformerTest.php (php_unit_strict)
  20) Tests/Form/DataTransformer/ModelToIdTransformerTest.php (php_unit_strict)
  21) Tests/Form/DataTransformer/ModelToIdPropertyTransformerTest.php (php_unit_strict)
  22) Tests/Form/Type/ModelAutocompleteTypeTest.php (php_unit_strict)
  23) Tests/Form/Type/AdminTypeTest.php (php_unit_strict)
  24) Tests/Form/Type/ModelTypeTest.php (php_unit_strict)
  25) Tests/Form/Type/ModelHiddenTypeTest.php (php_unit_strict)
  26) Tests/Form/Type/Filter/DateTimeRangeTypeTest.php (php_unit_strict)
  27) Tests/Form/Type/ModelTypeListTest.php (php_unit_strict)
  28) Tests/Form/FormMapperTest.php (php_unit_strict)
  29) Tests/Form/Extension/Field/Type/FormTypeFieldExtensionTest.php (php_unit_strict)
  30) Tests/Command/ValidatorsTest.php (php_unit_strict)
  31) Tests/Command/ExplainAdminCommandTest.php (php_unit_strict)
  32) Tests/Command/GenerateAdminCommandTest.php (php_unit_strict)
  33) Tests/Command/CreateClassCacheCommandTest.php (php_unit_strict)
  34) Tests/DependencyInjection/Compiler/AddDependencyCallsCompilerPassTest.php (php_unit_strict)
  35) Tests/Security/Acl/Permission/MaskBuilderTest.php (php_unit_strict)
  36) Tests/Security/Handler/RoleSecurityHandlerTest.php (php_unit_strict)
  37) Tests/Security/Handler/NoopSecurityHandlerTest.php (php_unit_strict)
  38) Tests/Translator/UnderscoreLabelTranslatorStrategyTest.php (php_unit_strict)
  39) Tests/Translator/FormLabelTranslatorStrategyTest.php (php_unit_strict)
  40) Tests/Translator/BCLabelTranslatorStrategyTest.php (php_unit_strict)
  41) Tests/Translator/Extractor/JMSTranslatorBundle/AdminExtractorTest.php (php_unit_strict)
  42) Tests/Translator/NativeLabelTranslatorStrategyTest.php (php_unit_strict)
  43) Tests/Translator/NoopLabelTranslatorStrategyTest.php (php_unit_strict)
  44) Tests/Util/AdminObjectAclManipulatorTest.php (php_unit_strict)
  45) Tests/Util/AdminObjectAclDataTest.php (php_unit_strict)
  46) Tests/Filter/FilterTest.php (php_unit_strict)
  47) Tests/Show/ShowMapperTest.php (php_unit_strict)
  48) Tests/Validator/Constraints/InlineConstraintTest.php (php_unit_strict)
  49) Tests/Validator/ErrorElementTest.php (php_unit_strict)
  50) Tests/Mapper/BaseMapperTest.php (php_unit_strict)
  51) Tests/Mapper/BaseGroupedMapperTest.php (php_unit_strict)
  52) Tests/Twig/Extension/SonataAdminExtensionTest.php (php_unit_strict)
  53) Tests/Guesser/TypeGuesserChainTest.php (php_unit_strict)
  54) Tests/Export/ExporterTest.php (php_unit_strict)
  • Loading branch information
soullivaneuh committed Aug 31, 2015
1 parent 8ce1a1b commit 6d398c0
Show file tree
Hide file tree
Showing 55 changed files with 752 additions and 752 deletions.
2 changes: 2 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ return Symfony\CS\Config\Config::create()
'newline_after_open_tag',
'ordered_use',
'long_array_syntax',
'php_unit_construct',
'php_unit_strict',
))
->setUsingCache(true)
->finder($finder)
Expand Down
180 changes: 90 additions & 90 deletions Tests/Admin/AdminTest.php

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions Tests/Admin/BaseFieldDescriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function testSetName()
$description = new FieldDescription();
$description->setName('foo');

$this->assertEquals('foo', $description->getFieldName());
$this->assertEquals('foo', $description->getName());
$this->assertSame('foo', $description->getFieldName());
$this->assertSame('foo', $description->getName());
}

public function testOptions()
Expand All @@ -30,38 +30,38 @@ public function testOptions()
$description->setOption('foo', 'bar');

$this->assertNull($description->getOption('bar'));
$this->assertEquals('bar', $description->getOption('foo'));
$this->assertSame('bar', $description->getOption('foo'));

$description->mergeOptions(array('settings' => array('value_1', 'value_2')));
$description->mergeOptions(array('settings' => array('value_1', 'value_3')));

$this->assertEquals(array('value_1', 'value_2', 'value_1', 'value_3'), $description->getOption('settings'));
$this->assertSame(array('value_1', 'value_2', 'value_1', 'value_3'), $description->getOption('settings'));

$description->mergeOption('settings', array('value_4'));
$this->assertEquals(array('value_1', 'value_2', 'value_1', 'value_3', 'value_4'), $description->getOption('settings'));
$this->assertSame(array('value_1', 'value_2', 'value_1', 'value_3', 'value_4'), $description->getOption('settings'));

$description->mergeOption('bar', array('hello'));

$this->assertCount(1, $description->getOption('bar'));

$description->setOption('label', 'trucmuche');
$this->assertEquals('trucmuche', $description->getLabel());
$this->assertSame('trucmuche', $description->getLabel());
$this->assertNull($description->getTemplate());
$description->setOptions(array('type' => 'integer', 'template' => 'foo.twig.html', 'help' => 'fooHelp'));

$this->assertEquals('integer', $description->getType());
$this->assertEquals('foo.twig.html', $description->getTemplate());
$this->assertEquals('fooHelp', $description->getHelp());
$this->assertSame('integer', $description->getType());
$this->assertSame('foo.twig.html', $description->getTemplate());
$this->assertSame('fooHelp', $description->getHelp());

$this->assertCount(2, $description->getOptions());

$description->setHelp('Please enter an integer');
$this->assertEquals('Please enter an integer', $description->getHelp());
$this->assertSame('Please enter an integer', $description->getHelp());

$description->setMappingType('int');
$this->assertEquals('int', $description->getMappingType());
$this->assertSame('int', $description->getMappingType());

$this->assertEquals('short_object_description_placeholder', $description->getOption('placeholder'));
$this->assertSame('short_object_description_placeholder', $description->getOption('placeholder'));
$description->setOptions(array('placeholder' => false));
$this->assertFalse($description->getOption('placeholder'));

Expand Down Expand Up @@ -101,7 +101,7 @@ public function testGetValue()
$mock = $this->getMock('stdClass', array('getFoo'));
$mock->expects($this->once())->method('getFoo')->will($this->returnValue(42));

$this->assertEquals(42, $description->getFieldValue($mock, 'fake'));
$this->assertSame(42, $description->getFieldValue($mock, 'fake'));

/*
* Test with One parameter int
Expand All @@ -116,7 +116,7 @@ public function testGetValue()
$returnValue1 = $arg1 + 2;
$mock1->expects($this->once())->method('getWithOneParameter')->with($this->equalTo($arg1))->will($this->returnValue($returnValue1));

$this->assertEquals(40, $description1->getFieldValue($mock1, 'fake'));
$this->assertSame(40, $description1->getFieldValue($mock1, 'fake'));

/*
* Test with Two parameters int
Expand All @@ -130,7 +130,7 @@ public function testGetValue()
$mock2 = $this->getMock('stdClass', array('getWithTwoParameters'));
$returnValue2 = $arg1 + $arg2;
$mock2->expects($this->any())->method('getWithTwoParameters')->with($this->equalTo($arg1), $this->equalTo($arg2))->will($this->returnValue($returnValue2));
$this->assertEquals(42, $description2->getFieldValue($mock2, 'fake'));
$this->assertSame(42, $description2->getFieldValue($mock2, 'fake'));
}

/**
Expand Down Expand Up @@ -165,19 +165,19 @@ public function testGetTranslationDomain()
->method('getTranslationDomain')
->will($this->returnValue('AdminDomain'));

$this->assertEquals('AdminDomain', $description->getTranslationDomain());
$this->assertSame('AdminDomain', $description->getTranslationDomain());

$admin->expects($this->never())
->method('getTranslationDomain');
$description->setOption('translation_domain', 'ExtensionDomain');
$this->assertEquals('ExtensionDomain', $description->getTranslationDomain());
$this->assertSame('ExtensionDomain', $description->getTranslationDomain());
}

public function testCamelize()
{
$this->assertEquals('FooBar', BaseFieldDescription::camelize('foo_bar'));
$this->assertEquals('FooBar', BaseFieldDescription::camelize('foo bar'));
$this->assertEquals('FOoBar', BaseFieldDescription::camelize('fOo bar'));
$this->assertSame('FooBar', BaseFieldDescription::camelize('foo_bar'));
$this->assertSame('FooBar', BaseFieldDescription::camelize('foo bar'));
$this->assertSame('FOoBar', BaseFieldDescription::camelize('fOo bar'));
}
}

Expand Down
30 changes: 15 additions & 15 deletions Tests/Admin/PoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testGetGroups()
),
);

$this->assertEquals($expectedOutput, $this->pool->getGroups());
$this->assertSame($expectedOutput, $this->pool->getGroups());
}

public function testHasGroup()
Expand Down Expand Up @@ -107,7 +107,7 @@ public function testGetAdminsByGroupWhenGroupIsEmpty()
'adminGroup1' => array(),
));

$this->assertEquals(array(), $this->pool->getAdminsByGroup('adminGroup1'));
$this->assertSame(array(), $this->pool->getAdminsByGroup('adminGroup1'));
}

public function testGetAdminsByGroup()
Expand Down Expand Up @@ -147,15 +147,15 @@ public function testGetAdminForClassWithTooManyRegisteredAdmin()
{
$this->pool->setAdminClasses(array('someclass' => array('sonata.user.admin.group1', 'sonata.user.admin.group2')));
$this->assertTrue($this->pool->hasAdminByClass('someclass'));
$this->assertEquals('adminUserClass', $this->pool->getAdminByClass('someclass'));
$this->assertSame('adminUserClass', $this->pool->getAdminByClass('someclass'));
}

public function testGetAdminForClassWhenAdminClassIsSet()
{
$this->pool->setAdminServiceIds(array('sonata.user.admin.group1'));
$this->pool->setAdminClasses(array('someclass' => array('sonata.user.admin.group1')));
$this->assertTrue($this->pool->hasAdminByClass('someclass'));
$this->assertEquals('adminUserClass', $this->pool->getAdminByClass('someclass'));
$this->assertSame('adminUserClass', $this->pool->getAdminByClass('someclass'));
}

/**
Expand All @@ -170,7 +170,7 @@ public function testGetInstanceWithUndefinedServiceId()
public function testGetAdminByAdminCode()
{
$this->pool->setAdminServiceIds(array('sonata.news.admin.post'));
$this->assertEquals('adminUserClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post'));
$this->assertSame('adminUserClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post'));
}

public function testGetAdminByAdminCodeForChildClass()
Expand All @@ -194,25 +194,25 @@ public function testGetAdminByAdminCodeForChildClass()
$this->pool = new Pool($containerMock, 'Sonata', '/path/to/logo.png');
$this->pool->setAdminServiceIds(array('sonata.news.admin.post'));

$this->assertEquals('commentAdminClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post|sonata.news.admin.comment'));
$this->assertSame('commentAdminClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post|sonata.news.admin.comment'));
}

public function testGetAdminClasses()
{
$this->pool->setAdminClasses(array('someclass' => 'sonata.user.admin.group1'));
$this->assertEquals(array('someclass' => 'sonata.user.admin.group1'), $this->pool->getAdminClasses());
$this->assertSame(array('someclass' => 'sonata.user.admin.group1'), $this->pool->getAdminClasses());
}

public function testGetAdminGroups()
{
$this->pool->setAdminGroups(array('adminGroup1' => 'sonata.user.admin.group1'));
$this->assertEquals(array('adminGroup1' => 'sonata.user.admin.group1'), $this->pool->getAdminGroups());
$this->assertSame(array('adminGroup1' => 'sonata.user.admin.group1'), $this->pool->getAdminGroups());
}

public function testGetAdminServiceIds()
{
$this->pool->setAdminServiceIds(array('sonata.user.admin.group1', 'sonata.user.admin.group2', 'sonata.user.admin.group3'));
$this->assertEquals(array('sonata.user.admin.group1', 'sonata.user.admin.group2', 'sonata.user.admin.group3'), $this->pool->getAdminServiceIds());
$this->assertSame(array('sonata.user.admin.group1', 'sonata.user.admin.group2', 'sonata.user.admin.group3'), $this->pool->getAdminServiceIds());
}

public function testGetContainer()
Expand All @@ -227,29 +227,29 @@ public function testTemplates()
$this->pool->setTemplates(array('ajax' => 'Foo.html.twig'));

$this->assertNull($this->pool->getTemplate('bar'));
$this->assertEquals('Foo.html.twig', $this->pool->getTemplate('ajax'));
$this->assertSame('Foo.html.twig', $this->pool->getTemplate('ajax'));
}

public function testGetTitleLogo()
{
$this->assertEquals('/path/to/pic.png', $this->pool->getTitleLogo());
$this->assertSame('/path/to/pic.png', $this->pool->getTitleLogo());
}

public function testGetTitle()
{
$this->assertEquals('Sonata Admin', $this->pool->getTitle());
$this->assertSame('Sonata Admin', $this->pool->getTitle());
}

public function testGetOption()
{
$this->assertEquals('bar', $this->pool->getOption('foo'));
$this->assertSame('bar', $this->pool->getOption('foo'));

$this->assertEquals(null, $this->pool->getOption('non_existent_option'));
$this->assertSame(null, $this->pool->getOption('non_existent_option'));
}

public function testOptionDefault()
{
$this->assertEquals(array(), $this->pool->getOption('nonexistantarray', array()));
$this->assertSame(array(), $this->pool->getOption('nonexistantarray', array()));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Tests/Command/CreateClassCacheCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function testExecuteWithException()
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName()));
} catch (\RuntimeException $e) {
$this->assertEquals(sprintf('The file %s/classes.map does not exist', $this->tempDirectory), $e->getMessage());
$this->assertSame(sprintf('The file %s/classes.map does not exist', $this->tempDirectory), $e->getMessage());

return;
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/Command/ExplainAdminCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function testExecute()
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), 'admin' => 'acme.admin.foo'));

$this->assertEquals(sprintf(str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/../Fixtures/Command/explain_admin.txt')), get_class($this->admin), get_class($modelManager), get_class($datagridBuilder), get_class($listBuilder)), $commandTester->getDisplay());
$this->assertSame(sprintf(str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/../Fixtures/Command/explain_admin.txt')), get_class($this->admin), get_class($modelManager), get_class($datagridBuilder), get_class($listBuilder)), $commandTester->getDisplay());
}

public function testExecuteEmptyValidator()
Expand Down Expand Up @@ -246,7 +246,7 @@ public function testExecuteEmptyValidator()
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), 'admin' => 'acme.admin.foo'));

$this->assertEquals(sprintf(str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/../Fixtures/Command/explain_admin_empty_validator.txt')), get_class($this->admin), get_class($modelManager), get_class($datagridBuilder), get_class($listBuilder)), $commandTester->getDisplay());
$this->assertSame(sprintf(str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/../Fixtures/Command/explain_admin_empty_validator.txt')), get_class($this->admin), get_class($modelManager), get_class($datagridBuilder), get_class($listBuilder)), $commandTester->getDisplay());
}

public function testExecuteNonAdminService()
Expand All @@ -256,7 +256,7 @@ public function testExecuteNonAdminService()
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), 'admin' => 'nonexistent.service'));
} catch (\RuntimeException $e) {
$this->assertEquals('Service "nonexistent.service" is not an admin class', $e->getMessage());
$this->assertSame('Service "nonexistent.service" is not an admin class', $e->getMessage());

return;
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/Command/GenerateAdminCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function testExecute()
$expectedOutput .= sprintf('%3$sThe controller class "Sonata\AdminBundle\Tests\Fixtures\Bundle\Controller\FooAdminController" has been generated under the file "%1$s%2$sController%2$sFooAdminController.php".%3$s', $this->tempDirectory, DIRECTORY_SEPARATOR, PHP_EOL);
$expectedOutput .= sprintf('%3$sThe service "acme_demo_admin.admin.foo" has been appended to the file "%1$s%2$sResources%2$sconfig%2$sadmin.yml".%3$s', $this->tempDirectory, DIRECTORY_SEPARATOR, PHP_EOL);

$this->assertEquals($expectedOutput, $commandTester->getDisplay());
$this->assertSame($expectedOutput, $commandTester->getDisplay());

$this->assertFileExists($this->tempDirectory.'/Admin/FooAdmin.php');
$this->assertFileExists($this->tempDirectory.'/Controller/FooAdminController.php');
Expand Down Expand Up @@ -322,7 +322,7 @@ public function testExecuteInteractive($modelEntity)
$expectedOutput .= sprintf('%3$sThe controller class "Sonata\AdminBundle\Tests\Fixtures\Bundle\Controller\FooAdminController" has been generated under the file "%1$s%2$sController%2$sFooAdminController.php".%3$s', $this->tempDirectory, DIRECTORY_SEPARATOR, PHP_EOL);
$expectedOutput .= sprintf('%3$sThe service "acme_demo_admin.admin.foo" has been appended to the file "%1$s%2$sResources%2$sconfig%2$sadmin.yml".%3$s', $this->tempDirectory, DIRECTORY_SEPARATOR, PHP_EOL);

$this->assertEquals($expectedOutput, str_replace("\n", PHP_EOL, str_replace(PHP_EOL, "\n", $commandTester->getDisplay())));
$this->assertSame($expectedOutput, str_replace("\n", PHP_EOL, str_replace(PHP_EOL, "\n", $commandTester->getDisplay())));

$this->assertFileExists($this->tempDirectory.'/Admin/FooAdmin.php');
$this->assertFileExists($this->tempDirectory.'/Controller/FooAdminController.php');
Expand Down Expand Up @@ -366,7 +366,7 @@ public function testValidateManagerType($expected, $managerType)
$this->container->set('sonata.admin.manager.foo', $this->getMock('Sonata\AdminBundle\Model\ModelManagerInterface'));
$this->container->set('sonata.admin.manager.bar', $this->getMock('Sonata\AdminBundle\Model\ModelManagerInterface'));

$this->assertEquals($expected, $this->command->validateManagerType($managerType));
$this->assertSame($expected, $this->command->validateManagerType($managerType));
}

public function getValidateManagerTypeTests()
Expand Down
14 changes: 7 additions & 7 deletions Tests/Command/ValidatorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ValidatorsTest extends \PHPUnit_Framework_TestCase
*/
public function testValidateUsername($expected, $value)
{
$this->assertEquals($expected, Validators::validateUsername($value));
$this->assertSame($expected, Validators::validateUsername($value));
}

public function getValidateUsernameTests()
Expand Down Expand Up @@ -56,7 +56,7 @@ public function getValidateUsernameWithExceptionTests()
*/
public function testValidateEntityName($expected, $value)
{
$this->assertEquals($expected, Validators::validateEntityName($value));
$this->assertSame($expected, Validators::validateEntityName($value));
}

public function getValidateEntityNameTests()
Expand Down Expand Up @@ -96,7 +96,7 @@ public function getValidateEntityNamesWithExceptionTests()
*/
public function testValidateClass($expected, $value)
{
$this->assertEquals($expected, Validators::validateClass($value));
$this->assertSame($expected, Validators::validateClass($value));
}

public function getValidateClassTests()
Expand Down Expand Up @@ -131,7 +131,7 @@ public function getValidateClassWithExceptionTests()
*/
public function testValidateAdminClassBasename($expected, $value)
{
$this->assertEquals($expected, Validators::validateAdminClassBasename($value));
$this->assertSame($expected, Validators::validateAdminClassBasename($value));
}

public function getValidateAdminClassBasenameTests()
Expand Down Expand Up @@ -167,7 +167,7 @@ public function getValidateAdminClassBasenameWithExceptionTests()
*/
public function testValidateControllerClassBasename($expected, $value)
{
$this->assertEquals($expected, Validators::validateControllerClassBasename($value));
$this->assertSame($expected, Validators::validateControllerClassBasename($value));
}

public function getValidateControllerClassBasenameTests()
Expand Down Expand Up @@ -220,7 +220,7 @@ public function getValidateControllerClassBasenameWithExceptionTests()
*/
public function testValidateServicesFile($expected, $value)
{
$this->assertEquals($expected, Validators::validateServicesFile($value));
$this->assertSame($expected, Validators::validateServicesFile($value));
}

public function getValidateServicesFileTests()
Expand All @@ -241,7 +241,7 @@ public function getValidateServicesFileTests()
*/
public function testValidateServiceId($value)
{
$this->assertEquals($value, Validators::validateServiceId($value));
$this->assertSame($value, Validators::validateServiceId($value));
}

public function getValidateServiceIdTests()
Expand Down
Loading

0 comments on commit 6d398c0

Please sign in to comment.