Skip to content

Commit

Permalink
Fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Sep 4, 2021
1 parent 4dc85a8 commit 046fa78
Show file tree
Hide file tree
Showing 41 changed files with 391 additions and 391 deletions.
94 changes: 47 additions & 47 deletions tests/Admin/FieldDescriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,34 @@ public function testOptions(): void
]);

// test method shortcut
$this->assertNull($field->getOption('template'));
$this->assertNull($field->getOption('type'));
static::assertNull($field->getOption('template'));
static::assertNull($field->getOption('type'));

$this->assertSame('foo', $field->getTemplate());
$this->assertSame('bar', $field->getType());
static::assertSame('foo', $field->getTemplate());
static::assertSame('bar', $field->getType());

// test the default value option
$this->assertSame('default', $field->getOption('template', 'default'));
static::assertSame('default', $field->getOption('template', 'default'));

// test the merge options
$field->setOption('array', ['key1' => 'val1']);
$field->mergeOption('array', ['key1' => 'key_1', 'key2' => 'key_2']);

$this->assertSame(['key1' => 'key_1', 'key2' => 'key_2'], $field->getOption('array'));
static::assertSame(['key1' => 'key_1', 'key2' => 'key_2'], $field->getOption('array'));

$field->mergeOption('non_existent', ['key1' => 'key_1', 'key2' => 'key_2']);

$this->assertSame(['key1' => 'key_1', 'key2' => 'key_2'], $field->getOption('array'));
static::assertSame(['key1' => 'key_1', 'key2' => 'key_2'], $field->getOption('array'));

$field->mergeOptions(['array' => ['key3' => 'key_3']]);

$this->assertSame(['key1' => 'key_1', 'key2' => 'key_2', 'key3' => 'key_3'], $field->getOption('array'));
static::assertSame(['key1' => 'key_1', 'key2' => 'key_2', 'key3' => 'key_3'], $field->getOption('array'));

$field->setOption('integer', 1);

try {
$field->mergeOption('integer', []);
$this->fail('no exception raised !!');
static::fail('no exception raised !!');
} catch (\RuntimeException $e) {
}

Expand All @@ -88,7 +88,7 @@ public function testOptions(): void
'final' => 'test',
];

$this->assertSame($expected, $field->getOptions());
static::assertSame($expected, $field->getOptions());
}

public function testAssociationMapping(): void
Expand All @@ -98,9 +98,9 @@ public function testAssociationMapping(): void
'fieldName' => 'position',
]);

$this->assertSame('integer', $field->getType());
$this->assertSame('integer', $field->getMappingType());
$this->assertSame('position', $field->getFieldName());
static::assertSame('integer', $field->getType());
static::assertSame('integer', $field->getMappingType());
static::assertSame('position', $field->getFieldName());

// NEXT_MAJOR: Remove all the rest of the test.
// cannot overwrite defined definition
Expand All @@ -109,9 +109,9 @@ public function testAssociationMapping(): void
'fieldName' => 'overwritten',
]);

$this->assertSame('integer', $field->getType());
$this->assertSame('integer', $field->getMappingType());
$this->assertSame('overwritten', $field->getFieldName());
static::assertSame('integer', $field->getType());
static::assertSame('integer', $field->getMappingType());
static::assertSame('overwritten', $field->getFieldName());
}

public function testGetParent(): void
Expand All @@ -120,7 +120,7 @@ public function testGetParent(): void
$field = new FieldDescription('name');
$field->setParent($adminMock);

$this->assertSame($adminMock, $field->getParent());
static::assertSame($adminMock, $field->getParent());
}

public function testGetAdmin(): void
Expand All @@ -129,36 +129,36 @@ public function testGetAdmin(): void
$field = new FieldDescription('name');
$field->setAdmin($adminMock);

$this->assertSame($adminMock, $field->getAdmin());
static::assertSame($adminMock, $field->getAdmin());
}

public function testGetAssociationAdmin(): void
{
$adminMock = $this->createMock(AbstractAdmin::class);
$adminMock->expects($this->once())
$adminMock->expects(static::once())
->method('setParentFieldDescription')
->with($this->isInstanceOf(FieldDescriptionInterface::class));
->with(static::isInstanceOf(FieldDescriptionInterface::class));

$field = new FieldDescription('name');
$field->setAssociationAdmin($adminMock);

$this->assertSame($adminMock, $field->getAssociationAdmin());
static::assertSame($adminMock, $field->getAssociationAdmin());
}

public function testHasAssociationAdmin(): void
{
$adminMock = $this->createMock(AbstractAdmin::class);
$adminMock->expects($this->once())
$adminMock->expects(static::once())
->method('setParentFieldDescription')
->with($this->isInstanceOf(FieldDescriptionInterface::class));
->with(static::isInstanceOf(FieldDescriptionInterface::class));

$field = new FieldDescription('name');

$this->assertFalse($field->hasAssociationAdmin());
static::assertFalse($field->hasAssociationAdmin());

$field->setAssociationAdmin($adminMock);

$this->assertTrue($field->hasAssociationAdmin());
static::assertTrue($field->hasAssociationAdmin());
}

public function testGetAssociationMapping(): void
Expand All @@ -169,7 +169,7 @@ public function testGetAssociationMapping(): void
];

$field = new FieldDescription('name', [], [], $associationMapping);
$this->assertSame($associationMapping, $field->getAssociationMapping());
static::assertSame($associationMapping, $field->getAssociationMapping());
}

/**
Expand Down Expand Up @@ -203,7 +203,7 @@ public function testSetFieldMappingSetType(): void

$field = new FieldDescription('position', [], $fieldMapping);

$this->assertSame('integer', $field->getType());
static::assertSame('integer', $field->getType());
}

public function testSetFieldMappingSetMappingType(): void
Expand All @@ -215,7 +215,7 @@ public function testSetFieldMappingSetMappingType(): void

$field = new FieldDescription('position', [], $fieldMapping);

$this->assertSame('integer', $field->getMappingType());
static::assertSame('integer', $field->getMappingType());
}

public function testGetTargetModel(): void
Expand All @@ -228,7 +228,7 @@ public function testGetTargetModel(): void

$field = new FieldDescription('position', [], [], $associationMapping);

$this->assertSame('someValue', $field->getTargetModel());
static::assertSame('someValue', $field->getTargetModel());
}

public function testIsIdentifierFromFieldMapping(): void
Expand All @@ -241,7 +241,7 @@ public function testIsIdentifierFromFieldMapping(): void

$field = new FieldDescription('position', [], $fieldMapping);

$this->assertTrue($field->isIdentifier());
static::assertTrue($field->isIdentifier());
}

public function testGetFieldMapping(): void
Expand All @@ -254,71 +254,71 @@ public function testGetFieldMapping(): void

$field = new FieldDescription('position', [], $fieldMapping);

$this->assertSame($fieldMapping, $field->getFieldMapping());
static::assertSame($fieldMapping, $field->getFieldMapping());
}

public function testGetValue(): void
{
$mockedObject = $this->getMockBuilder(\stdClass::class)->addMethods(['myMethod'])->getMock();
$mockedObject->expects($this->once())->method('myMethod')->willReturn('myMethodValue');
$mockedObject->expects(static::once())->method('myMethod')->willReturn('myMethodValue');

$field = new FieldDescription('name', ['accessor' => 'myMethod']);

$this->assertSame('myMethodValue', $field->getValue($mockedObject));
static::assertSame('myMethodValue', $field->getValue($mockedObject));
}

public function testGetValueWithParentAssociationMappings(): void
{
$mockedSubObject = $this->getMockBuilder(\stdClass::class)->addMethods(['getFieldName'])->getMock();
$mockedSubObject->expects($this->once())->method('getFieldName')->willReturn('value');
$mockedSubObject->expects(static::once())->method('getFieldName')->willReturn('value');

$mockedObject = $this->getMockBuilder(\stdClass::class)->addMethods(['getSubObject'])->getMock();
$mockedObject->expects($this->once())->method('getSubObject')->willReturn($mockedSubObject);
$mockedObject->expects(static::once())->method('getSubObject')->willReturn($mockedSubObject);

$field = new FieldDescription('name', [], [], [], [['fieldName' => 'subObject']], 'fieldName');

$this->assertSame('value', $field->getValue($mockedObject));
static::assertSame('value', $field->getValue($mockedObject));
}

public function testGetValueWhenCannotRetrieve(): void
{
$this->expectException(NoValueException::class);

$mockedObject = $this->getMockBuilder(\stdClass::class)->addMethods(['myMethod'])->getMock();
$mockedObject->expects($this->never())->method('myMethod')->willReturn('myMethodValue');
$mockedObject->expects(static::never())->method('myMethod')->willReturn('myMethodValue');

$field = new FieldDescription('name');

$this->assertSame('myMethodValue', $field->getValue($mockedObject));
static::assertSame('myMethodValue', $field->getValue($mockedObject));
}

public function testGetValueForEmbeddedObject(): void
{
$mockedEmbeddedObject = $this->getMockBuilder(\stdClass::class)->addMethods(['getMyMethod'])->getMock();
$mockedEmbeddedObject->expects($this->once())->method('getMyMethod')->willReturn('myMethodValue');
$mockedEmbeddedObject->expects(static::once())->method('getMyMethod')->willReturn('myMethodValue');

$mockedObject = $this->getMockBuilder(\stdClass::class)->addMethods(['getMyEmbeddedObject'])->getMock();
$mockedObject->expects($this->once())->method('getMyEmbeddedObject')->willReturn($mockedEmbeddedObject);
$mockedObject->expects(static::once())->method('getMyEmbeddedObject')->willReturn($mockedEmbeddedObject);

$field = new FieldDescription('myMethod', [], [], [], [], 'myEmbeddedObject.myMethod');

$this->assertSame('myMethodValue', $field->getValue($mockedObject));
static::assertSame('myMethodValue', $field->getValue($mockedObject));
}

public function testGetValueForMultiLevelEmbeddedObject(): void
{
$mockedChildEmbeddedObject = $this->getMockBuilder(\stdClass::class)->addMethods(['getMyMethod'])->getMock();
$mockedChildEmbeddedObject->expects($this->once())->method('getMyMethod')->willReturn('myMethodValue');
$mockedChildEmbeddedObject->expects(static::once())->method('getMyMethod')->willReturn('myMethodValue');

$mockedEmbeddedObject = $this->getMockBuilder(\stdClass::class)->addMethods(['getChild'])->getMock();
$mockedEmbeddedObject->expects($this->once())->method('getChild')->willReturn($mockedChildEmbeddedObject);
$mockedEmbeddedObject->expects(static::once())->method('getChild')->willReturn($mockedChildEmbeddedObject);

$mockedObject = $this->getMockBuilder(\stdClass::class)->addMethods(['getMyEmbeddedObject'])->getMock();
$mockedObject->expects($this->once())->method('getMyEmbeddedObject')->willReturn($mockedEmbeddedObject);
$mockedObject->expects(static::once())->method('getMyEmbeddedObject')->willReturn($mockedEmbeddedObject);

$field = new FieldDescription('myMethod', [], [], [], [], 'myEmbeddedObject.child.myMethod');

$this->assertSame('myMethodValue', $field->getValue($mockedObject));
static::assertSame('myMethodValue', $field->getValue($mockedObject));
}

/**
Expand All @@ -333,7 +333,7 @@ public function testDescribesSingleValuedAssociation($mappingType, bool $expecte
'fieldName' => 'foo',
'type' => $mappingType,
]);
$this->assertSame($expected, $fd->describesSingleValuedAssociation());
static::assertSame($expected, $fd->describesSingleValuedAssociation());
}

/**
Expand All @@ -360,7 +360,7 @@ public function testDescribesCollectionValuedAssociation($mappingType, bool $exp
'fieldName' => 'foo',
'type' => $mappingType,
]);
$this->assertSame($expected, $fd->describesCollectionValuedAssociation());
static::assertSame($expected, $fd->describesCollectionValuedAssociation());
}

/**
Expand Down
16 changes: 8 additions & 8 deletions tests/Block/AuditBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ public function testExecute(): void
{
$blockContext = $this->createMock(BlockContextInterface::class);

$blockContext->expects($this->once())->method('getBlock')->willReturn($block = new Block());
$blockContext->expects($this->once())->method('getSetting')->with('limit')->willReturn($limit = 10);
$blockContext->expects(static::once())->method('getBlock')->willReturn($block = new Block());
$blockContext->expects(static::once())->method('getSetting')->with('limit')->willReturn($limit = 10);

$this->simpleThingsAuditReader
->expects($this->once())
->expects(static::once())
->method('findRevisionHistory')
->with($limit, 0)
->willReturn([$revision = new Revision('test', new \DateTime(), 'test')]);

$this->simpleThingsAuditReader
->expects($this->once())
->expects(static::once())
->method('findEntitiesChangedAtRevision')
->willReturn([]);

$blockContext->expects($this->once())->method('getTemplate')->willReturn('template');
$blockContext->expects($this->once())->method('getSettings')->willReturn([]);
$blockContext->expects(static::once())->method('getTemplate')->willReturn('template');
$blockContext->expects(static::once())->method('getSettings')->willReturn([]);

$this->twig
->expects($this->once())
->expects(static::once())
->method('render')
->with('template', [
'block' => $block,
Expand All @@ -80,7 +80,7 @@ public function testExecute(): void

$response = $this->blockService->execute($blockContext);

$this->assertSame('content', $response->getContent());
static::assertSame('content', $response->getContent());
}

public function testDefaultSettings(): void
Expand Down
10 changes: 5 additions & 5 deletions tests/Block/DeprecatedAuditBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DeprecatedAuditBlockServiceTest extends BlockServiceTestCase
protected function setUp(): void
{
if (!property_exists($this, 'templating')) {
$this->markTestSkipped(sprintf(
static::markTestSkipped(sprintf(
'%s requires sonata-project/block-bundle < 3.18.4.',
__CLASS__
));
Expand Down Expand Up @@ -75,10 +75,10 @@ public function testExecute(): void

$this->blockService->execute($blockContext->reveal());

$this->assertSame('template', $this->templating->view);
$this->assertIsArray($this->templating->parameters['settings']);
$this->assertSame($revision, $this->templating->parameters['revisions'][0]['revision']);
$this->assertSame($block, $this->templating->parameters['block']);
static::assertSame('template', $this->templating->view);
static::assertIsArray($this->templating->parameters['settings']);
static::assertSame($revision, $this->templating->parameters['revisions'][0]['revision']);
static::assertSame($block, $this->templating->parameters['block']);
}

/**
Expand Down
14 changes: 7 additions & 7 deletions tests/Builder/DatagridBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public function testGetBaseDatagrid($pagerType, $pager): void

$datagrid = $this->datagridBuilder->getBaseDatagrid($this->admin);

$this->assertInstanceOf(Datagrid::class, $datagrid);
$this->assertInstanceOf($pager, $datagrid->getPager());
static::assertInstanceOf(Datagrid::class, $datagrid);
static::assertInstanceOf($pager, $datagrid->getPager());
}

public function getBaseDatagridData()
Expand Down Expand Up @@ -129,10 +129,10 @@ public function testFixFieldDescription(): void

$fieldDescription = new FieldDescription('test', [], ['type' => ClassMetadata::ONE_TO_MANY]);

$this->admin->expects($this->once())->method('attachAdminClass');
$this->admin->expects(static::once())->method('attachAdminClass');
// NEXT_MAJOR: Remove the next 2 lines.
$this->modelManager->method('hasMetadata')->willReturn(true);
$this->modelManager->expects($this->once())->method('getParentMetadataForProperty')
$this->modelManager->expects(static::once())->method('getParentMetadataForProperty')
->willReturn([$classMetadata, 'someField', []]);

$this->datagridBuilder->fixFieldDescription($this->admin, $fieldDescription);
Expand All @@ -145,17 +145,17 @@ public function testAddFilterNoType(): void

$fieldDescription = new FieldDescription('test');

$this->admin->expects($this->once())->method('addFilterFieldDescription');
$this->admin->expects(static::once())->method('addFilterFieldDescription');
$this->admin->method('getCode')->willReturn('someFakeCode');
$this->admin->method('getLabelTranslatorStrategy')->willReturn(new FormLabelTranslatorStrategy());
$this->typeGuesser->method('guess')->willReturn($guessType);
// NEXT_MAJOR: Remove the next line.
$this->modelManager->expects($this->once())->method('hasMetadata')->willReturn(false);
$this->modelManager->expects(static::once())->method('hasMetadata')->willReturn(false);
$this->filterFactory->method('create')->willReturn(new ModelAutocompleteFilter());

$guessType->method('getOptions')->willReturn(['name' => 'value']);
$guessType->method('getType')->willReturn(ModelAutocompleteFilter::class);
$datagrid->method('addFilter')->with($this->isInstanceOf(ModelAutocompleteFilter::class));
$datagrid->method('addFilter')->with(static::isInstanceOf(ModelAutocompleteFilter::class));

$this->datagridBuilder->addFilter($datagrid, null, $fieldDescription, $this->admin);
}
Expand Down
Loading

0 comments on commit 046fa78

Please sign in to comment.